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
function Person(name, age, height, weight) { | |
this.name = name; | |
this.age = age; | |
this.height = height; | |
this.weight = weight; | |
} | |
Person.prototype.speak = function(speech) { | |
console.log(this.name+": "+speech); | |
} |
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 url = require('url').parse("http://closure-compiler.appspot.com/compile"); | |
var data = require('querystring').stringify({ | |
'js_code': code, | |
'compilation_level': compilation_level, | |
'output_format': 'json', | |
'output_info': ['errors','warnings','statistics','compiled_code'] | |
}); | |
var request = require('http').createClient(80, url.host).request('POST', url.pathname, | |
{ | |
host: url.host, |
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 files = ['file1','file2','file3' /*...*/]; | |
var counter = 0; | |
var length = 0; | |
var afterLoad = function () { /* all our files are loaded in here :) */ } | |
for (var i = 0; i < files.length; i++) { | |
//Increment length counter so we know that a request has been sent... | |
length++; | |
require('fs').readFile(files[i], function (data) { | |
//Increment counter variable so we know where we are |
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
// Check for hash value in URL | |
var hash = window.location.hash.substr(1); | |
//Check to ensure that a link with href == hash is on the page | |
if ($('a[href="' + hash + '"]').length) { | |
//Load the page. | |
var toLoad = hash + '.html #main-content'; | |
$('#main-content').load(toLoad); | |
} | |
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
// script.js | |
$(document).ready(function(){ | |
var $def = $('.projects').find('dl dd'); | |
$def.hide(); | |
var defBox = $('#def-box'); | |
$('.projects').hover(function(){ | |
//defBox.fadeToggle(800); | |
defBox.html('<p> Hover over my recent work to see a description <p>'); |
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 http = require('http'), | |
url = require('url'); | |
function GET(path, cb) { | |
var url = url.parse(path), | |
data = ''; | |
http.get({ | |
host: url.hostname, | |
port: url.port, |
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
$ npm -v | |
0.2.18 | |
$ node -v | |
v0.3.7 | |
$ npm update | |
npm info it worked if it ends with ok | |
npm info using npm@0.2.18 | |
npm info using node@v0.3.7 | |
npm ERR! Error connecting to server http://registry.npmjs.org/sqlite | |
npm ERR! Error connecting to server http://registry.npmjs.org/colors |
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
$ rake routes | |
... | |
admin_users GET /admin/users(.:format) {:controller=>"admin/users", :action=>"index"} | |
POST /admin/users(.:format) {:controller=>"admin/users", :action=>"create"} | |
new_admin_user GET /admin/users/new(.:format) {:controller=>"admin/users", :action=>"new"} | |
edit_admin_user GET /admin/users/:id/edit(.:format) {:controller=>"admin/users", :action=>"edit"} | |
admin_user GET /admin/users/:id(.:format) {:controller=>"admin/users", :action=>"show"} | |
PUT /admin/users/:id(.:format) {:controller=>"admin/users", :action=>"update"} | |
DELETE /admin/users/:id(.:format) {:controller=>"admin/users", :action=>"destroy"} | |
admin_root /admin(.:format) {:controller=>"admin/home", :action=>"index"} |
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 q = require('q'), | |
guid = 1; | |
function randomDefer() { | |
var defer = q.defer(), id = guid++; | |
console.log("sending %d", id); | |
setTimeout(function () { | |
console.log("resolving %d", id); | |
defer.resolve('hi'); |
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
//I copied the hash value exactly from a tracker -- this is a hex | |
//representation of the sha1sum of the info dictionary | |
var bigint = require('bigint'), | |
hash = new Buffer('8ac3731ad4b039c05393b5404afa6e7397810b41', 'hex'), | |
connection_id = new bigint('4497486125440'), | |
buffer = new Buffer(36); | |
/* ( http://www.bittorrent.org/beps/bep_0015.html ) |
OlderNewer