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
python -m SimpleHTTPServer 8000 |
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
// May ask you to install x-code command line tools | |
// If so, just follow the prompt | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" |
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
# vim:ft=zsh ts=2 sw=2 sts=2 | |
# | |
# agnoster's Theme - https://gist.github.com/3712874 | |
# A Powerline-inspired theme for ZSH | |
# | |
# # README | |
# | |
# In order for this theme to render correctly, you will need a | |
# [Powerline-patched font](https://gist.github.com/1595572). | |
# |
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
##### Optimise caching ##### | |
### Leverage Browser Caching ### | |
- 'Expires' and 'Cache-Control: max-age' | |
Specify time period browser can use a local copy without checking for a newer version. Strong cache headers - will not issue a GET request until the expiry or max age is reached. | |
- 'Last-Modified' and 'ETag' | |
Specify some characteristic that the browser checks to see if the files are the same - 'Last-Modified' is always a date; 'ETag' is any value that uniquely identifies that resource, like version number or hash. Weak cache header - the browser applies a heuristic to determine whether to use a cahce copy or not (each browser uses a different heuristic). Uses a conditional GET though - don't return a full response unless the resource has changed (thus lower latency than full GETS). |
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
// usage: log('inside coolFunc',this,arguments); | |
// http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ | |
window.log = function () { | |
log.history = log.history || []; // store logs to an array for reference | |
log.history.push( arguments ); | |
if ( this.console ){ | |
console.log( Array.prototype.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
Array.max = function( array ){ | |
return Math.max.apply( Math, array ); | |
}; | |
Array.min = function( array ){ | |
return Math.min.apply( Math, 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
/* Namespace Function */ | |
var MYAPP = MYAPP || {}; | |
MYAPP.namespace = function ( ns_string ) { | |
var parts = ns_string.split( '.' ), | |
parent = MYAPP, i; | |
if ( parts[ 0 ] === "MYAPP" ) { | |
parts = parts.slice( 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
/* Currying */ | |
// Currying is making JavaScript functions understand and handle partial application | |
// A non-curried add functions | |
var add = function ( x, y ) { | |
return x + y; | |
}; | |
// A curried add function | |
function add ( x, y ) { |
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
/* Memoization Pattern */ | |
// a single parameter example | |
var myFunc = function ( param ) { | |
if ( !myFunc.cache[ param ] ) { | |
var result = {}; | |
// ... expensive operation ... | |
myFunc.cache[ param ] = result; | |
} | |
return myFunc.cache[ param ]; |