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/sh | |
# Alot of these configs have been taken from the various places | |
# on the web, most from here | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# Set the colours you can use | |
black='\033[0;30m' | |
white='\033[0;37m' | |
red='\033[0;31m' |
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
var keywords = ['do', 'if', 'in', 'for', 'new', 'try', 'var', 'case', 'else', 'enum', 'null', 'this', 'true', 'void', 'with', 'break', 'catch', 'class', 'const', 'false', 'super', 'throw', 'while', 'delete', 'export', 'import', 'return', 'switch', 'typeof', 'default', 'extends', 'finally', 'continue', 'debugger', 'function', 'do', 'if', 'in', 'for', 'int', 'new', 'try', 'var', 'byte', 'case', 'char', 'else', 'enum', 'goto', 'long', 'null', 'this', 'true', 'void', 'with', 'break', 'catch', 'class', 'const', 'false', 'final', 'float', 'short', 'super', 'throw', 'while', 'delete', 'double', 'export', 'import', 'native', 'public', 'return', 'static', 'switch', 'throws', 'typeof', 'boolean', 'default', 'extends', 'finally', 'package', 'private', 'abstract', 'continue', 'debugger', 'function', 'volatile', 'interface', 'protected', 'transient', 'implements', 'instanceof', 'synchronized', 'do', 'if', 'in', 'for', 'let', 'new', 'try', 'var', 'case', 'else', 'enum', 'eval', 'null', 'this', 'true', 'void', 'with', 'brea |
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
/** | |
* Example: | |
* var foo = [ 1,2,3 ]; | |
* emptyArray( foo ); | |
* console.log( foo ); | |
* // [] | |
*/ | |
function emptyArray( arr ) { | |
//empty the array |
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
/** | |
* Example: | |
* var a = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; | |
* var b = shuffleArray( a ); | |
* console.log(b); | |
* // [2, 7, 8, 6, 5, 3, 1, 4] | |
*/ | |
function shuffleArray( arr ) { | |
var i, |
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
!!"" // false | |
!!0 // false | |
!!null // false | |
!!undefined // false | |
!!NaN // false | |
!!"hello" // true | |
!!1 // true | |
!!{} // true | |
!![] // true |
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
/** | |
* Common practice to convert arguments into an array: | |
*/ | |
var args = Array.prototype.slice.call(arguments); | |
/* or the shorthand */ | |
var args = [].slice.call(arguments); | |
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
/** | |
* Given: | |
* var myArray = [[1, 2],[3, 4, 5], [6, 7, 8, 9]]; | |
* | |
* Result: | |
* // [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
*/ | |
// Using concat() and apply() | |
var myNewArray1 = [].concat.apply([], myArray); |
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
/** | |
* Primitives | |
*/ | |
// If an Array only contains primitive values, we can deduplicate it by only using the filter and indexOf methods. | |
var deduped = [ 1, 1, 'a', 'a' ].filter(function (el, i, arr) { | |
return arr.indexOf(el) === i; | |
}); | |
console.log(deduped); // [ 1, 'a' ] |
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
// Inline | |
[latex]\mintinline[bgcolor=black]{js}|...code goes here...|[/latex] | |
// Multi line | |
[latex] | |
\begin{minted} | |
[ | |
frame=lines, | |
framesep=2mm, |
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
// leftmost | |
const callFirst = (fn, larg) => | |
function (...rest) { | |
return fn.call(this, larg, ...rest); | |
} | |
// rightmost | |
const callLast = (fn, rarg) => | |
function (...rest) { | |
return fn.call(this, ...rest, rarg); |
OlderNewer