Skip to content

Instantly share code, notes, and snippets.

View rboyd's full-sized avatar

Robert Boyd rboyd

  • Anarchist
  • Bentonville, AR
View GitHub Profile
@rboyd
rboyd / gist:4157227
Created November 27, 2012 21:35
immutant ex
(immutant.messaging.core/with-connection :host "somehost" :port 1234 (receive (.createQueue (immutant.messaging.core/session) "SomeQueue")))
@rboyd
rboyd / gist:4157220
Created November 27, 2012 21:34
consumer example
(ns consumer
(:import [javax.jms Connection Message MessageConsumer Queue Session MessageListener TextMessage])
(:import [org.hornetq.api.core TransportConfiguration])
(:import [java.util HashMap Map])
(:import [org.hornetq.api.jms HornetQJMSClient JMSFactoryType])
(:import [org.hornetq.jms.client HornetQConnectionFactory]))
(def props (java.util.HashMap. {"host" "somehost" "port" (Integer. 1234) "use-nio" true}))
@rboyd
rboyd / accounts.clj
Created September 14, 2012 04:57 — forked from pelle/accounts.clj
Using database functions in Datomic transactions and annotating transaction history
(use '[datomic.api :only [q db] :as d])
(def uri "datomic:mem://accounts")
;; create database
(d/create-database uri)
;; connect to database
(def conn (d/connect uri))
@rboyd
rboyd / memo-dyn.txt
Created September 14, 2012 04:34 — forked from fogus/memo-dyn.txt
Memoization vs dynamic programming
Memoization is fundamentally a top-down computation and dynamic
programming is fundamentally bottom-up. In memoization, we observe
that a computational *tree* can actually be represented as a
computational *DAG* (the single most underrated data structure in
computer science); we then use a black-box to turn the tree into a
DAG. But it allows the top-down description of the problem to remain
unchanged.
In dynamic programming, we make the same observation, but construct
the DAG from the bottom-up. That means we have to rewrite the
@rboyd
rboyd / upsert-auto.clj
Created September 14, 2012 04:28 — forked from clifford/upsert-auto.clj
Upserting in Datomic
(use '[datomic.api :only (q db) :as d])
(def initial-data
[{:sku "1" :price 0.95M :qty 1}
{:sku "2" :price 1.99M :qty 0}
{:sku "3" :price 1.99M :qty 0}
{:sku "4" :price 5.99M :qty 3}
{:sku "5" :price 9.99M :qty 2}
{:sku "6" :price 2.99M :qty 3}
{:sku "7" :price 2.99M :qty 2}])
@rboyd
rboyd / .vimrc.after
Created August 14, 2012 01:51
.vimrc.after
map \rs :RunSpec<cr>
map \rsl :RunSpecLine<cr>
map \t :CommandT<cr>
set hidden
let g:RspecBin="bundle exec rspec"
inoremap <c-p> <esc>ka
inoremap <c-n> <esc>ja
inoremap <c-b> <esc>ha
inoremap <c-f> <esc>la
inoremap <c-a> <esc>0i
@rboyd
rboyd / namecheap.rb
Created August 8, 2012 05:04
namecheap api via httparty
require 'yaml'
require 'httparty'
settings = YAML::load_file(File.dirname(File.expand_path(__FILE__)) + '/namecheap.yml')
username = settings['namecheap']['user']
api_key = settings['namecheap']['api_key']
request_string = "https://api.namecheap.com/xml.response"
@rboyd
rboyd / gist:2836977
Created May 30, 2012 15:22
sublime text run spec through rvm
http://upstre.am/blog/2011/07/sublime-text-2-with-rvm-on-osx/
It's even easier as rvm already ships with a wrapper located in ~/.rvm/bin/rvm-auto-ruby. So you just need to edit the Ruby.sublime-build to this:
{ "cmd": ["~/.rvm/bin/rvm-auto-ruby", "$file"], "file_regex": "^(...*?):([0-9]*):?([0-9]*)", "selector": "source.ruby"}
@rboyd
rboyd / gem_uninstall_all.sh
Created November 21, 2011 06:51
uninstall all gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@rboyd
rboyd / builder_ex.rb
Created November 12, 2011 21:30
builder example for ibtkm
require 'builder'
builder = Builder::XmlMarkup.new
xml = builder.transaction time: Time.now, merchant_code: 179001795 do |transaction|
transaction.price '$27.50'
transaction.billing do |billing|
billing.name 'John Doe'
billing.address1 '123 Any St'
billing.country 'Mongolia'
end