Skip to content

Instantly share code, notes, and snippets.

View sdiehl's full-sized avatar
💭
I may be slow to respond.

Stephen Diehl sdiehl

💭
I may be slow to respond.
View GitHub Profile
@sdiehl
sdiehl / run.py
Created April 13, 2011 06:35
gevent launch script
#!/usr/bin/env python
import os, sys
from gevent import monkey
monkey.patch_all()
import settings
import django.core.handlers.wsgi
from socketio import SocketIOServer
@sdiehl
sdiehl / nginx.conf
Created April 13, 2011 06:43
nginx config
worker_processes 1;
user http users;
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;
events {
worker_connections 1024;
accept_mutex off;
}
@sdiehl
sdiehl / pattern_match.coffee
Created April 16, 2011 00:35
Pattern Matching in Coffeescript
# Haskell style pattern matching using:
# https://github.com/jfd/match-js/blob/master/match.js
{Match, incl } = require './match.js'
_ = Match.incl
print = console.log
fib = Match(
0, -> 0
import sys
from cStringIO import StringIO
sys.path = [
'/opt/pypy-sandbox',
'/opt/pypy-sandbox/lib_pypy',
'/opt/pypy-sandbox/lib-python/modified-2.5.2',
'/opt/pypy-sandbox/lib-python/2.5.2',
'/opt/pypy-sandbox/lib-python/2.5.2/plat-linux2'
]
@sdiehl
sdiehl / lisp.hs
Created May 1, 2011 14:40
Minimal Lisp in Haskell
{-# LANGUAGE OverloadedStrings #-}
{- To Run:
Load in ghci
:set -XOverloadedStrings (for convenience)
Execute repl expr -}
import Control.Applicative
import Data.Attoparsec hiding (Result)
import Data.Attoparsec.Char8 (char8, isDigit_w8, isSpace_w8)
pkgbase=libwebkit
pkgname=(libwebkit libwebkit3)
pkgver=1.4.0
pkgrel=1
pkgdesc="An opensource web content engine"
arch=('i686' 'x86_64')
url="http://webkitgtk.org/"
license=('custom')
depends=('libxt' 'libxslt' 'sqlite3' 'icu' 'gstreamer0.10-base' 'libsoup' 'enchant')
makedepends=('gperf' 'gtk-doc' 'gobject-introspection' 'python2' 'gtk2')
(function(jQuery) {
$(document).ready(function() {
var html_ns = document.body.namespaceURI,
mml_ns = "http://www.w3.org/1998/Math/MathML";
window.mml_ns = mml_ns;
document.html_ns = html_ns;
document.mml_ns = mml_ns;
@sdiehl
sdiehl / observer.coffee
Created May 18, 2011 02:26
Observer Pattern in Coffeescript
class Observer
bind : (event, fn) ->
this._events ||= {}
this._events[event] ||= []
this._events[event].push(fn)
unbind: (event, fn) ->
@_events ||= {}
@sdiehl
sdiehl / LICENSE
Created May 23, 2011 00:21 — forked from kriskowal/LICENSE
Nano-promises
Copyright 2011 Kristopher Michael Kowal. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
encrypt = lambda msg: pow(int(''.join(map(lambda x: str('%.3d' % ord(x)),msg))), 65537, 5551201688147)
decrypt = lambda code: (lambda y: ''.join([chr(int(y[i:i+3])) for i in range(0, len(y), 3)]))(str(pow(code, 109182490673, 5551201688147)))