Skip to content

Instantly share code, notes, and snippets.

View cwvh's full-sized avatar

Chris Van Horne cwvh

  • Seattle, WA, USA
View GitHub Profile
@cwvh
cwvh / init.el
Created January 1, 2014 01:48
~/.emacs.d/init.el
(setq initial-scratch-message nil)
(setq inhibit-startup-message t)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(prefer-coding-system 'utf-8)
(setq make-backup-files nil)
(setq auto-save-default nil)
(global-font-lock-mode t)
(setq ring-bell-function 'ignore)
@cwvh
cwvh / countingbloom.py
Created December 9, 2011 23:04
Simple counting bloom filter in Python.
def hashfn(item):
h = hash(item)
return (1 << (h%64)) | (1 << (h/64%64))
def mask(val):
return bin(hashfn(val))[2:]
class CountingBloom(object):
def __init__(self):
self.items = [0] * 64
@cwvh
cwvh / bf.hs
Last active May 18, 2018 01:50
Haskell brainfuck interpreter.
{-# LANGUAGE OverloadedStrings #-}
import Data.Array.IO
import Data.Array.Base
import Control.Applicative
import Control.Monad.Loops
import Data.Either
import Data.Attoparsec.Char8
import qualified Data.ByteString.Char8 as B
import System.Environment
@cwvh
cwvh / webauth.user.js
Created January 23, 2014 00:02
drag-and-drop this into your chrome settings -> extensions page
// ==UserScript==
// @match https://webauth.arizona.edu/*
// ==/UserScript==
var username = 'fill me in',
password = 'fill me in';
document.getElementById('username').value = username;
document.getElementById('password').value = password;
HTMLFormElement.prototype.submit.call(document.getElementById('fm1'))
@cwvh
cwvh / K.hs
Created January 9, 2014 14:55
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
import Control.Applicative
import Control.Monad.Loops
import Control.Monad.State.Strict
import Data.Either
import Data.Attoparsec.Char8
import qualified Data.ByteString.Char8 as B
@cwvh
cwvh / C.hs
Created January 7, 2014 21:31
trivial optimizing brainfuck interpreter
{-# LANGUAGE OverloadedStrings #-}
import Data.Array.IO
import Data.Array.Base
import Control.Applicative
import Control.Monad
import Data.Attoparsec.Char8
import qualified Data.ByteString.Char8 as B
import System.Environment
import Debug.Trace
@cwvh
cwvh / B.hs
Last active January 2, 2016 06:29
{-# LANGUAGE OverloadedStrings #-}
import Data.Array.IO
import Data.Array.Base
import Control.Applicative
import Control.Monad
import Data.Attoparsec.Char8
import qualified Data.ByteString.Char8 as B
import System.Environment
data Primitive =
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <boost/spirit/include/qi.hpp>
namespace ast
{
struct Left
{
@cwvh
cwvh / factorial.bf
Created December 29, 2013 03:51
factorial.. incorrect prints for values larger than 1000.
+++++++++++++++++++++++++++++++++ c1v33 : ASCII code of !
>++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++ c2v61 : ASCII code of =
>++++++++++ c3v10 : ASCII code of EOL
>++++++++++ c4v7 : quantity of numbers to be calculated
> c5v0 : current number (one digit)
>+ c6v1 : current value of factorial (up to three digits)
<< c4 : loop counter
[ block : loop to print one line and calculate next
>++++++++++++++++++++++++++++++++++++++++++++++++. c5 : print current number
@cwvh
cwvh / mandelbrot.bf
Created December 29, 2013 03:50
mandelbrot, very slow execution
A mandelbrot set fractal viewer in brainf*** written by Erik Bosman
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+
<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>
>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>>
>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>>
>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>>
>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>
[>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<<
<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>+++++++++++++++[[