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
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl https://www.npmjs.org/install.sh | sh |
reason
Offers a simple mechanism to allow extremely long expire-headers on scripts whilst still being able to switch to newer versions on the fly.
implementation
A js file defined with data-main attribute on the script tag of require.js, will always be loaded with current timestamp to always force a fresh load.
// main.js?cacheKey=TIMESTAMP-123412312321
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<title>My Web Page</title> | |
<meta charset="utf-8"> | |
<link href="/stylesheets/main.css" rel="stylesheet"> | |
</head> | |
<body> | |
</body> | |
</html> |
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
// includes bindings for fetching/fetched | |
var PaginatedCollection = Backbone.Collection.extend({ | |
initialize: function() { | |
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage'); | |
typeof(options) != 'undefined' || (options = {}); | |
this.page = 1; | |
typeof(this.perPage) != 'undefined' || (this.perPage = 10); | |
}, | |
fetch: function(options) { |
a list of slides from nodeconf
you may want to take a look at the jsconf-gist too!
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
# this can be put in [repo]/.git/config for local settings | |
# or ~/.gitconfig for global settings | |
# create a difftool "nodiff" that just returns true | |
# this path is for Mac. On linux it's /bin/true i guess | |
[diff "nodiff"] | |
command = /usr/bin/true | |
# make git ignore white space differences, many different possibilites here |
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
# ## Backbone model caching | |
# This is a simple solution to the problem "how do I make less requests to | |
# my server?". | |
# | |
# Whenever you need a model instance, this will check first if the same thing | |
# has been fetched before, and gives you the same instance instead of fetching | |
# the same data from the server again. | |
# | |
# Reusing the same instance also has the great side-effect of making your | |
# model changeable from one part of your code, with your changes being available |
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
// Generates a URL-friendly "slug" from a provided string. | |
// For example: "This Is Great!!!" transforms into "this-is-great" | |
function generateSlug (value) { | |
// 1) convert to lowercase | |
// 2) remove dashes and pluses | |
// 3) replace spaces with dashes | |
// 4) remove everything but alphanumeric characters and dashes | |
return value.toLowerCase().replace(/-+/g, '').replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, ''); | |
}; |
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 child_process = require('child_process'); | |
// exec: spawns a shell. | |
child_process.exec('ls -lah /tmp', function(error, stdout, stderr){ | |
console.log(stdout); | |
}); | |
// execFile: executes a file with the specified arguments | |
child_process.execFile('ls', ['-lah', '/tmp'], function(error, stdout, stderr){ | |
console.log(stdout); |
OlderNewer