Skip to content

Instantly share code, notes, and snippets.

View jrun's full-sized avatar

Jeremy Burks jrun

View GitHub Profile
def f(i=1);return if i>100;s=(i%3==0?'Fizz':'')+(i%5==0?'Buzz' : '');puts(s.empty? ? i:s);f(i+1);end;f
@jrun
jrun / get_jdbc_connection.rb
Created February 4, 2009 15:41
Helpful when debugging from script/console or irb. This allows you to poke into JDBC stuff.
# "u" is an ActiveRecord::Base subclass
u.class.connection.instance_variable_get("@connection").instance_variable_get("@connection")
diff --git a/lib/active_record/connection_adapters/jdbc_adapter.rb b/lib/active_record/connection_adapters/jdbc_adapter.rb
index b40a59e..e5cbd63 100644
--- a/lib/active_record/connection_adapters/jdbc_adapter.rb
+++ b/lib/active_record/connection_adapters/jdbc_adapter.rb
@@ -374,15 +374,15 @@ module ActiveRecord
while resultset.next
index_name = resultset.get_string(Jdbc::IndexMetaData::INDEX_NAME)
next unless index_name
- index_name.downcase!
- column_name = resultset.get_string(Jdbc::IndexMetaData::COLUMN_NAME).downcase
--- a/src/java/jdbc_adapter/RubyJdbcConnection.java
+++ b/src/java/jdbc_adapter/RubyJdbcConnection.java
@@ -804,7 +804,7 @@ public class RubyJdbcConnection extends RubyObject {
rs = metadata.getTables(catalog, realschema, realtablepat, types);
List arr = new ArrayList();
while (rs.next()) {
- String name = rs.getString(3).toLowerCase();
+ String name = caseConvertIdentifierForJdbc(metadata, rs.getString(3));
// Handle stupid Oracle 10g RecycleBin feature
if (!isOracle || !name.startsWith("bin$")) {
#! /bin/sh
#
# /etc/init.d/mountec2vol
#
# chkconfig: 234 20 50
# description: Assigns an EC2 EBS Volume to a device and mounts the device
#
# To add this as a service run:
# /sbin/chkconfig --add mountec2vol
#
java -cp ~/usr/local/btrace/build/btrace-client.jar:/usr/jdk/lib/tools.jar:jruby-complete-1.2.0.jar com.sun.btrace.compiler.Compiler spec/RubyClassHistogram.java
@jrun
jrun / spec_config.rb
Created April 2, 2010 18:26
An example spec_config.rb that can be used to run sequel's integration tests with JNDI
# This is an example spec_config.rb that can be used to run sequel's
# integration tests.
# jars used to run the integration tests for sqlite and mysql
#
# commons-dbcp-1.2.2.jar
# commons-pool-1.4.jar
# fscontext.jar
# mysql-connector-java-5.0.5.jar
# providerutil.jar
@jrun
jrun / dumbfr.rb
Created July 1, 2010 01:09
This sucks. What is the better way?
#!/usr/bin/env ruby
find = ARGV[0]
replace = ARGV[1]
`ack '#{find}' -l`.split.each do |f|
`sed -i 's/#{find}/#{replace}/g' #{f}`
end
@jrun
jrun / .pryrc
Created May 1, 2011 02:22
Modify Pry's wait prompt to look better when using ruby-send-* in emacs
Pry.prompt[1] = proc {""}
@jrun
jrun / install-openvpn.sh
Created July 22, 2011 16:47
openvpn Homebrew Formula for OSX Lion
brew install https://raw.github.com/gist/1099830/02960cf13a1486f4c73972b707cd979ea0dfbbec/openvpn.rb --force