Skip to content

Instantly share code, notes, and snippets.

View nicksieger's full-sized avatar

Nick Sieger nicksieger

View GitHub Profile
@nicksieger
nicksieger / gist:10133066
Created April 8, 2014 14:28
Poems are rough notations for the music we are.
Did you hear that winter is over?
The basil and carnation cannot control their laughter.
The nightingale, back from his wandering,
has been made singing master over all the birds.
The trees reach out their congratulations.
The soul goes dancing through the king’s doorway.
Anemones blush because they have seen the rose naked.
$ cat fucksgiven.c
#include <stdio.h>
#include <stdlib.h>
typedef struct aFuck {} Fuck;
int main (int argc, char** argv)
{
Fuck * given = (Fuck*) malloc(argc * sizeof(Fuck));
printf("You gave %lu fucks\n", sizeof(*given));
1) Failure:
test_any_should_not_load_results(NamedScopeTest)
[./test/cases/../../lib/active_record/test_case.rb:40:in `assert_queries'
./test/cases/named_scope_test.rb:189:in `test_any_should_not_load_results'
./test/cases/../../lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:94:in `__send__'
./test/cases/../../lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:94:in `run']:
0 instead of 1 queries were executed.
<1> expected but was
<0>.
# Warbler web application assembly configuration file
Warbler::Config.new do |config|
# Temporary directory where the application is staged
# config.staging_dir = "tmp/war"
# Application directories to be included in the webapp.
config.dirs = %w(app config lib log vendor tmp)
# Additional files/directories to include, above those in config.dirs
# config.includes = FileList["db"]
<plugin>
<groupId>org.jruby.plugins</groupId>
<artifactId>jruby-rake-plugin</artifactId>
<executions>
<execution>
<id>runtests</id>
<phase>test</phase>
<goals><goal>rake</goal></goals>
<configuration>
<script>
require 'java'
class SafeSequence
def initialize
@mutex = java.lang.Object.new
@count = -1
end
def next
@mutex.synchronized { @count += 1}
end
jruby --debug ./script/performance/profiler "Project.alphabetical.publicly_visible" 5000 2> jruby-projects-prof.txt
./script/performance/profiler "Project.alphabetical.publicly_visible" 5000 2> ruby-projects-prof.txt
java.lang.NullPointerException
at org.jruby.parser.Parser.parse(Parser.java:128)
at org.jruby.Ruby.parseEval(Ruby.java:1849)
at org.jruby.Ruby.evalScriptlet(Ruby.java:223)
at org.jruby.javasupport.JavaEmbedUtils$2.eval(JavaEmbedUtils.java:157)
at org.jruby.rack.jms.DefaultQueueManager$RubyObjectMessageListener.onMessage(DefaultQueueManager.java:112)
at com.sun.messaging.jms.ra.DirectSession._deliverMessage(DirectSession.java:1889)
at com.sun.messaging.jms.ra.DirectConsumer.deliver(DirectConsumer.java:368)
at com.sun.messaging.jmq.jmsserver.service.imq.SessionListener.process(IMQDirectService.java:2917)
at com.sun.messaging.jmq.jmsserver.service.imq.SessionListener.run(IMQDirectService.java:2855)
it "should allow assignable equivalents to be passed to a method" do
impl = DescendantOfSingleMethodInterface.impl {|name| name}
impl.should be_kind_of(SingleMethodInterface)
DescendantOfSingleMethodInterface.should === impl
UsesSingleMethodInterface.callIt(impl).should == :callIt
end
diff --git a/src/org/jruby/javasupport/JavaUtil.java b/src/org/jruby/javasupport/JavaUtil.java
index e8de4c4..eb0842e 100644
--- a/src/org/jruby/javasupport/JavaUtil.java
+++ b/src/org/jruby/javasupport/JavaUtil.java
@@ -868,6 +868,8 @@ public class JavaUtil {
public static Object convertArgumentToType(ThreadContext context, IRubyObject arg, Class target) {
if (arg instanceof JavaObject) {
return coerceJavaObjectToType(context, ((JavaObject)arg).getValue(), target);
+ } else if (arg.respondsTo("java_object")) {
+ return convertArgumentToType(context, arg.callMethod(context, "java_object"), target);