Skip to content

Instantly share code, notes, and snippets.

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);
}
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,
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
// 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);
}
// 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>');
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,
$ 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
$ 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"}
@clarkf
clarkf / q.js
Created January 26, 2012 06:25
What did I do here?
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');
//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 )