Skip to content

Instantly share code, notes, and snippets.

View mboeh's full-sized avatar

Matthew Boeh mboeh

View GitHub Profile
@mboeh
mboeh / Makefile
Last active August 29, 2015 14:05
play project with ocaml
run:
ocamlbuild -use-ocamlfind -package batteries world_common.native
ocamlbuild -use-ocamlfind -package batteries world.native && _build/world.native | tee results.txt
upload:
gist -u https://gist.github.com/mboeh/c45e477a8f737a9157e0 world.ml world_common.ml world_common.mli Makefile results.txt
@mboeh
mboeh / pretty-bunny.rb
Created August 5, 2014 18:35
nicer inspects for Bunny objects
# bunny uses the default Ruby inspect, which means it includes nested objects.
# that means that inspecting a Bunny::Queue ends up dumping a screenful of irrelevant
# gunk nested somewhere deep in the protocol implementation.
# These monkeypatches make #inspect terse and relevant for Exchange, Queue, Channel,
# and Session.
# Caveat emptor: there are some configuration details the inspect format doesn't cover,
# and there are very likely bugs -- this was thrown together through some experimentation
# on the REPL.
@mboeh
mboeh / cnd.rb
Created July 28, 2014 19:20
cnd.rb
alias λ proc
alias _l proc
class Object
def cnd(t:λ{},f:λ{})
t[]
end
end
class NilClass
@mboeh
mboeh / speak.rb
Last active August 29, 2015 14:04 — forked from mrinterweb/speak.rb
#! /usr/bin/env ruby
# Some of the words are misspelled to help the say program pronounce them right
#
# copy the following line and paste for fun!
# curl -O https://gist.githubusercontent.com/mrinterweb/0ed2ac30a97e25e03fad/raw/5da7c2a012a08cfcc9649e0f410d53f8986e4990/speak.rb && mv speak.rb speak && chmod a+x speak && ./speak
def envlist(name, &default)
results = (ENV["SPEAK_#{name.to_s.upcase}"] || "").split(":")
results.empty? ? default.call : results
end
@mboeh
mboeh / duplex_msg.c
Created November 29, 2013 00:44
C version of ZeroMQ experiment.
#include <czmq.h>
#include <bstrlib.h>
const char* shouter_addr = "inproc://shouter";
const char* listener_addr = "inproc://listener";
const char* ui_addr = "inproc://ui";
// Simulation Thread
typedef struct simulation_arg_t
require 'ffi-rzmq'
inport, outport, label = ARGV[0], ARGV[1], ARGV[2]
context = ZMQ::Context.new(1)
simulation = Thread.new do
shoutsock = context.socket(ZMQ::PAIR)
shoutsock.bind("inproc://shouter")
@mboeh
mboeh / snatcher.rb
Created January 9, 2013 04:15
Gillian, please use extreme caution.
class Snatcher < BasicObject
C = ::Object.new
class << C
def abduct_method(meth, arity)
ObjectSpace.each_object(Module) do |mod|
next if mod.kind_of? Class
if mod.instance_methods.include?(meth)
return mod.instance_method(meth)
end
@mboeh
mboeh / gist:4069267
Created November 14, 2012 00:02
social security
"the government borrows from it... the government could borrow more money to pay it back"
No it doesn't. No it couldn't. Please please PLEASE read up on the structure of the Social Security system before parroting the right-wing line on this. (Did you notice your link here was to an advocate of privatization?)
Social Security payments are made from the current year's Social Security tax. Any surplus collected is, by law, used to purchase (essentially) Treasury securities. This is intragovernmental debt -- it's money the government owes itself. It's actually a huge part of our current federal debt.
The federal government then goes on to spend that money on services like any other revenue. It could potentially sequester that revenue in a fund, but what would it invest it in? What form of savings is more reliable than Treasury securities? You can't just pile up money in a vault somewhere. So the government doesn't "borrow" from the Social Security Trust Fund -- the government's debt IS the Social Security T
#!/usr/bin/env ruby
require 'open-uri'
require 'rexml/document'
@mboeh
mboeh / clarify.txt
Created September 26, 2012 22:13
just for the sake of clarification
What I mean is that even though JS method invocation seems to work like this:
(obj.method)(args)
it's a bit trickier than that. See this:
> a = {}
> a.toString()
"[object Object]"
> (a.toString)()