Skip to content

Instantly share code, notes, and snippets.

View bluescreen303's full-sized avatar

Mathijs Kwik bluescreen303

  • Uithoorn, Netherlands
View GitHub Profile
ruby_thing.rb:
require 'jruby/core_ext'
puts "hello from ruby"
class RubyThing
include org.test.RubyInit::RubyThingInterface
def setJt(java_thing)
puts "setJt"
module Imports
import com.dutchcoastsoftware.tsunami.server.ClientFrontend
import com.dutchcoastsoftware.tsunami.server.ClientFrontendImpl
import org.waveprotocol.wave.examples.fedone.waveserver.WaveletListener
import org.waveprotocol.wave.examples.fedone.waveserver.WaveletProvider
import org.waveprotocol.wave.model.id.WaveId
import org.waveprotocol.wave.model.id.WaveletName
import org.waveprotocol.wave.model.wave.ParticipantId
Common = org.waveprotocol.wave.protocol.common
end
import System.TimeIt
import System.Random
import Control.Parallel.Strategies (NFData(..))
import Control.Exception (evaluate)
-- rpartition :: (a -> Bool) -> [a] -> ([a], [a])
-- rpartition p = go [] []
-- where
-- go ts fs [] = (ts, fs)
-- go ts fs (x:xs) | p x = go (x:ts) fs xs
import System.TimeIt
import System.Random
import Control.Parallel.Strategies (NFData(..))
import Control.Exception (evaluate)
rpartition :: (a -> Bool) -> [a] -> ([a], [a])
rpartition p = go [] []
where
go ts fs [] = (ts, fs)
go ts fs (x:xs) | p x = go (x:ts) fs xs
diff --git a/build.xml b/build.xml
index 8979d97..87ac1d6 100644
--- a/build.xml
+++ b/build.xml
@@ -211,17 +211,26 @@
<jar destfile="${jar.outfile-server}">
<fileset dir="${staging}">
<include name="META-INF/services/*" />
+ <include name="builtin/**/*" />
+ <include name="com/dutchcoastsoftware/tsunami/**/*" />
starting server
opts: StartupConfig {connectionMode = TCPIP False 4005, autoPort = False, showHelp = False}
=== Listening on port: 4005
==> {"id":1,"method":"connection-info","params":{}}
<== {"version":"0.1","id":1,"result":{"version":1,"pid":0}}
==> {"id":2,"method":"list-cabal-components","params":{"cabal-file":"/home/mathijs/workspace/json/json.cabal"}}
<== {"version":"0.1","id":2,"result":[{"library":null,"cabal-file":"/home/mathijs/workspace/json/json.cabal"}]}
==> {"id":3,"method":"load","params":{"component":{"library":null,"cabal-file":"/home/mathijs/workspace/json/json.cabal"},"output":false}}
Configuring json-0.1...
Creating .dist-scion (and its parents)
org.eclipse.core.internal.resources.ResourceException: The resource tree is locked for modifications.
at org.eclipse.core.internal.resources.WorkManager.checkIn(WorkManager.java:115)
at org.eclipse.core.internal.resources.Workspace.prepareOperation(Workspace.java:1747)
at org.eclipse.core.internal.resources.Resource.deleteMarkers(Resource.java:762)
at net.sf.eclipsefp.haskell.scion.client.ScionInstance.deleteProblems(ScionInstance.java:283)
at net.sf.eclipsefp.haskell.scion.client.ScionInstance.buildProject(ScionInstance.java:141)
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jruby.javasupport.proxy.JavaProxyClassFactory.invokeDefineClass(JavaProxyClassFactory.java:256)
at org.jruby.javasupport.proxy.JavaProxyClassFactory.generate(JavaProxyClassFactory.java:221)
at org.jruby.javasupport.proxy.JavaProxyClassFactory.newProxyClass(JavaProxyClassFactory.java:174)
at org.jruby.javasupport.proxy.JavaProxyClass.getProxyClass(JavaProxyClass.java:122)
at org.jruby.javasupport.proxy.JavaProxyClass.get_with_class(JavaProxyClass.java:693)
at org.jruby.javasupport.Java$5.call(Java.java:580)
I have a java method that requires one or more classes:
public class FlagBinder {
public static Module parseFlags(String[] args, Class<?>... flagSettings) throws ParseException {
I tried different kinds of combinations of .java_class, .to_java but couldn't get it working.
Java code that uses this class does this:
Module flags = FlagBinder.parseFlags(args, FlagSettings.class);
Now in ruby I tried:
// map function
function(op) {
if(op.channel) {
emit(op.channel, op);
}
}
// reduce
function(keys, ops, rereduce) {