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
#!/usr/bin/env node | |
var YUI = require("yui3").YUI; | |
YUI({ | |
debug: true | |
}).use('node', 'io', function(Y) { | |
//Messing with the main page.. | |
Y.one('title').set('innerHTML', 'Digg News Headlines'); |
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 doHash(str, seed) { | |
var m = 0x5bd1e995; | |
var r = 24; | |
var h = seed ^ str.length; | |
var length = str.length; | |
var currentIndex = 0; | |
while (length >= 4) { | |
var k = UInt32(str, currentIndex); | |
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() { | |
// properties and validations | |
attr( | |
{ id:Number, unique:true, nullable:false }, | |
{ email:String, unique:true, nullable:false, min:1, max:55, format:'[a-b]' }, | |
{ salt:String }, | |
{ pswd:String }, | |
{ active:Boolean, init:false }, | |
{ tags: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
function (newDoc, oldDoc, userCtx) { | |
if (newDoc._deleted === true && userCtx.roles.indexOf('_admin') === -1) { | |
throw "Only admin can delete documents on this database." | |
} | |
} |
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
# located at /Applications/TextMate.app/Contents/SharedSupport/Support/lib/scriptmate.rb | |
# change lines 12 - 13: | |
$KCODE = 'u' if (RUBY_VERSION.to_f < 1.9) | |
require "jcode" unless "".respond_to? :each_char | |
# rest of the file is unchanged |
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
; Just drop this in /etc/couchdb/local.d/ and then | |
; start CouchDB normally. | |
; Here couch_node can be anything as long as it's uniq. | |
[os_daemons] | |
couch_node = /Users/davisp/tmp/couch-node.js | |
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
// Load the TCP Library | |
net = require('net'); | |
// Keep track of the chat clients | |
var clients = []; | |
// Start a TCP Server | |
net.createServer(function (socket) { | |
// Identify this client |
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") | |
, util = require("sys") // 0.3.x: require("util") | |
, fs = require("fs") | |
, client = http.createClient(80, "example.com") | |
, request = client.request("POST", "/", {"host":"example.com"}) | |
// send body chunks | |
request.write("hello, world") | |
// pump a file through |
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 find(root, obj) { | |
var seen = []; | |
function search(root, name, depth) { | |
if (root === obj) { | |
console.log(name); | |
return; | |
} | |
if (!depth) { return; } | |
if (seen.indexOf(root) >= 0) { return; } | |
if (typeof root !== "object") { return; } |
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 Parser = require('./jsonparse'); | |
var Http = require('http'); | |
var p = new Parser(); | |
// IMPORTANT, put your username and password in here | |
var username = "yourTwitterUsername", password = "yourPassword"; | |
var client = Http.createClient(80, "stream.twitter.com"); | |
var request = client.request("GET", "/1/statuses/sample.json", { | |
"Host": "stream.twitter.com", | |
"Authorization": (new Buffer(username + ":" + password)).toString("base64") | |
}); |
OlderNewer