Skip to content

Instantly share code, notes, and snippets.

@seancribbs
seancribbs / Readme.md
Last active September 7, 2021 17:51 — forked from jszmajda/Readme.md
Game of Life in Erlang

Conway's Game of Life in Erlang, in 2 hours, with 0 Erlang experience, in 20 lines of code.

1337 h4x0rs:

  • @jszmajda
  • @ngauthier
  • @ericoestrich
  • @danivovich
  • @kafuchau
@seancribbs
seancribbs / jruby-1.7.2.txt
Last active December 15, 2015 00:29 — forked from bkerley/Gemfile
storing 10000 objects
done storing
Rehearsal ----------------------------------------------
individual 3.170000 0.250000 3.420000 ( 8.162000)
threaded/2 4.780000 0.350000 5.130000 ( 5.546000)
threaded/4 5.220000 0.410000 5.630000 ( 3.777000)
threaded/8 5.210000 0.430000 5.640000 ( 3.187000)
------------------------------------ total: 19.820000sec
user system total real
@seancribbs
seancribbs / bench.erl
Last active December 14, 2015 07:18 — forked from kevsmith/bench.erl
-module(bench).
-export([run/1]).
run(Count) ->
Me = self(),
timer:tc(fun() -> run(Me, Count) end).
run(Me, Count) ->
F = spawn(fun() -> worker(Me, Count) end),
module InvoiceFinders
def paid
klass.find_by_index(:business_paid, "#{owner.key}-true")
end
def unpaid
klass.find_by_index(:business_paid, "#{owner.key}-false")
end
end
@seancribbs
seancribbs / h.yaml
Created March 14, 2012 15:33 — forked from heffergm/h
production:
#protocol: http
http_port: 8000
pb_port: 8087
http_backend: Excon
ssl: true
nodes:
-
host: 10.183.38.200 # prod-riak-r01
-
# Emulates the QuickCheck ?SOMETIMES macro.
module Sometimes
def run_with_retries(example_to_run, retries)
self.example.metadata[:retries] ||= retries
retries.times do |t|
self.example.metadata[:retried] = t + 1
self.example.instance_variable_set(:@exception, nil)
example_to_run.run
break unless self.example.exception
require 'ffi'
require 'jnr-enxio-0.1.jar'
module Open
extend FFI::Library
ffi_lib 'c'
attach_function :open, [:string, :int], :int
end
@seancribbs
seancribbs / assets_resource.rb
Created October 23, 2011 14:51 — forked from jamis/assets_resource.rb
Sprockets asset resource for Webmachine (asset pipelining!)
class Resources::Assets < Webmachine::Resource
def content_types_provided
path = request.uri.path
@asset = Application.assets[path]
if @asset.present?
[[@asset.content_type, :to_asset]]
else
# Better to simply provide a content-type you CAN provide, even if it's not acceptable.
# Since the asset is not there, it'll bail anyway at resource_exists?
-module(test_helper).
-export([riak_test/1]).
riak_test(Fun) ->
start_riak(),
{ok, Riak} = riak:local_client(),
Ret = (catch Fun(Riak)),
stop_riak(),
case Ret of
Author.find_by_sql "SELECT * FROM authors INNER JOIN extensions ON authors.id = extensions.author_id GROUP BY extensions.author_id HAVING COUNT(extensions.author_id) > 0"
# Had to add the :group key to produce a unique set.
# Removing `:include => :extensions` also reduced this from two queries to one.