Skip to content

Instantly share code, notes, and snippets.

View copiousfreetime's full-sized avatar

Jeremy Hinegardner copiousfreetime

View GitHub Profile
✦✧★✩✪✩✫✬ ★✭ ★✧✮✯✪ ✯✩✰✭✯ ✱✲✳✬ ✴✳✵✪ ✧✶ ✩✷✱ ✩✬ ✸✳✵✶✧✹✺✩✱✳✧✵
✬✮✳✷✳✪✭✻ ✧✹ ✬✧✺✭✱✲✳✵✼ ✽✭✹✫ ✬✧✾✲✳✬✱✳✷✩✱✭✪✿ ✰✭✷✩✮✬✭ ✾✭✧✾✯✭ ✩✹✭ ✺✮✷✲ ✺✧✹✭ ✩★✩✹✭ ✧✶ ✱✲✭ ✳✺✾✧✹✱✩✵✷✭ ✧✶ ✧✵✭✬❀ ✳✪✭✵✱✳✱✳✭✬✿ ✰✮✱
✳✵ ✱✲✧✬✭ ✪✩✫✬ ★✭ ✬✳✺✾✯✫ ✷✩✯✯✭✪ ✳✱ ✸❁✭✹✴✱✧✩✬✱✳✵✼✻ ✩✵✪ ✱✲✭✬✭ ✾✭✧✾✯✭ ✧✵ ✱✲✭ ✬✱✩✼✭ ★✭✹✭ ❁✮✬✱ ✩ ✶✭★ ❁✭✹✴✱✧✩✬✱✭✹✬ ★✲✧ ✼✧✱ ✷✩✮✼✲✱❂ ❃✭ ★✭✹✭ ✶✩✬✷✳✵✩✱✭✪ ✰✫ ✱✲✭✺✿ ✰✭✷✩✮✬✭ ✵✧ ✧✵✭ ✧✶ ✮✬ ✲✩✪ ✭✽✭✹ ✱✲✧✮✼✲✱ ✧✶ ✪✭✯✭✱✳✵✼ ✧✮✹✬✭✯✽✭✬❂ ❄✱ ✬✭✭✺✭✪ ✶✮✱✮✹✳✬✱✳✷
✱✧ ✪✧ ✬✧ ✩✵✪ ✳✱ ✬✭✭✺✭✪ ✱✧ ✭❅✲✳✰✳✱ ★✳✯✯✶✮✯ ✩✵✱✳✾✩✱✲✫ ✱✧ ✪✧ ✬✧✿ ★✲✳✷✲✿ ✳✵ ✩ ★✩✫✿ ✬✧✺✭✲✧★ ✬✭✭✺✬ ❆✮✳✱✭ ✶✮✱✮✹✳✬✱✳✷ ✩✬ ★✭✯✯❂ ❇❃✭ ★✭✹✭ ✩✯✯ ✬✧ ★✧✹✹✳✭✪ ✩✰✧✮✱ ✩ ✪✫✬✱✧✾✳✩✵ ✶✮✱✮✹✭ ✩✱ ✱✲✭ ✱✳✺✭✿ ✩
✶✮✱✮✹✭ ✧✶ ✩✬✬✳✺✳✯✩✱✳✧✵ ✧✹ ✩ ✶✮✱✮✹✭ ✧✶ ✬✮✹✽✭✳✯✯✩✵✷✭✿ ✩✵✪ ✱✲✭✬✭ ✾✭✧✾✯✭ ✲✩✪ ✩✬✬✳✺✳✯✩✱✭✪ ✱✲✭✺✬✭✯✽✭✬✿ ✯✧✬✱ ✱✲✭✺✬✭✯✽✭✬✿ ✳✵ ✩ ✬✱✫✯✭
✶✩✹ ✺✧✹✭ ✭✶✶✭✷✱✳✽✭ ✱✲✩✵ ✱✲✭ ✼✧✽✭✹✵✺✭✵✱ ✷✧✮✯✪ ✪✹✭✩✺❂❈ ❉✶ ✷✧✮✹✬✭✿ ❉✾✹✩✲ ★✩✵✱✭✪ ✱✧ ✷✮✱ ✹✳✼✲✱ ✱✧ ✱✲✭ ✰✧✱✱✧✺ ✧✶ ✱✲✳✵✼✬ ✩✵✪ ✬✲✭ ✬✱✹✩✳✼✲✱ ✮✾ ✩✬✴✭✪ ✱✲✭✺✿ ✸❃✲✫ ✪✧ ✱✲✳✬❊ ❃✲✫ ✪✧ ✩✯✯ ✱✲✳✬ ★✧✹✴✿ ✱✲✳✬ ✳✬ ✫✭✩✹✬ ✩✵✪ ✫✭✩✹✬ ✧✶ ★✧✹✴✿ ★✲✫ ✪✧ ✱✲✳✬ ❁✮✬✱ ✱✧
✭✹✩✬✭ ✫✧✮✹✬✭✯✽✭✬ ✶✹✧✺ ✬✧✷✳✭✱✫❊✻
❋✲✭ ✾✭✧✾✯✭ ✳✵ ✱✲✭ ✪✩✹✴ ✬✲✳✶✱✭✪ ✩ ✰✳✱✿
# Given an input of a base64 encoded numuber and you want to compare it to the
# then hex version of the number
base64val = "H6Xnkk0Y+SXZEGoKf6Yk9gGeBOw="
hexval = "1fa5e7924d18f925d9106a0a7fa624f6019e04ec"
converted = base64val.unpack("m*").first # unpack into a binary blob
.unpack("C*") # upack each byte into an int
.map { |x| "%02x" % x } # hex notation with leading 0
.join # join back to a single string
@copiousfreetime
copiousfreetime / manage-ruby.sh
Created March 20, 2013 15:53
managing ruby version and gem sets
ruby_version()
{
local rv=
if test -n "${RUBY_ROOT}"
then
rv=$(basename ${RUBY_ROOT})
else
rv="system"
fi
@copiousfreetime
copiousfreetime / bdrg-2013-01_rails-vuln.md
Created January 16, 2013 17:59
Links used for 2013-01-15 Boulder Ruby User Group talk about the recent Rails vulnerabilities.
@copiousfreetime
copiousfreetime / build-ext-java.txt
Created January 10, 2013 02:14
Deprecations warnings from building hitimes in jruby.
javac -classpath /Users/jeremy/.rvm/rubies/jruby-1.7.2/lib/jruby.jar -Xlint:deprecation -d pkg/classes ext/java/src/hitimes/Hitimes.java ext/java/src/hitimes/HitimesInterval.java ext/java/src/hitimes/HitimesService.java ext/java/src/hitimes/HitimesStats.java
ext/java/src/hitimes/Hitimes.java:45: warning: [deprecation] fastGetModule(java.lang.String) in org.jruby.Ruby has been deprecated
RubyClass errorClass = runtime.fastGetModule("Hitimes").fastGetClass( "Error" );
^
ext/java/src/hitimes/Hitimes.java:45: warning: [deprecation] fastGetClass(java.lang.String) in org.jruby.RubyModule has been deprecated
RubyClass errorClass = runtime.fastGetModule("Hitimes").fastGetClass( "Error" );
^
jeremy@feather:~/repos/git/maglev ruby-1.9.3-p327 master % ./install.sh
[Info] Configuring feather.local to run MagLev
Password:
Tue Nov 27 23:34:46 CET 2012
[Info] Setting up shared memory
Total memory available is 4096 MB
Max shared memory segment size is 2048 MB
Max shared memory allowed is 2048 MB
[Info] No need to increase max shared memory segment size
[Info] No need to increase max shared memory allowed
@copiousfreetime
copiousfreetime / iostat-report.rb
Created August 22, 2012 04:03
Parse the output of 'iostats -x' and feed it to this program for some output
#!/usr/bin/env ruby
#
# Calculate I/O stats from the output of 'iostat -x'
#
# This is to take the output from 'iostat -x' and receive it on stdin.
#
# % iostat -x | ./report.rb
#
fields = {
'rrqm/s' => 1,
module MyApp
class Config
include ::Yacl::Configurable::Application
class Defaults
extend ::Yacl::Define::Defaults
default 'archive.uri' , 'http://archive.collectiveintellect.com'
default 'messaging.uri' , 'kestrel://messaging1.collectiveintellect.com:2229/'
default 'messaging.queue', 'frankensnip'
default 'system' , 'pipeline_main'
@copiousfreetime
copiousfreetime / wtf.rb
Created May 4, 2012 22:31
gem dependency collision
#!/usr/bin/env ruby
#
require 'rubygems'
require 'rubygems/dependency'
a = Gem::Dependency.new( "main", "~> 4.6.0")
b = Gem::Dependency.new( "mail", "~> 2.2.19" )
print "#{RUBY_DESCRIPTION} : "
if a.hash == b.hash then
@copiousfreetime
copiousfreetime / hashlike_bench.rb
Created April 7, 2012 21:19
hash like comparison benchmark
#!/usr/bin/env ruby
require 'rubygems'
require "benchmark"
require 'map'
require 'digest/md5'
require 'hashr'
require 'hashie'
def keys( count, start = 'aaaaaa' )