Skip to content

Instantly share code, notes, and snippets.

@hmarr
hmarr / Gemfile
Last active August 29, 2015 14:02
Encoding issue in elasticsearch-ruby
source 'https://rubygems.org'
gem 'rspec'
gem 'elasticsearch', '~> 1.0.2'

Keybase proof

I hereby claim:

  • I am hmarr on github.
  • I am hmarr (https://keybase.io/hmarr) on keybase.
  • I have a public key whose fingerprint is 5019 3A27 4A54 FCF3 525E EDC9 EC35 9447 F668 59CC

To claim this, I am signing this object:

@hmarr
hmarr / catsh
Created February 11, 2014 11:46
#!/bin/bash
echo -n "catsh% "
while read line; do
if [[ "$line" == ":exit" ]]; then
exit
fi
sh -c "cat $line"
echo -n "catsh% "
@hmarr
hmarr / gitsh
Last active August 29, 2015 13:56
Apparently percent signs are the new cool
#!/bin/bash
echo -n "gitsh% "
while read line; do
if [[ "$line" == ":exit" ]]; then
exit
fi
sh -c "git $line"
echo -n "gitsh% "
@hmarr
hmarr / hutch-deployment-notes.txt
Created October 8, 2013 08:22
Hutch deployment notes
When you install the Hutch gem, an executable called `hutch` will be installed.
Assuming you're using bundler, you can run Hutch by executing the hutch
executable. If it's executed in the working directory of a Rails app, the Rails
app will be auto-detected and any consumers in the `app/consumers` directory
will be auto loaded. If you're not using Rails, or have your consumers in
non-standard locations, pass `--require` flags to the hutch executable to
specify your consumer paths.
To run the Hutch executable, it's probably worth using a process supervisor
such as upstart, supervisord, god, etc., just as you'd use with your app

RabbitMQ Basics

As demonstrated by the tutorials on the website, RabbitMQ can be used for everything from queuing background work to building RPC systems. To use RabbitMQ effectively, it is important to understand the core concepts: queues, exchanges, bindings, and messages. The documentation on rabbitmq.com is excellent, so I won't go into much depth, but it's worth briefly mentioning the core ideas.

Basic Terminology

Exchanges are where messages are sent. Every time a message is pushed in to RabbitMQ, it goes through an exchange.

@hmarr
hmarr / gc-ruby-api-deprecation.md
Last active December 16, 2015 10:19
GoCardless Ruby Library API Deprecation

API Deprecation in gocardless-ruby

When initialising gocardless-ruby with your GoCardless account details, your merchant id must now be passed in explicitly. This means that including the manage_merchant scope in the token attribute is now deprecated.

Before

GoCardless.account_details = {
  :app_id     => 'APP_ID_XXXXXXXXXXXXXXXXXXXXX',
 :app_secret => 'APP_SECRET_XXXXXXXXXXXXXXXXX',
@hmarr
hmarr / gocardless.cs
Created September 17, 2012 13:08
GoCardless Client Libraries
GoCardless.AccountDetails = new AccountDetails {
AppId = "APP123",
AppSecret = "S3CR3T",
Token = "ACCESSTOKEN123 manage_merchant:MERCHANT123"
};
GoCardless.Connect.NewBillUrl(new BillRequest("MERCHANT123", 30m));
@hmarr
hmarr / gist:1852852
Created February 17, 2012 11:35
brew-install-redis-error
~ ⚡ brew install redis
==> Downloading http://redis.googlecode.com/files/redis-2.4.7.tar.gz
######################################################################## 100.0%
==> make -C src
MAKE hiredis
CC ae.o
CC anet.o
CC redis-benchmark.o
clang: warning: argument unused during compilation: '-rdynamic'
clang: warning: argument unused during compilation: '-ggdb'
@hmarr
hmarr / bbikes.sh
Created November 24, 2011 13:52
Determine Barclays Bike availability via the command line
function bbikes {
location=${1:-$DEFAULT_BBIKE_LOCATION}
if [ -z $location ]; then
echo "usage: bbikes <location>"
echo "(you can also set a default location with DEFAULT_BBIKE_LOCATION)"
return 1
fi
url='https://web.barclayscyclehire.tfl.gov.uk/maps'
user_agent='Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)'
data=$(curl -sA "$user_agent" "$url" | grep ShowInfoB | grep -i "$location")