Skip to content

Instantly share code, notes, and snippets.

@arturaz
arturaz / gist:1214962
Created September 13, 2011 20:04
Scala side
object Finder {
def find(
source: Locatable,
sourceJumpgates: Set[SolarSystemPoint],
sourceSs: Option[SolarSystem],
sourceSsGalaxyCoords: Option[Coords],
target: Locatable,
targetJumpgates: Set[SolarSystemPoint],
targetSs: Option[SolarSystem],
targetSsGalaxyCoords: Option[Coords],
@arturaz
arturaz / gist:1214959
Created September 13, 2011 20:03
Ruby side
lambda do
jar_path = File.join(ROOT_DIR, 'vendor', 'SpaceMule', 'dist', 'SpaceMule.jar')
# Win32 requires us to manually require all the jars before requiring
# main jar.
Dir[File.dirname(jar_path) + "/lib/*.jar"].each { |jar| require jar }
require jar_path
# Scala <-> Ruby interoperability.
class Object
>> SpaceMule.instance.find_path(GalaxyPoint.new(1, -3, 8), GalaxyPoint.new(1, 25, -2))
[2011-09-13 22:40:40|main|info ] [Initializing SpaceMule]
[main|info ] Sending configuration
[END of Initializin...] 2.255 seconds
Java::JavaLang::NullPointerException:
from org.jruby.util.CodegenUtils.human(CodegenUtils.java:98)
from org.jruby.util.CodegenUtils.prettyParams(CodegenUtils.java:152)
from org.jruby.java.dispatch.CallableSelector.argumentError(CallableSelector.java:462)
lazy val dist = TaskKey[Unit](
"dist", "Creates a project distribution in dist/ folder."
)
def distTask =
dist <<=
dist.dependsOn(compile, packageBin) <<=
(update, crossTarget).map { case (updateReport, out) =>
updateReport.allFiles.foreach { srcPath =>
val destPath = out / "lib" / srcPath.getName
IO.copyFile(srcPath, destPath, preserveLastModified=true)
@arturaz
arturaz / gist:1206394
Created September 9, 2011 14:36
ruby-debug-ide hung (deadlocked?) on JVM6
arturas 28876 12.8 6.3 695276 129628 ? Sl 17:31 0:35 /usr/lib/jvm/java-6-sun//bin/java -client -Djruby.memory.max=500m -Djruby.stack.max=2048k -Xmx500m -Xss2048k -Djffi.boot.library.path=/home/arturas/.rvm/rubies/jruby-1.6.4/lib/native/i386-Linux:/home/arturas/.rvm/rubies/jruby-1.6.4/lib/native/ppc-Linux:/home/arturas/.rvm/rubies/jruby-1.6.4/lib/native/x86_64-Linux -Djruby.reflection=true -Djruby.compile.mode=OFF -Djruby.debug.fullTrace=true -Xbootclasspath/a:/home/arturas/.rvm/rubies/jruby-1.6.4/lib/jruby.jar -classpath :../lib/bootstrap.jar:../lib/util.jar:../lib/jdom.jar:../lib/log4j.jar:../lib/extensions.jar:../lib/trove4j.jar: -Djruby.home=/home/arturas/.rvm/rubies/jruby-1.6.4 -Djruby.lib=/home/arturas/.rvm/rubies/jruby-1.6.4/lib -Djruby.script=jruby -Djruby.shell=/bin/sh org.jruby.Main -X+O -X+O -e at_exit{sleep(1)};$stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/arturas/.rvm/gems/jruby-1.6.4@nebulaserver/gems/ruby-debug-ide-0.4.17.beta8/bin/rdebug-ide --port 59484 -- /home/art
@arturaz
arturaz / gist:1206247
Created September 9, 2011 13:48
ruby-debug-ide hung (deadlocked?) on JVM7
2011-09-09 16:47:25
Full thread dump Java HotSpot(TM) Client VM (21.0-b17 mixed mode):
"Attach Listener" daemon prio=10 tid=0x08d4e800 nid=0x2b87 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE
"RubyThread-1: /home/arturas/.rvm/gems/jruby-1.6.4@nebulaserver/gems/ruby-debug-ide-0.4.17.beta8/lib/ruby-debug-ide.rb:144" daemon prio=10 tid=0x088ef400 nid=0x2659 waiting for monitor entry [0x902fc000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.jruby.debug.DebugEventHook.eventHandler(DebugEventHook.java:91)
- waiting to lock <0x9c9c1e78> (a org.jruby.debug.DebugEventHook)
@arturaz
arturaz / gist:1201690
Created September 7, 2011 20:51
Skype guardian - kill memhungry skype processes
#!/bin/bash
while true; do
mem_used=$(ps aux | grep -P "\bskype\b" | grep -v grep | awk {'print $5'})
mem_limit=$((1024 * 512)) # 512mb
if (("$mem_used" >= "$mem_limit")); then
killall -9 skype
notify-send -i error "Skype was killed because it reached $mem_limit KB limit"
fi
@arturaz
arturaz / gist:1139069
Created August 11, 2011 07:14
Running Nebula 44 server controller tests with jruby-head
arturas@arturaz-fujitsu:~/work/spacegame/server$ rvm use jruby-head
Using /home/arturas/.rvm/gems/jruby-head
arturas@arturaz-fujitsu:~/work/spacegame/server$ time jruby -S rake spec:controllers
NameError: uninitialized constant ActiveRecord::Base::BelongsToPolymorphicAssociation
load_missing_constant at /home/arturas/.rvm/gems/jruby-head/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:506
const_missing at /home/arturas/.rvm/gems/jruby-head/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:183
each at org/jruby/RubyArray.java:1603
const_missing at /home/arturas/.rvm/gems/jruby-head/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:181
const_get at org/jruby/RubyModule.java:2486
local_constants at /home/arturas/.rvm/gems/jruby-head/gems/activesupport-3.0.9/lib/active_support/core_ext/module/introspection.rb:70
@arturaz
arturaz / gist:1138440
Created August 10, 2011 22:21
Running Nebula 44 server controller tests with jruby-head branch jruby-1_6
arturas@arturaz-fujitsu:~/work/spacegame/server$ jruby -v
jruby 1.6.3 (ruby-1.8.7-p330) (2011-08-11 fa0cea0) (Java HotSpot(TM) Client VM 1.7.0) [linux-i386-java]
arturas@arturaz-fujitsu:~/work/spacegame/server$ time jruby -S rake spec:controllers
................................................................................................................................................................................................................................................................................................FFFF...............FF.F.............................................................................................................................................................
1)
Java::JavaLang::ArrayIndexOutOfBoundsException in 'UnitsController units|attack invoked should not create cooldown'
-1
org.jruby.javasupport.JavaClass.handleScalaSingletons(JavaClass.java:142)
@arturaz
arturaz / gist:1138255
Created August 10, 2011 21:01
Strange YAML output in jruby 1.9 mode
arturas@arturaz-fujitsu:~/work/spacegame/server$ jruby -S rake spec:controllers
....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Finished in 75.246 seconds
468 examples, 0 failures
arturas@arturaz-fujitsu:~/work/spacegame/server$ time jruby --1.9 -S rake spec:controllers
%YAML 1.1
--- ! "0"