Skip to content

Instantly share code, notes, and snippets.

View copiousfreetime's full-sized avatar

Jeremy Hinegardner copiousfreetime

View GitHub Profile

Keybase proof

I hereby claim:

  • I am copiousfreetime on github.
  • I am copiousfreetime (https://keybase.io/copiousfreetime) on keybase.
  • I have a public key whose fingerprint is 59D9 CFCC 8488 FEA1 5B99 667D 390B 27AA 2C12 881E

To claim this, I am signing this object:

@copiousfreetime
copiousfreetime / bench_rbtree.rb
Last active August 29, 2015 14:05
Segmentation fault with Containers::RBTreeMap
require 'benchmark'
#require 'rbtree'
require 'algorithms'
Benchmark.bm(20) do |r|
data = nil
r.report('shuffling') { data = (0..1_000_000).to_a.shuffle }
{ :hash => Hash.new,
# :classic => RBTree.new,
require 'thread'
require 'securerandom'
class MyUUIDGenerator
def initialize
@counter = 0
@address = calc_address_bits
@mutex = Mutex.new
@last_time = time_msec
end
@copiousfreetime
copiousfreetime / sql.rb
Last active March 17, 2016 22:01 — forked from zerowidth/sql.md
# https://gist.github.com/zerowidth/9696463
#
# GitHub::SQL - a helping hand for SQL in a rails app.
#
# Built for MySQL, adaptations and updates welcome.
#
# Authors/maintainers: @jbarnette, @zerowidth, et. al.
#
# The MIT License (MIT)
#
class FiberLocal
def []( key )
current[key]
end
def []=(key, value)
current[key] = value
end
def keys
@copiousfreetime
copiousfreetime / benchmark-str-append.rb
Last active December 29, 2015 12:59
Benchmarking the speed of a variety of ways to concatenate strings.
require 'benchmark'
require 'stringio'
sizes = [ 10_000, 20_000, 40_000, 80_000, 160_000, 320_000, 640_000, 1_280_000 ]
count = 10_000
CRLF = "\r\n"
sizes.each do |size|
data = "x" * size
puts "-------[ Size #{size} ]----------------------------------------"
specs.4.8
prerelease_specs.4.8
versions.list
names.list
specs
deps
gems
@copiousfreetime
copiousfreetime / gather-md5.rb
Created July 27, 2013 19:50
Gather the contents of all the md5 files below a directory and make it into a single checksum file with all the paths fixed up so the whole thing may be fed to `md5sum -c`
#!/usr/bin/env ruby
# Given a directory tree of md5 checksum files and the files they check, gather
# all the checksums and send them to stdout so we can do the following:
#
# ./gather-md5sums.rb ./disk-contents/ | md5sum -c -
require 'pathname'
root_dir = Pathname.new( ARGV.shift )
class C
@x = nil
def self.x
@x
end
def self.x=(_x)
@x = _x
end
end
@copiousfreetime
copiousfreetime / launchy-test-windows.rb
Created May 23, 2013 07:38
A variety of launchy tests for windows
require 'launchy'
rest_of_path = [
"rails-letter-opener/tmp/letter_opener/369254672_4b74f43/rich.html",
# something with %20 or other escape issues
]
prefixes = {
'drive-colon-backslash' => 'E:\\',
'drive-colon-slash' => 'E:/',