Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View brendanhay's full-sized avatar
💭
💩

Brendan Hay brendanhay

💭
💩
View GitHub Profile
@brendanhay
brendanhay / amazonka-ec2-case-insensitive-simpl-types.hs
Created January 6, 2015 06:33
amazonka-ec2-case-insensitive-simpl-types.hs
lvl768_r4v5V
:: Data.CaseInsensitive.Internal.CI Data.Text.Internal.Text
[GblId, Str=DmdType]
lvl768_r4v5V =
case Data.Text.unpackCString# "disabled"#
of dt_a19nJ
{ Data.Text.Internal.Text ipv_s19nM ipv1_s19nN ipv2_s19nO ->
case GHC.ST.runSTRep
@ Data.Text.Internal.Text
(\ (@ s1_a19nY) (s2_a19nZ :: GHC.Prim.State# s1_a19nY) ->
#!/usr/bin/env bash
set -e
core=( documentation amazonka-core amazonka )
priority_=( s3 autoscaling elb sqs iam ec2 )
priority=${priority_[@]/#/amazonka-}
library_=( $(ls -d amazonka-*) )
λ: type ExampleResource = "foo" :> "bar" :> Capture "alt" Text :> QueryParam "quote" Bool :> Get '[JSON] Text
λ: let p = Proxy :: Proxy ExampleResource
λ: let u = BaseUrl Http
λ: let u = BaseUrl Http "localhost" 8080
λ: let example = client p u
λ: :t example
example :: Text -> Maybe Bool -> EitherT ServantError IO Text
@brendanhay
brendanhay / erlang-sort.erl
Created September 29, 2011 12:24
Order items according to another sorted array
-spec sort([integer()], [integer()]) -> {[integer()], [integer()]}.
sort([], _) -> {[], [0]};
sort(Stack, Stack) -> {Stack, [0]};
sort(Stack=[H|_], Order) ->
Length = length(Stack),
Last = lists:last(Stack),
Ops = case lists:max(Stack) of
H -> [Length];
Last -> [];
Max -> [position(Max, Stack), Length]
@brendanhay
brendanhay / cassandra-6.2-homebrew-formula.rb
Created September 30, 2011 11:19
Cassandra 6.2 Homebrew Formula
require 'formula'
class Cassandra <Formula
url 'http://archive.apache.org/dist/cassandra/0.6.2/apache-cassandra-0.6.2-bin.tar.gz'
homepage 'http://cassandra.apache.org'
md5 '9243f3bb0638b53865e4eba792719076'
version '0.6.2'
def install
(var+"lib/cassandra").mkpath
@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')
@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 / 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 / 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)]).
{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">>}]}
]}