NodeJS Common Definitions

First-class functions:

Everything you can do with other types, you can do with functions.

You can use functions like strings, numbers, etc.(i.e. pass them around, set variables equal to them, put them in arrays, and more)

function greet() {
  console.log('hi from greet()');
}

//function are first-class

function logGreeting(fn) {
  fn();
}

// first-class
logGreeting(greet);

var greetMe = function() {
  console.log('hi from greetMe()');
}
// first-class
logGreeting(greetMe);

//
//function expression on the fly
logGreeting(function(){
  console.log('function expression on the fly')
});

Advertisements

iterm2 shortcuts

Tabs and Windows

Function Shortcut
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow
Go to Split Pane by Order of Use + ] , + [
Split Window Horizontally (same profile) + D
Split Window Vertically (same profile) + d
Split Window Horizontally (new profile) Option + + H
Split Window Vertically (new profile) Option + + V
Set Mark + M
Jump to Mark + J

Basic Moves

Function Shortcut
Move back one character Ctrl + b
Move forward one character Ctrl + f
Delete current character Ctrl + d
Delete previous character Backspace
Undo Ctrl + -

Moving Faster

Function Shortcut
Move to the start of line Ctrl + a
Move to the end of line Ctrl + e
Move forward a word Option + f
Move backward a word Option + b
Clear the screen + k

Cut and Paste

Function Shortcut
Cut from cursor to the end of line Ctrl + k
Cut from cursor to the end of word Option + d
Cut from cursor to the start of word Option + Backspace
Cut from cursor to previous whitespace Ctrl + w
Paste the last cut text Ctrl + w
Loop through and paste previously cut text Option + y
Loop through and paste the last argument of previous commands Option + .

Search the Command History

Function Shortcut
Search as you type Ctrl + r and type the search term; Repeat Ctrl + r to loop through result
Search the last remembered search term Ctrl + r twice
End the search at current history entry Ctrl + y
Cancel the search and restore original line Ctrl + g

Install Latest Google Chrome in Ubuntu/Linux Mint

To install latest Google Chrome in Ubuntu/Linux Mint open Terminal (Press Ctrl+Alt+T) and copy the following commands in the Terminal:
For 32-bit

For 64-bit

Shortcuts that save time

Imagine the following situation: you would like to clone textmate repo and make a typo in a word git (‘_’ is your cursor position):

$ git clone https://github.com/textmate/textmate _

So you’d like to correct it and… Well, the vast majority of programmers that I know will hit left arrow key over 30 times to get there because they don’t know that:

Ctrl-A returns cursor to the beginning of current line, Ctrl-E moves cursor to the end of the line, Ctrl-K deletes the rest of the line, beginning from the cursor.

Those shortcuts work on OSX almost everywhere, for example in Safari address bar.