Skip to content

Instantly share code, notes, and snippets.

View DTrejo's full-sized avatar

David Trejo DTrejo

View GitHub Profile
@DTrejo
DTrejo / node-and-npm-in-30-seconds.sh
Created November 13, 2011 21:45 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@DTrejo
DTrejo / server.js
Created January 5, 2012 08:41 — forked from anonymous/server.js
fixed :)
var http = require('http');
var fs = require('fs');
var ip = '127.0.0.1';
var port = 2000;
var www = process.cwd();
var mimetypes = {'html': 'text/html', 'js': 'text/javascript', 'css': 'text/css', 'png': 'image/png', 'svg': 'image/svg'};
var path = require('path');
http.createServer(function (req, res) {
fs.realpath(path.join(www, req.url), function(err, realpath){
@DTrejo
DTrejo / notfound.js
Created February 9, 2012 21:57
notfound not called
var http = require('http')
, director = require('director')
, PORT = process.env.port || 8000
var routes = {
'/hello': {
get: function(route) { this.res.end('/hello') }
}
}
var routerOptions = { notfound: notFound }
@DTrejo
DTrejo / animals.js
Created February 14, 2012 23:47
dog and cat and animal
function Animal() {
this.legs = 4;
};
function Dog() {
this.sound = 'woof';
};
Dog.prototype = new Animal();
function Cat() {
/*
# set a password, leave all else as default
echo "requirepass password" >> tests/auth_error.conf
# start redis server
redis-server tests/auth_error.conf
# run this script
node tests/auth_error.js
*/
@DTrejo
DTrejo / script.sh
Created March 16, 2012 02:49
how to get dropbox and flux working on your sunlab account
#
# add this to your ~/.bashrc
#
# start dropbox
if [ "$(pidof dropbox)" ]
then
# dont start
echo "dropbox is running"
else
@DTrejo
DTrejo / proposal.js
Created April 9, 2012 20:50
API thoughts for zookeeper mkdir -p
//
// How would you prefer to use a mkdir-p API?
// Note that this is for making directories in ZooKeeper :)
//
//
// Option #1
//
var mkdirp = require('zk-mkdirp');
var redis = require("../index");
var async = require("async");
// Set this to truthy to see the wire protocol and other debugging info
redis.debug_mode = process.argv[2];
client1 = redis.createClient();
client2 = redis.createClient();
multi1 = client1.multi();
@DTrejo
DTrejo / fat.json
Created May 9, 2012 06:30
biggest fatest example json you will ever see? maybe, but check out http://package.jit.su/
{
"name": "my-big-json-package-example"
, "description": "see `npm help json` for full docs. Thanks for reading! — @ddtrejo"
, "keywords": [ "keywords", "to help people find", "this package" ]
, "homepage": "http://npmjs.org/doc/json.html"
, "bugs": {
"//": "(either hash is optional)"
, "url" : "http://github.com/isaacs/npm/issues"
, "email" : "[email protected]"
}
var redis = require('redis')
, client = redis.createClient()
, assert = require('assert');
// redis.debug_mode = true;
client.on("error", function (err) {
console.log("Error " + err);
});