Skip to content

Instantly share code, notes, and snippets.

View eraserhd's full-sized avatar

Jason Felice eraserhd

View GitHub Profile
module CachingImageDB (
CachingImageDB,
openCachingImageDB,
ImageSizeType,
storeImage,
lookupImage,
@eraserhd
eraserhd / gist:994438
Created May 27, 2011 00:50 — forked from kognate/gist:994423
tumbledry
require 'yaml'
class Tumbledry
attr_accessor :patterns
def initialize
File.open('repetative.txt', 'r') do |f|
@data = f.read()
end
self.patterns = {}
@numpat = 1
end
@eraserhd
eraserhd / nfa.cpp
Created August 3, 2011 17:54
NFA matcher
#include <boost/foreach.hpp>
#include <cassert>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
static bool pattern_matches_file(string const& pattern, string const& file) {
// Build an NFA recognizer (currently only supports '*' and '?')
augroup Kiwi
au!
autocmd BufNewFile,BufRead *Spec.m,*Spec.mm set foldmethod=expr foldexpr=KiwiFoldLevel(v:lnum)
augroup END
function! KiwiFoldLevel(lnum)
let line=getline(a:lnum)
if line=~'^\s\s*\(context\|describe\|it\)\s*('
return ">" . (indent(a:lnum) / (&sts ? &sts : &ts))
elseif line=~'^\s\s*});\s*$' && getline(a:lnum+1)!~'^\s*$'
function! RunBuildCommand(cmd)
let l:BuildLog = "build/vim.log"
if bufname("%") != ""
silent write
endif
echo "Building... "
let l:StartTime = reltime()
exec "silent !" . a:cmd . " >" . l:BuildLog . " 2>&1"
@eraserhd
eraserhd / gist:1353931
Created November 10, 2011 02:33
Bio, take 1

Oh, something wasn't right when I wrote my first little game at age eight - I was going to figure this computer thing out quick and move along as usual. So many software-years later - sixteen of them professional, and eight of those in startups - I suppose I must admit defeat on that "quick" part. But as the next wave of programmers enter the arena, and I see them face some of the same problems (think, "Oh, man, don't do that again") and many new and different ones ("Wow, that was cool") I feel I can still do good in the world.

It is by caffeine alone that I set my mind in motion. It is by the beans of Java that thoughts
acquire speed, that hands acquire shaking, the shaking becomes a warning.
@eraserhd
eraserhd / project.vim
Created December 14, 2011 03:32
Sample project.vim
map <leader>xt :call RunKiwiSpecs()<CR>
map <leader>xb :call Build()<CR>
augroup cprog
au!
autocmd BufNewFile,BufRead * set formatoptions=tcql nocindent comments&
autocmd BufNewFile,BufRead *.c,*.cc,*.cpp,*.hh,*.hpp,*.h set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,:// sts=4 sw=4 et
augroup END
@eraserhd
eraserhd / syntax.?
Created June 19, 2012 01:36
Proposed syntax of compiled stack-based language
% A comment starts with '%'
123 -42 0 0xffff 0xDEAD 0b111101 % Numeric literals
"Hello, World!\r\n\t" % String literals
true false % Boolean literals
[ 2 3 4 ] % List of integers
printf + * / - on? % Names
-> % Naming operator
<- % Non-executing value-of operator
@eraserhd
eraserhd / all-at-once.scm
Created August 15, 2012 02:06
Bowling kata (chicken scheme)
#!/usr/bin/env csi -ss
(use test)
(use srfi-1)
(define (compute-bowling-score input)
(define (pins-knocked-down input-offset)
(case (string-ref input input-offset)
((#\X) 10)
((#\-) 0)
((#\/)