Skip to content

Instantly share code, notes, and snippets.

View lancejpollard's full-sized avatar
😍
Lots of coding

Lance Pollard lancejpollard

😍
Lots of coding
View GitHub Profile
@butaji
butaji / server.hs
Created May 29, 2011 20:27
Simple Haskell web server
import Control.Monad
import Data.Char
import System.IO
import Network
import Data.Time.LocalTime
data RequestType = GET | POST deriving (Show)
data Request = Request { rtype :: RequestType, path :: String, options :: [(String,String)] }
data Response = Response { version :: String, statuscode :: Int }
@chadhutchins
chadhutchins / gist:1440602
Created December 6, 2011 23:36
Tarjan's strongly connected components algorithm in Javascript - followed pseudocode from http://en.wikipedia.org/wiki/Tarjan%E2%80%99s_strongly_connected_components_algorithm
window.onload = function() {
var v0 = new Vertex("0");
var v1 = new Vertex("1");
var v2 = new Vertex("2");
var v3 = new Vertex("3");
var v4 = new Vertex("4");
var v5 = new Vertex("5");
var v6 = new Vertex("6");
var v7 = new Vertex("7");
@Raynos
Raynos / a.md
Created January 23, 2012 19:48
Shim status of ES6

ES6 what can be shimmed and what not.

Currently only lists things that can be shimmed or are experimentally implemented

Note that for any kind of decent ES6 support we need an ES6 transpiler. A few projects are attempting this [Reference SO question][3]

  • [traceur][4]
  • [Caja][5]
  • [ES transpiler][6]
@cwholt
cwholt / Autocomplete.js
Created February 17, 2012 16:39
node.js + redis prefix trie (autocomplete)
module.exports = function(redisClient,prefix) {
var Autocomplete = {};
Autocomplete.prefix = prefix;
Autocomplete.terminal = "+";
Autocomplete.add = function(word, next) {
function add(letters, key, last, x) {
var letter = last ? Autocomplete.terminal : letters[x];
var score = last ? 0 : letter.charCodeAt(0);
@clemherreman
clemherreman / install.sh
Created February 20, 2012 13:17
How to: install nodeJS on debian Squeeze, via @sekati
sudo apt-get update && apt-get install git-core curl build-essential openssl libssl-dev
git clone https://github.com/joyent/node.git
cd node
# 'git tag' shows all available versions: select the latest stable.
git checkout enter-a-version
# Configure seems not to find libssl by default so we give it an explicit pointer.
# Optionally: you can isolate node by adding --prefix=/opt/node
@dvberkel
dvberkel / gist:1950267
Created March 1, 2012 14:53
Duvals Algorithm for generating Lyndon words
"""Lyndon.py
Algorithms on strings and sequences based on Lyndon words.
David Eppstein, October 2011."""
import unittest
from Eratosthenes import MoebiusFunction
def LengthLimitedLyndonWords(s,n):
"""Generate nonempty Lyndon words of length <= n over an s-symbol alphabet.
The words are generated in lexicographic order, using an algorithm from
@lancejpollard
lancejpollard / index.md
Created March 15, 2012 18:12
Math for Coders

Sets =~ Arrays

A set is basically an array of unique items.

(A,B)

Ordered set.

[1, 2] != [2, 1]

Routing in Ember

In Ember, the application's state manager handles routing. Let's take a look at a simple example:

App.stateManager = Ember.StateManager.create({
  start: Ember.State.extend({
    index: Ember.State.extend({
      route: "/",

Routing in Ember

In Ember, the application's state manager handles routing. Let's take a look at a simple example:

App.stateManager = Ember.StateManager.create({
  start: Ember.State.extend({
    index: Ember.State.extend({
      route "/",
@lancejpollard
lancejpollard / hello-node.js
Created July 7, 2012 08:54 — forked from nf/hello-node.js
Hello world web server that scales across multiple processors
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {