Skip to content

Instantly share code, notes, and snippets.

View sdiehl's full-sized avatar
🦫

Stephen Diehl sdiehl

🦫
View GitHub Profile
@sdiehl
sdiehl / PKGBUILD
Created June 16, 2011 16:58
Greenlet with debug symbols
# greenlet with debug symbols for gdb
pkgname=python2-greenlet-debuginfo
pkgver=0.3.1
pkgrel=2
pkgdesc="python coroutine library"
license=("MIT")
url="http://pypi.python.org/pypi/greenlet"
depends=('python2')
source=(http://pypi.python.org/packages/source/g/greenlet/greenlet-$pkgver.tar.gz patch)
@sdiehl
sdiehl / functional.r
Created January 25, 2012 17:33
The essense of functional programming in R.
# Value of x depends on order foo, bar are called. They have the
# side effect of altering global state so they aren't pure
# functions
x = 0
foo <- function() {
x <<- (x+1)
}
import Prelude hiding (id, (.))
import Control.Category
import Control.Arrow
newtype F dom cod = F { runF :: (dom -> cod) }
instance Arrow F where
arr f = F f
first (F f) = F (fst f)
@sdiehl
sdiehl / ipython.pynb
Created August 13, 2012 22:30
ipython notebook test
{
"metadata": {
"name": "Untitled5"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@sdiehl
sdiehl / benchmarks.sh
Created August 17, 2012 02:35
Numba / Cython / Fortran
$ uname -a
Linux thinkpad 3.4.9-ARCH #1 SMP PREEMPT Sat Jul 9 14:57:41 CEST 2011 x86_64 Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz GenuineIntel GNU/Linux
$ gcc --version
gcc (GCC) 4.6.1 20110819 (prerelease)
$ gfortran --version
GNU Fortran (GCC) 4.6.1 20110819 (prerelease)
# ========
@sdiehl
sdiehl / urls.hs
Created August 17, 2012 13:52
applicative_url for dabeaz
import Network.HTTP
import Data.Functor ((<$>))
import Control.Applicative ((<*>))
fetch1 = simpleHTTP (getRequest "http://www.dabeaz.com/") >>= getResponseBody
fetch2 = simpleHTTP (getRequest "http://www.dabeaz.com/blog.html") >>= getResponseBody
combined = (++) <$> fetch1 <*> fetch2
main :: IO ()
@sdiehl
sdiehl / gist:3440916
Created August 23, 2012 20:01
wtf ghc
'-u' 'ghczmprim_GHCziTypes_Izh_static_info' '-u' 'ghczmprim_GHCziTypes_Czh_static_info' '-u' 'ghczmprim_GHCziTypes_Fzh_static_info' '-u' 'ghczmprim_GHCziTypes_Dzh_static_info' '-u' 'base_GHCziPtr_Ptr_static_info' '-u' 'base_GHCziWord_Wzh_static_info' '-u' 'base_GHCziInt_I8zh_static_info' '-u' 'base_GHCziInt_I16zh_static_info' '-u' 'base_GHCziInt_I32zh_static_info' '-u' 'base_GHCziInt_I64zh_static_info' '-u' 'base_GHCziWord_W8zh_static_info' '-u' 'base_GHCziWord_W16zh_static_info' '-u' 'base_GHCziWord_W32zh_static_info' '-u' 'base_GHCziWord_W64zh_static_info' '-u' 'base_GHCziStable_StablePtr_static_info' '-u' 'ghczmprim_GHCziTypes_Izh_con_info' '-u' 'ghczmprim_GHCziTypes_Czh_con_info' '-u' 'ghczmprim_GHCziTypes_Fzh_con_info' '-u' 'ghczmprim_GHCziTypes_Dzh_con_info' '-u' 'base_GHCziPtr_Ptr_con_info' '-u' 'base_GHCziPtr_FunPtr_con_info' '-u' 'base_GHCziStable_StablePtr_con_info' '-u' 'ghczmprim_GHCziTypes_False_closure' '-u' 'ghczmprim_GHCziTypes_True_closure' '-u' 'base_GHCziPack_unpackCString_closure' '-u' 'ba
@sdiehl
sdiehl / evil.c
Created September 19, 2012 16:56
evil
#include <Python.h>
static PyMethodDef evilmethods[] = {
{NULL, NULL} /* Sentinel */
};
static PyObject *
int_add(PyIntObject *v, PyIntObject *w)
{
return PyInt_FromLong(42);
@sdiehl
sdiehl / church
Created October 19, 2012 00:42
church.ipynb
{
"metadata": {
"name": "Church Numbers"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
; Combinators in LispyScript
(var true (function (x) (function (y) x)))
(var false (function (y) (function (y) y)))
(var prod (function (x) (function (y) (function (z) (y x)))))
(var not (function (x) (function (y) (function (z) ((x z) y)))))
(var succ (function (x) (function (y) (function (z) (y ((x y) z))))))