Skip to content

Instantly share code, notes, and snippets.


Dan MacTough danmactough

View GitHub Profile
View http-and-https.js
var express = require('./')
, http = require('http')
, https = require('https')
, app = express.createServer();
View index.js
var mongoose = require('mongoose');
mongoose.connect('localhost', 'testing_535');
console.error('mongoose version', mongoose.version);
var OID = mongoose.Types.ObjectId;
var ASchema = new mongoose.Schema({
square: mongoose.Schema.ObjectId
, task: Number
tj / routes.js
Created Oct 15, 2011
Express routes
View routes.js
var app = require('../app');
console.log(' \033[90m%s \033[36m%s\033[0m', route.method.toUpperCase(), route.path);
erikh /
Created Mar 31, 2012 — forked from DAddYE/
OSX For Hackers
#!/usr/bin/env sh
# This is script with usefull tips taken from:
# install it:
# curl -sL | sh
View gist:2795214
import sys
import csv
import httplib, urllib, base64
def main():
# set the name of your repository, username and password
username = "test"
password = "test"
repo = "test"
piscisaureus /
Created Aug 13, 2012
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url =

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

AndreasMadsen /
Last active Nov 2, 2019
Playing with smartos
View domain-cluster-example.js
var cluster = require('cluster');
var PORT = +process.env.PORT || 1337;
if (cluster.isMaster) {
// In real life, you'd probably use more than just 2 workers,
// and perhaps not put the master and worker in the same file.
cluster.on('disconnect', function(worker) {
rektide /
Last active Dec 15, 2015
Promises are about Getting Rid of a Phase Distinction - A crude guide to what makes Promises Actually Different than every other tool.

A promise is a value, and values are by definition not machines.

Phase Distinctions, Machines, Higher Order Functions,

Tools for composing systems

In CS: a phase distinction is a boundary code goes through on it's way to being run. We write the prime artifact, "the code," but to run a machine, this code is transformed by machines, often many machines transforming, taking whatever the current code is, making decisions about what that code looks like, what it represents, and outputting a new code closer to the final execution target. This is the compilation pipeline goes go through to get executed on the target machine. Phase distinction is applied to types, as types change as code goes through the pipeline, but in general all aspects of the code are going through phasal distinctions as they become closer to being run.

Higher order functions: composing complexity

Async- the most popular library on the planet for helping to deal with functional programming- is a library dedicated to composing functio

You can’t perform that action at this time.