Skip to content

Instantly share code, notes, and snippets.

View murphybytes's full-sized avatar

John Murphy murphybytes

View GitHub Profile
@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,
@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 / 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 / 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 / shared_ptr.hpp
Created June 6, 2012 03:14
Had to roll my own shared pointer
#ifndef __SHARED_PTR_HPP__
#define __SHARED_PTR_HPP__
#include <string>
#include <sstream>
using std::string;
using std::stringstream;
namespace ucp {
@murphybytes
murphybytes / dummy.sh
Created June 11, 2012 18:05
create a dummy account for Mac OSX
cp $HOME/.bash_profile $HOME/bash_profile.$(date +%Y%m%d.%s).backup
grep -q DUMMY_ACCOUNT= $HOME/.bash_profile || echo "export DUMMY_ACCOUNT=${DUMMY_ACCOUNT}" >> $HOME/.bash_profile
last_uid=$(dscl . -list /Users UniqueID | awk '$2 > 500 { print $2 }' | sort -ug | tail -n1)
unique_uid=`expr $last_uid + 1`
echo "Creating user $DUMMY_ACCOUNT with UID $unique_uid"
dscl . -create /Users/$DUMMY_ACCOUNT
dscl . -create /Users/$DUMMY_ACCOUNT UserShell /bin/bash
dscl . -create /Users/$DUMMY_ACCOUNT RealName 'dummy account'
@murphybytes
murphybytes / Program.cs
Created July 25, 2012 03:37
Demonstrates using pinvoke to pass a callback from a .net managed application to a C dll
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace MyCSharpApp
{
@murphybytes
murphybytes / ksp.json
Created August 9, 2012 14:55
kbitz collaboration setup message
{
"message_type" : "collaboration",
"collaboration_id" : "7483cac0-e22f-11e1-9b23-0800200c9a66",
"type" : "setup",
"version" : 0.1,
"task" : [{
"worker_id" : "0b152bf0-e230-11e1-9b23-0800200c9a66",
"worker_type" : "spatial",
"task" : [ {
"worker_id" : "1b152bf0-e230-11e1-9b23-0800200c9a66",
@murphybytes
murphybytes / diskcheck.sh
Created October 1, 2012 12:18
does remote disk checks
#!/bin/bash
limit=$2
echo $1
number=`ssh jam@${1} df -lah | awk '$1=="/dev/sda5"{print int($5)}'`
echo $number
@murphybytes
murphybytes / thewayitisnow.rb
Created November 29, 2012 19:41
before and after
{ renditions: [
remoteUrl: get_encoded_asset_url( 'LOW' ),
type: 'VIDEO_FULL',
displayName: "#{get_file_basename}_LOW",
refid: "#{get_file_basename}_LOW",
videoDuration: -1,
size: 0,
encodingRate: 563000,
frameWidth: 640,
frameHeight: 360,