Skip to content

Instantly share code, notes, and snippets.

View stagas's full-sized avatar
🤸

stagas stagas

🤸
View GitHub Profile
@stagas
stagas / test-methods.js
Created June 27, 2011 09:16
node-http-proxy methods not working
var http = require('http')
, httpProxy = require('http-proxy');
httpProxy.createServer(function (req, res, proxy) {
//
// Put your custom server logic here
//
proxy.proxyRequest(req, res, {
host: 'localhost',
port: 9000
@stagas
stagas / LICENSE.txt
Created May 26, 2011 06:58 — forked from 140bytes/LICENSE.txt
Padding for Strings and Numbers
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 George Stagas https://github.com/stagas
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@stagas
stagas / dquery.js
Created April 23, 2011 22:33
dquery
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() {
$(function() {
var $body = $('body')
, $book = $('#book')
;(function animate_background() {
$body.animate({ backgroundColor: "#abcdef" }, 1000, function(){
$body.animate({ backgroundColor: "#000" }, 1000, animate_background)
})
}())
$(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 April 18, 2011 19:33
connect/express favicon & session problem?
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 April 10, 2011 09:53
overwrite JSON.parse to deserialize dates
;(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 April 10, 2011 08:49
dnode date values bug
//
var dnode = require('dnode')
dnode({
bar: function(cb) {
cb({
foo: 'bar'
, date: new Date()
})
@stagas
stagas / withtest.js
Created April 5, 2011 22:20
with undefined foo test
var locals = {}
var err
do {
err = undefined
try {
with(locals) {
foo
bar
$ node
> require('dnode')
WideCharToMultiByte: ▒ ▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒ ▒▒▒ ▒▒▒▒▒ ▒▒ ▒▒▒ ▒▒▒▒▒ ▒▒▒ ▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒.
{ [Function: dnode] connect: [Function], listen: [Function] }
>