Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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% "

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 / Gemfile
Last active August 29, 2015 14:02
Encoding issue in elasticsearch-ruby
source 'https://rubygems.org'
gem 'rspec'
gem 'elasticsearch', '~> 1.0.2'
@hmarr
hmarr / profile-after-patch.log
Created June 23, 2014 11:46
elasticsearch-ruby profile
Your Gemfile lists the gem elasticsearch-extensions (>= 0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Starting 2 Elasticsearch nodes.............
--------------------------------------------------------------------------------
Cluster: elasticsearch_test
Status: green
Nodes: 2
+ node-2 | version: 1.1.1, pid: 79902, address: inet[/0:0:0:0:0:0:0:0%0:9251]
- node-1 | version: 1.1.1, pid: 79901, address: inet[/0:0:0:0:0:0:0:0:9250]
@hmarr
hmarr / life.rs
Last active August 29, 2015 14:03
Conway's Game of Life in Rust
use std::io::{print};
use std::cmp::{min,max};
use std::time::Duration;
#[deriving(Clone,Show,PartialEq)]
enum Cell {
Alive,
Dead,
}
@hmarr
hmarr / gist:c1def5eebf3f084ad775
Last active August 29, 2015 14:05
Google Cloud IO...
$ touch ${HOME}/foobar; time sync
real 0m2.956s
user 0m0.000s
sys 0m0.012s
$ touch ${HOME}/foobar; time sync
real 0m0.286s
user 0m0.000s
sys 0m0.004s
@hmarr
hmarr / pg-feistel-ids.sql
Last active March 30, 2020 13:45
Random-looking id generation in Postgres
CREATE OR REPLACE FUNCTION base32_encode(n bigint, min_width int DEFAULT 8) RETURNS text AS $$
DECLARE
alphabet CONSTANT text := '0123456789abcdefghjkmnpqrstvwxyz';
output text := '';
BEGIN
IF n < 0 THEN
RAISE EXCEPTION 'base32_encode called with negative value';
END IF;
WHILE n != 0 LOOP
$ echo "source 'https://rubygems.org'\ngem 'rails', '4.2.0'" > Gemfile && bundle install
[truncated]
Using rails 4.2.0
Your bundle is complete!
It was installed into ./.bundle
$ bundle exec ruby routing_issue.rb
Run options: --seed 9548
# Running: