Skip to content

Instantly share code, notes, and snippets.

View brendanhay's full-sized avatar
💭
💩

Brendan Hay brendanhay

💭
💩
View GitHub Profile
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Lens -- lens
import Control.Monad.IO.Class -- transformers
import Control.Monad.Trans.AWS -- amazonka
import Network.AWS.EC2 -- amazonka-ec2
main :: IO ()
@brendanhay
brendanhay / Data.SemVer.hs
Last active December 31, 2015 12:29
Semantic Versioning Replacement for Data.Version
{-# LANGUAGE RecordWildCards #-}
-- Module : Data.SemVer
-- Copyright : (c) 2013 Brendan Hay <brendan.g.hay@gmail.com>
-- License : This Source Code Form is subject to the terms of
-- the Mozilla Public License, v. 2.0.
-- A copy of the MPL can be found in the LICENSE file or
-- you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability : experimental
@brendanhay
brendanhay / statsd-generator.sh
Created October 26, 2012 15:06
Random metrics generation for statsd
#!/bin/bash
BUCKETS=(ball sack nut job hax red saw new grunge)
TYPES=(g c s ms)
usage() {
echo "Usage: -h [host] -p [port]"
exit 1
}
{rabbit_shovel, [
{shovels, [
{my_first_shovel, [
{sources, [
{brokers, ["amqp://user:pwd@host1/vhost"]},
{declarations, [
{'exchange.declare', [{exchange, <<"source_exchange">>}, {type, <<"direct">>}, durable]}
{'queue.declare', [{queue, <<"source_queue">>}, durable]},
{'queue.bind', [{exchange, <<"source_exchange">>}, {queue, <<"source_queue">>}]}
]}
@brendanhay
brendanhay / amqp-single-send.erl
Created March 17, 2012 13:05
AMQP single send - error monad vs nested case
-spec send(method(), #amqp_params_direct{}) -> error_m(ok, term()).
%% @private
send(Method, Params) ->
do([error_m ||
Conn <- amqp_connection:start(Params),
Chan <- amqp_connection:open_channel(Conn),
return(amqp_channel:call(Chan, Method)),
return(amqp_channel:close(Chan)),
amqp_connection:close(Conn)]).
@brendanhay
brendanhay / paginated_collection.js
Created February 11, 2012 16:23 — forked from io41/paginated_collection.js
Pagination with Backbone.js
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
typeof(options) != 'undefined' || (options = {});
this.page = 1;
typeof(this.perPage) != 'undefined' || (this.perPage = 10);
},
fetch: function(options) {
@brendanhay
brendanhay / tmux-copy-mode-osx.md
Created February 8, 2012 14:15
Tmux, copy-mode, and OSX shenanigans.

Copy, with line wrapping!

If you've been trying to copy/paste text from a multi-pane tmux session with the mouse, you've probably been pretty pissed at the blissful ignorance a terminal application has of the rodent in your hand.

The alternative, which is quote-unqoute native copy/pasting using copy-mode takes a bit to get used to. So this is one solution for copying and pasting lines from a session with correct line wrapping behaviour, albeit keyboard only.

Disclaimer

Since copy-mode has similar concepts of marks, regions, and temp buffers to Emacs .. you'll probably find it straight forward if you're familar with Emacsen. For people using vi-mode in tmux, the same still applies but obviously the default key bindings will differ alot from what I show below.

@brendanhay
brendanhay / shovel.erl
Created December 16, 2011 15:39
Auto-generate rabbit-shovel configuration for all queues
#!/usr/bin/env escript
-export([main/1]).
main([Src, Dest]) ->
Path = "./shovel.config",
Config = config(Src, Dest),
write(Config, Path),
io:format("wrote ~p shovels to ~s~n", [length(Config), Path]);
main(_Any) ->
@brendanhay
brendanhay / rabbitmq.config
Created December 16, 2011 11:10
Example Shovel Config
[
{rabbit, [
%% snip...
]},
{rabbitmq_shovel, [
{shovels, [
{'MUTHA-SHOVELER', [
{sources, [
{broker, "amqp://"}
@brendanhay
brendanhay / driver-PKGBUILD
Created October 9, 2011 17:23
ArchLinux Broadcom 4331 rev02
pkgname=compat-wireless
pkgver=20110927
realver=2011-09-27
pkgrel=1
pkgdesc='Compat wireless driver, enabled for b43 support.'
url='http://wireless.kernel.org/'
arch=('x86_64')
license=('GPL')
depends=('linux' "b43-firmware")
makedepends=('linux-api-headers' 'linux-headers')