Skip to content

Instantly share code, notes, and snippets.

Sean Cribbs seancribbs

Block or report user

Report or block seancribbs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View jruby-1.7.2.txt
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
View bench.erl
run(Count) ->
Me = self(),
timer:tc(fun() -> run(Me, Count) end).
run(Me, Count) ->
F = spawn(fun() -> worker(Me, Count) end),
View gist:2408069
module InvoiceFinders
def paid
klass.find_by_index(:business_paid, "#{owner.key}-true")
def unpaid
klass.find_by_index(:business_paid, "#{owner.key}-false")
View h.yaml
#protocol: http
http_port: 8000
pb_port: 8087
http_backend: Excon
ssl: true
host: # prod-riak-r01
View rspec_retries.rb
# 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)
break unless self.example.exception
View gist:1430966
require 'ffi'
require 'jnr-enxio-0.1.jar'
module Open
extend FFI::Library
ffi_lib 'c'
attach_function :open, [:string, :int], :int
seancribbs / assets_resource.rb
Created Oct 23, 2011 — forked from jamis/assets_resource.rb
Sprockets asset resource for Webmachine (asset pipelining!)
View assets_resource.rb
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]]
# 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?
View gist:457451
riak_test(Fun) ->
{ok, Riak} = riak:local_client(),
Ret = (catch Fun(Riak)),
case Ret of
View gist:267368
Author.find_by_sql "SELECT * FROM authors INNER JOIN extensions ON = 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.
View gist:61628
def compare_user
%w{uid gid comment home shell password}.any? do |att|
!@new_resource.send(att).nil? && @new_resource.send(att) != @current_resource.send(att)
You can’t perform that action at this time.