Skip to content

Instantly share code, notes, and snippets.

💚
love

stagas stagas

💚
love
Block or report user

Report or block stagas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View dquery.js
var dnode = require('dnode')
, express = require('express')
, app = express.createServer()
app.use(express.static(__dirname))
app.listen(8080)
console.log('http://localhost:8080/')
var server = dnode(function(remote, conn) {
this.click = function() {
View gist:926364
$(function() {
var $body = $('body')
, $book = $('#book')
;(function animate_background() {
$body.animate({ backgroundColor: "#abcdef" }, 1000, function(){
$body.animate({ backgroundColor: "#000" }, 1000, animate_background)
})
}())
View gist:926226
$(document).ready(function() {
var $book = $('#book')
// wrapping the function in a closure
;(function display_icon() {
$book.hide(1000, function() {
$book.show(1000, function() {
setTimeout(function() {
display_icon();
}, 0);
});
@stagas
stagas / favicon-test.js
Created Apr 18, 2011
connect/express favicon & session problem?
View favicon-test.js
var express = require('express')
, app = express.createServer()
app.use(express.cookieParser())
app.use(express.session({ secret: 'foo' }))
app.use(function(req, res, next) {
console.log(req.url, typeof req.session)
next()
})
@stagas
stagas / jsondateparse.js
Created Apr 10, 2011
overwrite JSON.parse to deserialize dates
View jsondateparse.js
;(function() {
var parse = JSON.parse
JSON.parse = function(s, f) {
var ISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/
return parse(s, f ? f : function(key, value) {
return typeof value === 'string'
? ISO.exec(value) && new Date(value) || value
: value
})
}
@stagas
stagas / dnodedate.js
Created Apr 10, 2011
dnode date values bug
View dnodedate.js
//
var dnode = require('dnode')
dnode({
bar: function(cb) {
cb({
foo: 'bar'
, date: new Date()
})
@stagas
stagas / withtest.js
Created Apr 5, 2011
with undefined foo test
View withtest.js
var locals = {}
var err
do {
err = undefined
try {
with(locals) {
foo
bar
View gist:890255
$ node
> require('dnode')
WideCharToMultiByte: ▒ ▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒ ▒▒▒ ▒▒▒▒▒ ▒▒ ▒▒▒ ▒▒▒▒▒ ▒▒▒ ▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒.
{ [Function: dnode] connect: [Function], listen: [Function] }
>
View gist:890214
net.js:539
socket._readWatcher.set(socket.fd, true, false);
^
TypeError: Cannot call method 'set' of null
at doConnect (net.js:539:23)
at net.js:696:9
at dns.js:171:30
at IOWatcher.callback (dns.js:53:15)
@stagas
stagas / nodie.js
Created Mar 3, 2011
respawns app if it dies
View nodie.js
// mit licenced
var sys = require('util')
, child_process = require('child_process')
, proc
process.title = 'nodie'
;(function respawn(app) {
console.log('Starting', app)
You can’t perform that action at this time.