Skip to content

Instantly share code, notes, and snippets.

def attribute(name, options = {})
class_eval <<-EOS, __FILE__, __LINE__
def #{name}
attributes[:#{name}]
end
EOS
case options[:type]
when :boolean
class_eval <<-EOS, __FILE__, __LINE__
def #{name}=(new_#{name})
constant = collection.to_s.split('_').map {|characters| characters[0...1].upcase << characters[1..-1]}.join('')
(depends-on "magit")
(depends-on "smex")
(depends-on "popup")
(depends-on "auto-complete")
(depends-on "ruby-end")
require 'rubygems'
require 'shindo'
Shindo.tests('something') do
test('pending') # pending
test('truthyness') { true } # passes
test('failure') { false } # fails
end
gimme_a_client_in_mah(Context) when Context#ctx.client == undefined ->
{ok, Client} = riakc_pb_socket:start_link(?RIAK_NAME, ?RIAK_PB_PORT),
Context#ctx{client = Client}.
gimme_a_client_in_mah(Context) ->
Context.
gimme_a_client_from(Context) when Context#ctx.client == undefined ->
{ok, Client} = riakc_pb_socket:start_link(?RIAK_NAME, ?RIAK_PB_PORT),
Client;
gimme_a_client_from(Context) ->
C -> C.
gimme_a_client_from(Context) ->
case Context#ctx.client of
undefined ->
{ok, Client} = riakc_pb_socket:start_link(?RIAK_NAME, ?RIAK_PB_PORT),
Client;
C -> C
end.
{webmachine, [
{log_handlers, [
{webmachine_log_handler, ["log"]}
]}
]},
neighbor_coords({ X, Y }, Grid) ->
[ { NX, NY } ||
NX <- [ X - 1, X, X + 1 ],
NY <- [ Y - 1, Y, Y + 1 ],
{ NX, NY } /= { X, Y },
NX > 0, NY > 0,
NX =< length(Grid), NY =< length(Grid) ].
neighbor_coords(X, Y) ->
[ { NX, NY } ||
NX <- [ X - 1, X, X + 1 ],
NY <- [ Y - 1, Y, Y + 1 ],
{ NX, NY } /= { X, Y } ].