This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const shoppingList = ['apples', 'biscuits', 'cabbage', 'dip']; | |
const isCode200 = () => Math.random() >= 0.5; | |
function getShoppingList() { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
if (isCode200()) { | |
resolve(shoppingList); | |
} else { | |
reject('There was a problem with the server, please try again.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// callback functions can help us deal with asynchronous code but it can also get messy if we have multiple sequential callbacks (not shown here) | |
var shoppingList = ['apples', 'biscuits', 'cabbage']; | |
function addItem(item, callback) { | |
setTimeout(() => { | |
shoppingList.push(item); | |
console.log("Item added to shopping list"); | |
callback(); | |
}, 200); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// without a callback, asynchronous code has unexpected results | |
var shoppingList = ['apples', 'biscuits', 'cabbage']; | |
function addItem(item) { | |
setTimeout(() => { | |
shoppingList.push(item); | |
console.log("Item added to shopping list"); | |
}, 200); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### CLI ### | |
1. `mkdir parent` | |
2. `cd parent` | |
3. `touch blah.txt` | |
4. `mkdir child` | |
5. `ls -al` --> .DS_Store is not present | |
### Finder ### | |
6. drag blah.txt from parent/ to parent/child/ | |
7. drag blah.txt from parent/child/ to parent/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PARENT_DIR=$1 | |
DOC_TITLE=$2 | |
if (( $# < 2)); then | |
echo "- - - - -\nERROR: One or more missing arguments\nExecute this command as \"xxf <parentDirectoryName> <titleForHTMLDoc>\"\n- - - - -" | |
1>&2 | |
exit 1 # if in ~/.bashrc, use return here instead of exit | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PARENT_DIR=$1 | |
if [[ -z $PARENT_DIR ]]; then | |
echo "Name of the parent directory" | |
read PARENT_DIR | |
fi | |
CURRENT_DIR=$(pwd) | |
[[ -d $PARENT_DIR ]] && echo $PARENT_DIR already exists. Process terminated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In order to run TypeScript code in a shell from the command line, you need NPM's `ts-node` package. | |
`npm install -g @[email protected]` | |
`npm install -g @[email protected]` | |
If you see a warning or an error that TypeScript has an unmet peer dependency for `@type/node`, then install it directly. | |
`npm install -g @types/node` | |
Initiate a TypeScript Node Shell | |
`ts-node` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#let Terminal know that you are using bash shell (the line that begins with '#!' is known as the interpreter line) | |
#!/bin/sh | |
#set the version number for this | |
#version 0.0.3 (8 July 2016) | |
#create a variable to hold the name of the new repository | |
#the '$1' denotes the first argument passed to this shell | |
#for example, entering 'xxr repo-name' in Terminal stores the first argument, or 'repo-name', in the variable 'repo' | |
repo=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias gs='git status -sb' | |
alias ga='git add' | |
alias gb='git branch' | |
alias gc='git commit' | |
alias gd='git diff' | |
alias gl='git log' | |
alias gp='git push origin master' | |
alias gpush='git push origin' | |
alias gdrop='git stash drop stash@{0}' | |
alias rebase='git pull --rebase' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -------------------------------------------------------------- | |
# IMPORT ALIAS COMMANDS | |
# -------------------------------------------------------------- | |
. ~/.alias | |
# -------------------------------------------------------------- | |
# NODE VERSION MANAGER | |
# -------------------------------------------------------------- | |
export NVM_DIR="$HOME/.nvm" |