Skip to content

Instantly share code, notes, and snippets.

@coderarity
coderarity / foo.js
Last active December 14, 2015 21:09 — forked from zeromodulus/foo.js
// (c) 2013 coderarity is a boss, inc
function Foo (id) {
var _this = this;
if (id) {
db.redis.get(id, function(err, res) {
var obj = JSON.parse(res);
for (property in obj) {
if (property === 'date_created') {
_this[property] = new Date(obj[property]);
} else {
var express = require('express'),
wine = require('./routes/wines');
var app = express();
app.configure(function () {
app.use(express.logger('dev')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.bodyParser());
app.use(express.static(__dirname));
});
@coderarity
coderarity / curlPass
Created December 5, 2012 06:16 — forked from whyink/curlPass
curlPass
ofshard@whyink:~/346321 (master) $ curl -X POST \ -H "Content-type: application/json" \ --data "{ \"credentials\": githubUser:githubPassword }" \ https://nodejitsuUse
r:nodejitsuPass@webhooks.nodejitsu.com/1/auth/github
curl: (6) Couldn't resolve host ' -H'
{
"name": "nko3-intergrupo-mobile",
"version": "0.0.0-6",
"description": "Intergrupo Mobile",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"repository": {
"type": "git",
@coderarity
coderarity / gist:3965464
Created October 27, 2012 17:38 — forked from hackable/gist:3965462
Proxt
var httpProxy = require('http-proxy');
httpProxy.createServer(function (req, res, proxy) {
var buffer = httpProxy.buffer(req);
middleware(res, function() {
console.log("The request was proxied");
});
proxy.on('proxyError', function () {
@coderarity
coderarity / gist:3773010
Created September 23, 2012 20:51 — forked from anonymous/gist:3772985
NodeJS Socket.IO simple server
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
var users = {};
app.listen(80);
app.get('/', function handler (req, res) {
@coderarity
coderarity / proxy.js
Created April 14, 2012 20:05 — forked from RobSpectre/proxy.js
Proxy with buffering
var http = require('http'),
https = require('https'),
httpProxy = require('./lib/node-http-proxy');
var server = httpProxy.createServer({
target: { host: 'graph.facebook.com', port: 443, https: true },
changeOrigin: true },
function (req, res, proxy) {
console.log("Received request.");
server.proxy.response_buffer = '';