Skip to content

Instantly share code, notes, and snippets.

Charles Lowell cowboyd

Block or report user

Report or block cowboyd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View weakrefapi.mri.irb
ruby-1.8.7-p174 > WeakRef.public_instance_methods(false)
=> ["__setobj__", "__getobj__", "weakref_alive?"]
ruby-1.8.7-p174 >
View jquery_test.oputput.txt
Loaded suite /Users/cowboyd/Projects/rdom/test/rdom/jquery_test
Started
F
Finished in 0.14056 seconds.
1) Failure:
test_can_load_jquery:15
Exception raised:
Class: <V8::JSError>
Message: <"Cannot read property 'addEventListener' of undefined">
View gist:518003
legolas:cucumber cowboyd$ RUBYLIB=/Users/cowboyd/Projects/therubyrhino/lib jruby -S bin/cucumber -v -i examples/v8/features
Using the default profile...
Code:
* examples/v8/features/support/env.js
Features:
* examples/v8/features/fibonacci.feature
Parsing feature files took 0m0.084s
Code:
View object_template_as_function.rb
require 'v8'
include V8::C
print = FunctionTemplate::New() do |arguments|
for i in 0..arguments.Length() - 1
print case arg = arguments[i]
when TrueClass,FalseClass, nil
arg
else
@cowboyd
cowboyd / RubyExtensionFinder.java
Created Oct 29, 2010
Why can't JRuby find it's
View RubyExtensionFinder.java
@Extension
public class RubyExtensionFinder extends ExtensionFinder {
public RubyExtensionFinder() {
ScriptingContainer jruby = new ScriptingContainer();
/**
* When run in the maven test suite, this line executes just fine
* but when instantiated by the Hudson server at runtime, gets the
* following error: no such file to load -- builtin/core_ext/symbol
*
@cowboyd
cowboyd / MyExtensionFinder.java
Created Oct 30, 2010
Why does Hudson only ask for certain extension points?
View MyExtensionFinder.java
@Extension
public class MyExtensionFinder extends ExtensionFinder {
public <T> Collection<ExtensionComponent<T>> find(Class<T> tClass, Hudson hudson) {
System.out.printf("find(%s)\n", tClass.getName());
return new ArrayList<ExtensionComponent<T>>();
}
}
/**
View hello_world_builder.mirah
import hudson.Launcher;
import hudson.Extension;
import hudson.util.FormValidation;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.AbstractProject;
import hudson.tasks.Builder;
import hudson.tasks.BuildStepDescriptor;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
@cowboyd
cowboyd / list.rb
Created Nov 30, 2010
convert native java arraylist to ruby array.
View list.rb
require 'java'
list = java.util.ArrayList.new
list.add(1)
list.add(2)
puts list.inspect #=> <Java::JavaUtil::ArrayList:0x7dc21ece>
puts list.to_a.inspect #=> [1, 2]
@cowboyd
cowboyd / Fooby.java
Created Dec 3, 2010
try to get a top-level constant
View Fooby.java
package foo;
import org.jruby.embed.ScriptingContainer;
import org.jruby.embed.LocalContextScope;
import org.jruby.embed.LocalVariableBehavior;
import org.jruby.embed.internal.LocalContext;
public class Fooby {
public static void main(String[] args) {
View gist:735277
A 5 vol% ethanol solution needs to be converted to wt% for the table in the
CRC Handbook of Chemistry and Physics, 62nd Ed, pg D-207.
The density of pure alcohol is 0.791 times that of water at 20 C.
Basis 100 ml solution:
alcohol = 5x0.791 = 3.955 grams
water = 95x1.00 = 95.000
Total = 98.955 g
Wt% alcohol = 3.955/98.955 = 0.0400 -> 4.00 wt% alcohol.
You can’t perform that action at this time.