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 is how one would fetch tweets, right? | |
var http = require('http') | |
, twitter = http.createClient('80', 'api.twitter.com') | |
, request = twitter.request | |
( 'GET' | |
, '/1/statuses/user_timeline.json?user_id=56828167' | |
, {'host': 'api.twitter.com'} | |
) | |
, result = '' |
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
while (true) { | |
var now = new Date().getTime() | |
console.log(now) | |
} |
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
data = | |
{ a : | |
{ aa : | |
{ aaa : 'aaa' | |
, aab : 'aab' | |
} | |
} | |
, b : | |
{ ba : | |
{ baa : 'baa' |
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
/*************************** | |
benchmark nstore.get(id) versus nstore.find({id:id}) | |
{ 'randomID1' : { 1 : | |
{ id : '1' { title : 'title1' | |
, title : 'title1' , content : 'content1' | |
, content : 'content1' } | |
} , 2 : | |
, 'randomID2' { title : 'title2' |
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 nStore = require('nstore'); | |
var users = nStore.new(__dirname+'/users.db', function () { | |
users.save("creationix", {name: "Tim Caswell", age: 28}, function (err) { | |
if (err) { throw err; } | |
}); | |
users.find({age: 28}, function (err, results) { | |
if (err) { throw err; } | |
else { console.log(results); } | |
}); | |
}); |
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 db = require('dirty')(__dirname+'/feeds_dirty.db') | |
, n = 100000 | |
, start, t1, t2, t3 | |
; | |
db.on('load', function(){ | |
start = Date.now(); | |
console.log('----------- starting'); | |
for (var i=0; i<n; i++) | |
db.set(i, { title : 'title '+i |
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 | |
require('fs').readFile('image.png',function(err, data){ | |
console.log(require('crypto').createHash('sha1').update(data).digest('hex')) | |
}) |
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 A, B, C, test; | |
A = function() {}; | |
A.prototype.aMethod = function() { | |
console.log('aMethod'); | |
}; | |
B = function() {}; | |
B.prototype.bMethod = function() { | |
console.log('bMethod'); |
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 keys = require('keys') | |
, store = new keys.Memory({reapInterval:200}) | |
; | |
store.set('foo', JSON.stringify({bla:"blub"}), function(err){ | |
if (err) | |
console.log(err); | |
else | |
store.get('foo', function(err, val){ | |
err |
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
unhosted.send( 'asdf' | |
, to | |
, key | |
, val | |
); | |
unhosted.send | |
( 'asdf' | |
, to | |
, key |