Skip to content

Instantly share code, notes, and snippets.

<arturaz> >> Java::SpacemuleModulesConfigObjects::FormulaCalc.rubyCalc(3)
<arturaz> NameError: no method 'rubyCalc' for arguments (org.jruby.RubyFixnum) on Java::SpacemuleModulesConfigObjects::FormulaCalc
<arturaz> available overloads:
<arturaz> (org.jruby.RubyFixnum)
<arturaz> NameError: no method 'calc' for arguments (org.jruby.RubyString,org.jruby.RubyHash) on Java::SpacemuleModulesConfigObjects::FormulaCalc
<arturaz> available overloads: (org.jruby.RubyString,org.jruby.RubyHash)
<arturaz> WAT?
?> Pmg.Runner.ensurePool(
?> galaxy.id.to_java(:int), galaxy.ruleset,
?> galaxy.pool_free_zones.to_java(:int),
?> max_zone_iterations.to_java(:int),
?> galaxy.pool_free_home_ss.to_java(:int),
?> max_home_ss_iterations.to_java(:int)
>> )
TypeError: cannot convert instance of class org.jruby.java.proxies.ConcreteJavaProxy to int
from (irb):37:in `evaluate'
from org/jruby/RubyKernel.java:1091:in `eval'
def iterator = {
val rubyIter = raw.directEntrySet().iterator()
new Iterator[(IRubyObject, IRubyObject)] {
def hasNext = rubyIter.hasNext
def next() = {
val key = rubyIter.next.asInstanceOf[IRubyObject]
val value = raw.fastARef(key)
(key, value)
}
@arturaz
arturaz / connection_pool.rb
Created April 22, 2012 17:50
JRuby 1.6.7-HEAD ConcurrencyError in safe code
# Check-in a database connection back into the pool, indicating that you
# no longer need this connection.
#
# +conn+: an AbstractAdapter object, which was obtained by earlier by
# calling +checkout+ on this pool.
def checkin(conn)
synchronize do
conn.run_callbacks :checkin do
conn.expire
@queue.signal
class RaidSpawner
# It's a regular planet.
KEY_PLANET = 'planet'
# It's a battleground planet.
KEY_BATTLEGROUND = 'battleground'
# Apocalypse is raging in the galaxy.
KEY_APOCALYPSE = 'apocalypse'
def initialize(planet)
@planet = planet
def checkin(conn)
synchronize do
conn.run_callbacks :checkin do
conn.expire
@queue.signal
end
release conn
end
end
Author: Arturas Slajus <[email protected]> 2012-04-18 23:08:34
Committer: Arturas Slajus <[email protected]> 2012-04-18 23:08:34
Parent: f0cc63550a0bb0ca4f60a8a8fc1682d196d57087 (Merge remote-tracking branch 'origin/stable2' into stable2)
Branches: remotes/origin/stable2, stable2
Follows: many_scopes
Precedes:
Use EM instead of celluloid-io for now.
----------------------------------- Gemfile -----------------------------------
spacegame@gnat:~/web/current/www$ bundle show authlogic
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
/home/spacegame/web/shared/bundle/ruby/1.9.1/bundler/gems/authlogic-a087ad0cba3c
private void nearest(
final int index, final float x, final float y, final int depth,
final Result result
) {
if (index == -1) return;
final Node node = nodes[index];
// final Node node = (Node) unsafe.getObject(
// nodes, Unsafe.ARRAY_OBJECT_BASE_OFFSET +
// Unsafe.ARRAY_OBJECT_INDEX_SCALE * index
// );
require 'java'
require 'libssrckdtree-j-1.0.2.jar'
GenericPoint = Java::com.savarese.spatial.GenericPoint
KDTree = Java::com.savarese.spatial.KDTree
def generate_points(tree, size)
size.times do
x = rand(100)
y = rand(100)