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
-------------------------------------------------------------------------------
-- BEGIN PRELUDE --------------------------------------------------------------
-------------------------------------------------------------------------------
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
{-# LANGUAGE OverlappingInstances #-}
undefined = undefined
@sdiehl
sdiehl / io_imp.hs
Created August 1, 2014 20:41
io_impl.hs
instance Monad IO where
{-# INLINE return #-}
{-# INLINE (>>) #-}
{-# INLINE (>>=) #-}
m >> k = m >>= \ _ -> k
return = returnIO
(>>=) = bindIO
fail s = failIO s
returnIO :: a -> IO a
@sdiehl
sdiehl / hackagedocs.sh
Created September 21, 2014 17:58
Manual Hackage docs update script
# Usage: sh hackagedocs.sh mypackage 0.1 UserName Password
cabal configure && cabal build && cabal haddock --hyperlink-source \
--html-location='http://hackage.haskell.org/package/$pkg/docs' \
--contents-location='http://hackage.haskell.org/package/$pkg'
S=$?
if [ "${S}" -eq "0" ]; then
cd "dist/doc/html"
DDIR="${1}-${2}-docs"
cp -r "${1}" "${DDIR}" && tar -c -v -z --format ustar -f "${DDIR}.tar.gz" "${DDIR}"
@sdiehl
sdiehl / Eval.hs
Last active August 29, 2015 14:13
Mini interpreter with State
module Eval (eval) where
import Syntax
import Control.Monad.State
import qualified Data.Map as Map
data Value
= VInt Int
| VUnit
@sdiehl
sdiehl / gist:507a63fcff404e79fa5b
Created February 8, 2015 03:02
vim dictionary
Diehl
Asymptotics
frontend
AST
desugar
primops
unboxed
desugaring
Lexer
REPL
_class_template = '''\
class {typename}(tuple):
'{typename}({arg_list})'
__slots__ = ()
_fields = {field_names!r}
def __new__(_cls, {arg_list}):
'Create new instance of {typename}({arg_list})'
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
// Note - The x86 and x64 versions do _not_ produce the same results, as the
// algorithms are optimized for their respective platforms. You can still
// compile and run any of them on any platform, but your performance with the
// non-native version will be less than optimal.
#include "MurmurHash3.h"
module Eval (
eval
) where
import Syntax
import Data.Functor ((<$>))
isNum :: Expr -> Bool
isNum Zero = True
isNum (Succ x) = isNum x
# SVN Gource
# Download http://gource.googlecode.com/files/svn-gource-1.2.tar.gz and place svn-source.py in directory
# 1 Day = 0.05 seconds
COMPRESSION=0.05
svn log --verbose --xml > my-project.log
python svn-gource.py --filter-dirs my-project.log > data_unsorted.log
sort -t'|' -k1 data_unsorted.log > data_sorted.log
gource --log-format custom data_sorted.log -s $(COMPRESSION) --disable-progress --stop-at-end --output-ppm-stream - | ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -vpre libx264-default gource.mp4
# Stephen Diehl ( sdiehl@clarku.edu )
# Build up an OWL ontology recursively from the Python given Python objects inheritance tree.
from xml.dom import minidom
def generate(icls):
xml = minidom.Document()
rdf = xml.createElement('rdf:RDF')
rdf.setAttribute('xmlns:owl','http://www.w3.org/2002/07/owl#')