Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Van Horne cwvh

  • Seattle, WA, USA
View GitHub Profile
@cwvh
cwvh / init.el
Created Jan 1, 2014
~/.emacs.d/init.el
View 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 Dec 9, 2011
Simple counting bloom filter in Python.
View countingbloom.py
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
Haskell brainfuck interpreter.
View bf.hs
{-# 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 Jan 23, 2014
drag-and-drop this into your chrome settings -> extensions page
View webauth.user.js
// ==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'))
View K.hs
{-# 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 Jan 7, 2014
trivial optimizing brainfuck interpreter
View C.hs
{-# 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
View B.hs
{-# 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 =
View y.cpp
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <boost/spirit/include/qi.hpp>
namespace ast
{
struct Left
{
@cwvh
cwvh / factorial.bf
Created Dec 29, 2013
factorial.. incorrect prints for values larger than 1000.
View factorial.bf
+++++++++++++++++++++++++++++++++ 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 Dec 29, 2013
mandelbrot, very slow execution
View mandelbrot.bf
A mandelbrot set fractal viewer in brainf*** written by Erik Bosman
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+
<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>
>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>>
>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>>
>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>>
>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>
[>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<<
<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>+++++++++++++++[[