Skip to content

Instantly share code, notes, and snippets.

View jvoorhis's full-sized avatar

Jeremy Voorhis jvoorhis

View GitHub Profile
" Line width nags
hi OverLength ctermbg=red ctermfg=white
let line_width_nag=0
function! ToggleLineWidthNags()
if g:line_width_nag==0
match OverLength /\%80v.\+/
let g:line_width_nag=1
else
match OverLength //
let g:line_width_nag=0
#!/usr/bin/env ruby
=begin lit
# Introducing Lit
Lit allows developers to embed Markdown in their comments, and extracts
it for them to produce human friendly documentation.
=end
require 'rubygems'
@jvoorhis
jvoorhis / gist:1428465
Created December 3, 2011 23:15 — forked from lhitchon/gist:1424751
PHP MongoLab sample
<html>
<head>
<title>Demo</title>
</head>
<body>
<h1>PHP Mongo Test</h1>
<?php
try {
$connect = $_ENV["MONGOLAB_URI"];
$m = new Mongo($connect);
class Action < Struct.new(:action)
def initialize(&block)
super block
end
def call
action.call
end
def seq(rhs)
@jvoorhis
jvoorhis / gist:1104984
Created July 25, 2011 19:37
function pointers with ruby-llvm
require 'llvm/core'
require 'llvm/execution_engine'
require 'llvm/transforms/scalar'
LLVM.init_x86
mod = LLVM::Module.new("Function Pointers")
F = LLVM::Function([LLVM::Int], LLVM::Int)
FP = LLVM::Pointer(F)
NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]):
lib/heap_dump/dumped_lookup_table.rb:7:in `each'
lib/heap_dump/dumped_module.rb:38:in `find_class'
lib/heap_dump/decoder.rb:166:in `decode'
lib/read_dump.rb:23:in `initialize'
lib/read_dump.rb:32:in `session'
app/controllers/heap_viewer_controller.rb:5:in `show'
irb(main):028:0> Complex(-1,1).real == -1
=> true
irb(main):029:0> -1 ** 0
=> -1
irb(main):030:0> Complex(-1,1).real ** 0
=> 1
@jvoorhis
jvoorhis / gist:969630
Created May 12, 2011 22:48
visitor vs catamorphism
class Int
attr_reader :value
def initialize(value)
@value = value
end
def accept(visitor, *data)
visitor.visit_int(self, *data)
end
def fold(rules)
rules[Int].call(value)
@jvoorhis
jvoorhis / fm.ll
Created April 7, 2011 05:41
LLVM bytecode dump from Siren fm.rb
; ModuleID = 'Siren'
%0 = type { float, float, float, float, float }
declare float @powf(float, float)
declare float @sinf(float)
declare float @cosf(float)
undefined method `taint!' on an instance of Hash.
kernel/delta/kernel.rb:85:in `taint! (method_missing)'
kernel/common/hash.rb:555:in `reject'