Skip to content

Instantly share code, notes, and snippets.

View seth's full-sized avatar

Seth Falcon seth

View GitHub Profile
% connection supervisor
-module (connection_sup).
-behaviour (supervisor).
-export ([start_link/1, start_connection/0, init/1]).
start_link({Ip, Port, Options}) ->
supervisor:start_link({local, ?MODULE}, ?MODULE, [Ip, Port, Options]).
start_connection () ->
supervisor:start_child (?MODULE, []).
@seth
seth / yui_compressor.rb
Created January 11, 2011 04:23
A Nanoc filter for minifying CSS and Javascript using the YUI Compressor
YUI_JAR = File.dirname(__FILE__) + "/../tools/yuicompressor-2.4.2.jar"
class YuiCompressor < Nanoc3::Filter
identifier :yui_compress
type :text => :binary
def run(content, params={})
type = type_from_extension
cmd = "java -jar #{YUI_JAR} --type #{type} -o #{output_filename}"
IO.popen(cmd, 'w') { |f| f.write(content) }
raise "yuicompressor exited with #{$?} for '#{cmd}'" unless $? == 0
@seth
seth / gist:749226
Created December 20, 2010 23:35 — forked from bigloser/gist:749171
# Cookbook Name:: openldap
# Attributes:: openldap
#
# Copyright 2008-2009, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
myfun = Proc.new do
"hi"
end
myfun.call
@seth
seth / results
Created October 3, 2010 15:36 — forked from myronmarston/results
$ ./start_with_and_index.rb
user system total real
index fail 0.420000 0.000000 0.420000 ( 0.424444)
start_with? fail 0.990000 0.000000 0.990000 ( 0.993577)
index pass 0.420000 0.000000 0.420000 ( 0.424240)
start_with? pass 1.650000 0.020000 1.670000 ( 1.672174)
if RUBY_VERSION == "1.9.2"
require 'open3'
else
require 'win32/open3'
end
@seth
seth / gist:565778
Created September 5, 2010 05:33
session for erlang fun in riak REST map reduce
[orange] riak/dev: cat map-ex.json
{"inputs":[["goog","2010-01-04"],
["goog","2010-01-05"],
["goog","2010-01-06"],
["goog","2010-01-07"],
["goog","2010-01-08"]],
"query":[{"map":{"language":"erlang",
"source":"fun(G, _, _) ->
O = [riak_object:get_value(G)],
Merge = fun(VL, _A) ->
[ lists:foldl(fun(X, Acc) -> X + Acc end, 0, VL) ]
end.
Length = fun(G, _X, _Y) ->
[ size(riak_object:get_value(G)) ]
end.
Identity = fun(G, _X, _Y) ->
[ riak_object:get_value(G) ]
109> Merge = fun(VL, _A) ->
109> [ lists:foldl(fun(X, Acc) -> X + Acc end, 0, VL) ]
109> end.
#Fun<erl_eval.12.113037538>
110>
110> Length = fun(G, _X, _Y) ->
110> [ size(riakc_obj:get_value(G)) ]
110> end.
#Fun<erl_eval.18.105910772>
111>
% using goog data import from the "fast track"
Merge = fun(VL, _A) ->
[ lists:foldl(fun(X, Acc) -> X + Acc end, 0, VL) ]
end.
Length = fun(G, _X, _Y) ->
[ erlang:byte_size(riakc_obj:get_value(G)) ]
end.