Skip to content

Instantly share code, notes, and snippets.

View murphybytes's full-sized avatar

John Murphy murphybytes

View GitHub Profile
@murphybytes
murphybytes / npv_hack.rb
Created May 31, 2012 17:49
Hack for mongoid version differences
def self.npv_item_for_security_id sec_id, swap_prices
npv_items = swap_prices.npv_items.select do |item|
item['symbol'].eql?(sec_id)
end
return nil if npv_items.empty?
npv_item = npv_items.last
npv_item = npv_item.as_document unless npv_item.is_a?(Hash)
@murphybytes
murphybytes / eight-ball.rb
Created March 29, 2012 22:13
Rich and John made a magic 8 ball using Vert.x ... and yeah could have used sample and the array but no-worky
require('vertx')
include Vertx
@server = HttpServer.new
@server.request_handler do | req |
premonition = [
@murphybytes
murphybytes / listener.rb
Created March 15, 2012 01:27
Heroku hosted iron mq message listener
require 'iron_mq'
$stdout.sync = true
def write_msg msg
puts "*"*10
puts msg
puts "*"*10
@murphybytes
murphybytes / example.cpp
Created February 21, 2012 19:59
Handy templated state machine for C++
#include <boost/test/minimal.hpp>
#include "state_machine.hpp"
#include <vector>
// define states
enum states_t {
init,
state_one,
state_two,