How-to and Snippets

This is where I will try to list out some useful information that I reference from time to time. Mostly things that I keep having to google. As they get bigger I will extract the links and howtos into separate pages

Back

Github

First time git config

to see all configs
git config -l
edit file directly
vi ~/.gitconfig - or - git config --global alias.st status
useful settings from .gitconfig file

user.name=dane
user.email=kingd9@gmail.com
alias.co=checkout
alias.st=status
alias.ci=commit
alias.br=branch
alias.shn=show --name-only
alias.lgn=log --oneline
core.editor=vim

Add an untracked repository to Github

git init
create and add any files/directories to gitignore
git add -A
git ci -m "First Commit"

Create a repository and copy path

git remote add origin <repository path>
git push -u origin master

need OAuth password to push

UI

JavaScript

Useful JS Functions

RxJs

Callbacks

Build/IDE

Babel and Typescript

Babel and Typescript

Jest

Running Jest runs node which doesn’t support ES6 imports add to env

	"env": {
		"development": {
			"plugins": ...
		},
		"test": {
			"plugins": [
			  ...
				"transform-es2015-modules-commonjs"
			]
		}

NPM

Global packages to install

npm install -g win-node-env on windows makes npm calls function as linux

Setup NPM so you don’t need sudo

Source

  • Step 1: Configure NPM
    • npm config set prefix ~/.local
    • Now NPM will install your global executables to ~/.local/bin, and the libraries to ~/.local/lib/node_modules/
  • Step 2: Add ~/.local/bin to your path
    • vi ~/.bashrc
    • PATH=~/.local/bin/:$PATH
    • source ~/.bashrc

Visual Studio Code

User Settings

  • On Windows/Linux - File > Preferences > Settings or ctl + comma
  • Sample user settings enable eslint
    {
      "git.autofetch": true,
      "editor.suggestSelection": "first",
      "emmet.triggerExpansionOnTab": true,
      "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
      "eslint.validate": [
          "javascript",
          "javascriptreact",
          {
            "language": "typescript",
            "autoFix": true
          },
          {
            "language": "typescriptreact",
            "autoFix": true
          }
        ]
    }
    

    Emmet Settings

    Source

  • “emmet.triggerExpansionOnTab”: true enables emmet expansion

Setting up eslint typescript with VSCode

  • Make sure eslint plugin is already installed
  • Install typescript eslint plugin
    • npm install eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser --save-dev
  • Install prettier and eslint can ignore formating
    • npm install prettier eslint-config-prettier --save-dev
  • Add to .eslint.json
    {
    "parser": "@typescript-eslint/parser",  
    "parserOptions": {  
      "jsx": true,  
      "useJSXTextNode": true  
    },  
    "extends": [  
      "plugin:@typescript-eslint/recommended",  
      "prettier",  
      "prettier/@typescript-eslint"  
    ],  
    "plugins": ["@typescript-eslint"]  
    } 
    
Written on March 19, 2019