Skip to content

Instantly share code, notes, and snippets.

@ludwig
ludwig / lisp.hs
Created May 1, 2011 15:31
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)
@ludwig
ludwig / about.md
Created August 11, 2011 22:12 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
# ~/.astylerc
#
# Courtesy of HN's super_mario: http://news.ycombinator.com/item?id=5348401
#
# Use K&R formatting style
style=kr
# Indent class and struct blocks so that the blocks 'public', 'private' and
# 'protected' are indented. This option is effective in C++ files only
#!/usr/bin/env python
class Base(object):
def foo(self):
print("Base")
return True
class Mixin(object):
def foo(self):
print("Mixin logs bar {0}".format(self.bar))
@ludwig
ludwig / lisp.c
Created April 5, 2014 21:47 — forked from sanxiyn/lisp.c
#include <assert.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
enum type {
NIL,
M[16],X=16,W,k;main(){T(system("stty cbreak")
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<<
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k)
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X]
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4;
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4||
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2
@ludwig
ludwig / foo.log
Created April 11, 2014 17:42 — forked from ibeex/foo.log
A warning occurred (42 apples)
An error occurred
@ludwig
ludwig / httpd.conf
Last active August 29, 2015 14:00
Flask app on WebFaction
# File /home/ludwig/webapps/flask/apache2/conf/httpd.conf
ServerRoot "/home/ludwig/webapps/flask/apache2"
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule wsgi_module modules/mod_wsgi.so
import wave, struct, sys
from math import pow, sin
samples = 100000
terms = 50
normalizer = 32768/1.5
weier = wave.open('weierstrass.wav', 'w')
weier.setparams((1, 2, 44100, 0, 'NONE', 'not compressed'))
print "Progress (%):",
for i in range(samples):
x = float(1000*i)/samples
# A guide to prevent pain and suffering while upgrading to OS X Mavericks
# This will vary greatly depending on system set up, so read the instructions carefully
# Back up Virtulenvs
####################
# Very important!
# For each virtualenv you have, run "pip freeze > requirements.txt" while in the activated virtualenv
# in order to prevent loss of dependencies during the upgrade.