Skip to content

Instantly share code, notes, and snippets.

View bsbodden's full-sized avatar

Brian Sam-Bodden bsbodden

View GitHub Profile
config.after_initialize do
Dir["#{RAILS_ROOT}/app/models/**/*.rb"].each { |f| require(f) }
end
class Class
def extends?(klass)
not superclass.nil? and ( superclass == klass or superclass.extends? klass )
end
def descendants(&block)
Module.constants.select do |constant_name|
constant = eval constant_name
if not constant.nil? and constant.is_a? Class and constant.extends? self
block_given? ? (constant if block.call(constant)) : constant
raw = 'PARAM1 = #{param_1}, PARAM2 = #{param_2}'
params = { :param_1 => "foo", :param_2 => "bar" }
query = proc do |*args|
@params = params
def method_missing(key)
@params[key.to_sym]
end
eval('"' + raw + '"')
end
#!/usr/bin/env ruby
# made by the folks at Integrallis (http://www.integrallis.com), enjoy!
require 'cgi'
require 'ostruct'
target = $TM_FILEPATH
f = IO.popen(%[java org.mozilla.javascript.tools.shell.Main -f $1 "$TM_FILEPATH" 2>&1])
lines = f.readlines()
f.close_read
@bsbodden
bsbodden / Simple.java
Created August 1, 2011 20:15
Simple Java POJO
public class Simple {
private String foo;
private String bar;
private String baz;
public String getBar() {
return bar;
}
public String getFoo() {
@bsbodden
bsbodden / gist:1118895
Created August 1, 2011 20:18
Ruby Module pulling in JAR
require 'java'
require 'java/core/simple.jar'
module MyModule
include_package 'my.package'
end
@bsbodden
bsbodden / .ircrb
Created February 9, 2013 21:28
My .irbrc file
require 'rbconfig'
Config = RbConfig
if defined?(Rails)
Dir.glob("#{Rails.root}/app/models/**/*.rb").each { |file| require file }
end
def clear
system 'clear'
nil
@bsbodden
bsbodden / homebrew_install
Created November 23, 2014 20:13
Homebrew Installation
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@bsbodden
bsbodden / homebrew_cassandra_install
Created November 23, 2014 20:23
Homebrew Cassandra Install
brew install cassandra
brew install python
easy_install cql
@bsbodden
bsbodden / linux_cassandra_download
Created November 24, 2014 16:35
Linux Cassandra Download
cd ~/temp
wget http://www.us.apache.org/dist/cassandra/2.1.2/apache-cassandra-2.1.2-bin.tar.gz
tar -xvzf apache-cassandra-2.1.2-bin.tar.gz
mv apache-cassandra-2.1.2 ~/cassandra