Skip to content

Instantly share code, notes, and snippets.

View iconara's full-sized avatar
🤖

Theo iconara

🤖
View GitHub Profile
@iconara
iconara / jruby_issue_2420.rb
Created January 7, 2015 15:32
JRuby issue 2420
require 'socket'
require 'thread'
port = 2**15 + rand(2**15)
lock = Mutex.new
connections = []
server_socket = TCPServer.new(port)
# this thread is the server, it accepts connections and adds
# them to the connections array
@iconara
iconara / gist:56f97bcd9a9ea3f37a40
Created January 4, 2015 12:11
IllegalBlockingModeException stack trace
Java::JavaNioChannels::IllegalBlockingModeException:
# java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:293)
# org.jruby.util.io.OpenFile.setBlocking(OpenFile.java:2340)
# org.jruby.util.io.OpenFile.setBlock(OpenFile.java:2324)
# org.jruby.RubyIO.ioWriteNonblock(RubyIO.java:1358)
# org.jruby.RubyIO.write_nonblock(RubyIO.java:1332)
# org.jruby.RubyIO$INVOKER$i$0$1$write_nonblock.call(RubyIO$INVOKER$i$0$1$write_nonblock.gen)
# org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:679)
# org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:206)
# org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:165)
@iconara
iconara / error
Last active August 29, 2015 14:08
LinkageError when bundling
Compiler.java:78:in `__file__': java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
from Compiler.java:89:in `load'
from Ruby.java:805:in `runScript'
from Ruby.java:798:in `runScript'
from Ruby.java:749:in `runNormally'
from Ruby.java:559:in `runFromMain'
from Main.java:405:in `doRunFromMain'
from Main.java:300:in `internalRun'
from Main.java:227:in `run'
from Main.java:199:in `main'
@iconara
iconara / output1
Last active August 29, 2015 14:08
JRuby 9k error with too many open files
Running the decorator end to end
only decorates with known properties
detects duplicates and does not send them downstream (FAILED - 1)
Failures:
1) Running the decorator end to end detects duplicates and does not send them downstream
Failure/Error: Unable to find matching line from backtrace
IOError:
Too many open files in system
@iconara
iconara / discard_server_test.rb
Last active August 29, 2015 14:08
Non blocking IO on JRuby 9k
require 'socket'
require 'thread'
server_port = 45678
server_bound_barrier = Queue.new
Thread.start do
server_socket = TCPServer.new(server_port)
server_bound_barrier << nil
readables = [server_socket]
@iconara
iconara / JVM stack trace
Created October 17, 2014 08:44
Stack frames from a script using aws-sdk-core to connect to DynamoDB Local without a real access key
"main" #1 prio=5 os_prio=31 tid=0x00007fcf2c001000 nid=0x1903 in Object.wait() [0x000000010c0b2000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000007a0eb8190> (a org.jruby.RubyThread)
at org.jruby.RubyThread.sleep(RubyThread.java:1001)
- locked <0x00000007a0eb8190> (a org.jruby.RubyThread)
- locked <0x00000007a0eb8190> (a org.jruby.RubyThread)
at org.jruby.RubyKernel.sleep(RubyKernel.java:828)
at org.jruby.RubyKernel$INVOKER$s$0$1$sleep.call(RubyKernel$INVOKER$s$0$1$sleep.gen)
at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:665)
@iconara
iconara / ssh-encrypt.sh
Last active August 29, 2015 14:07
Encrypt and decrypt strings with your SSH key
#!/bin/bash
case $1 in
encrypt)
pem_path=/tmp/$(basename $1).pem
ssh-keygen -f $2 -e -m PKCS8 > $pem_path
openssl rsautl -encrypt -pubin -inkey $pem_path -ssl | base64
srm $pem_path
;;
@iconara
iconara / notes.md
Last active August 29, 2015 14:04
Does a working JRuby web server exist?

Does a working JRuby web server exist?

Notes of the different Rack compatible web servers that exist for JRuby and their issues.

Puma

Puma's IO reactor doesn't handle errors very well. It can enter an endless loop where it will write error messages to $stderr, which is not fun if you redirect that to a log file.

Jubilee

@iconara
iconara / http_server.rb
Last active August 29, 2015 13:58
Ione Rack server using Puma's HttpParser
# encoding: utf-8
require 'ione'
require 'ione/http_client'
require 'puma/puma_http11'
module Ione
class HttpServer
def initialize(port, app)
@iconara
iconara / Test.java
Created March 17, 2014 08:25
Testing the full IPv4 range with GeoIPCity.dat
import com.maxmind.geoip.*;
import java.io.IOException;
import java.util.concurrent.*;
class Test {
public static void main(String[] args) throws IOException {
if (args.length == 0 || args[0] == "all") {
checkAll();
} else {
checkSome(args);