Skip to content

Instantly share code, notes, and snippets.

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 00:52
Thrift-0.6.0 Inconsistent Errors in fauna/cassandra tests
➜ 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 01:02
DEBUG Log Output During Tests
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 August 31, 2011 23:20
Simple CQL to Thrift Comparison in ruby
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 September 9, 2011 01:46
Method Missing Test Class
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 October 3, 2011 18:22
Mark Sense Form Parser
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 November 15, 2011 03:33
Convert JDBC ResultSet into Ruby Hash with JRuby
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 December 18, 2011 05:45
Parse and print output from a HIPAA 277CA file.
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 January 19, 2012 17:06
Reload all ruby files in the given directory (defaults to Dir.pwd) that have been loaded.
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 February 20, 2012 18:38 — forked from rondale-sc/pconsole.sh
pconsole bash/zsh alias
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
}