Skip to content

Instantly share code, notes, and snippets.

View 0001-Add-Time.strptime-RubySpec.patch
From 184e3de1046884dcf6467d19cf73a7eb65f811f5 Mon Sep 17 00:00:00 2001
From: Robert Jackson <robertj@promedicalinc.com>
Date: Thu, 19 May 2011 18:02:00 -0400
Subject: [PATCH 1/2] Add RubySpec for Time#strptime.
---
spec/ruby/library/time/strptime_spec.rb | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
create mode 100644 spec/ruby/library/time/strptime_spec.rb
@rwjblue
rwjblue / gist:987949
Created May 24, 2011
Thrift-0.6.0 Inconsistent Errors in fauna/cassandra tests
View gist:987949
➜ cassandra git:(master) ✗ ruby test/cassandra_test.rb -n test_remove_super_sub_key
Loaded suite test/cassandra_test
Started
.
Finished in 0.212645 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
➜ cassandra git:(master) ✗ ruby test/cassandra_test.rb -n test_remove_super_sub_key
Loaded suite test/cassandra_test
Started
@rwjblue
rwjblue / Errored Test Cassandra DEBUG Log
Created May 24, 2011
DEBUG Log Output During Tests
View Errored Test Cassandra DEBUG Log
DEBUG 21:01:27,166 computing ranges for 118913266174357844299523244095729587344
DEBUG 21:01:27,168 logged out: #<User allow_all groups=[]>
DEBUG 21:01:27,226 truncating Users in Twitter
DEBUG 21:01:27,227 Starting a blocking truncate operation on keyspace Twitter, CF
DEBUG 21:01:27,227 Starting to send truncate messages to hosts [localhost/127.0.0.1]
DEBUG 21:01:27,227 Sent all truncate messages, now waiting for 1 responses
DEBUG 21:01:27,227 Applying Truncation(keyspace='Twitter', cf='Users')
DEBUG 21:01:27,227 Truncating...
DEBUG 21:01:27,227 forceFlush requested but everything is clean
DEBUG 21:01:27,228 forceFlush requested but everything is clean
@rwjblue
rwjblue / Gemfile
Created Aug 31, 2011
Simple CQL to Thrift Comparison in ruby
View Gemfile
source :rubygems
gem 'rake'
gem 'forgery'
gem 'cassandra-cql', :path => '../cassandra-cql'
gem 'cassandra', :path => '../cassandra'
gem 'perftools.rb'
gem 'rbtrace'
@rwjblue
rwjblue / gist:1205294
Created Sep 9, 2011
Method Missing Test Class
View gist:1205294
class MethodMissingTest
def method_missing(method_name, *args, &block)
puts 'Method Called: ' + method_name.to_s
puts 'Arguments: ' + args.to_s
puts 'Block Given: ' + block_given?.to_s
end
end
@rwjblue
rwjblue / mark_sense_form.rb
Created Oct 3, 2011
Mark Sense Form Parser
View mark_sense_form.rb
begin
require 'oily_png'
rescue LoadError
require 'chunky_png'
end
require 'bigdecimal'
class ChunkyPNG::Image
def neighbors(x,y)
[[x, y-1], [x+1, y], [x, y+1], [x-1, y]].select do |xy|
@rwjblue
rwjblue / jdbc_sample.rb
Created Nov 15, 2011
Convert JDBC ResultSet into Ruby Hash with JRuby
View jdbc_sample.rb
require 'java'
require 'jt400'
require 'date'
require 'bigdecimal'
java_import 'com.ibm.as400.access.AS400JDBCDriver'
def get_records
@connection ||= java.sql.DriverManager.get_connection("jdbc:as400://127.0.0.1/",'username','password')
rs = @connection.createStatement.executeQuery("SELECT * FROM RANDOM_TABLE")
@rwjblue
rwjblue / parse_277.rb
Created Dec 18, 2011
Parse and print output from a HIPAA 277CA file.
View parse_277.rb
require 'pp'
require 'pry'
require 'hippo'
def wrap_text(text, max_width, wrap_string = "\n")
if text.length <= max_width
text
else
text.scan(/.{1,#{max_width}}/).join(wrap_string)
end
@rwjblue
rwjblue / pry_reload.rb
Created Jan 19, 2012
Reload all ruby files in the given directory (defaults to Dir.pwd) that have been loaded.
View pry_reload.rb
Pry.config.commands.command "reload", "Reload all ruby files in the given directory (defaults to Dir.pwd) that have been loaded." do |*args|
args = [Dir.pwd] if args.empty?
$LOADED_FEATURES.each do |feature|
if args.any?{|dir| feature =~ /#{dir}/} && feature.end_with?('.rb')
load feature
output.puts "Reloaded: #{feature}."
end
end
end
@rwjblue
rwjblue / pconsole.sh
Created Feb 20, 2012 — forked from rondale-sc/pconsole.sh
pconsole bash/zsh alias
View pconsole.sh
pconsole () {
if [[ -e ./config/environment.rb ]];
then
rails_env="development"
if [[ "$1z" != "z" ]]; then rails_env=$1; fi;
RAILS_ENV=$rails_env pry -r ./config/environment.rb -r rails/console/app -r rails/console/helpers;
else pry;
fi
}
You can’t perform that action at this time.