Skip to content

Instantly share code, notes, and snippets.

@oberhamsi
oberhamsi / gist:5712588
Created June 5, 2013 08:55
shutdown hook deadlock
2013-06-05 10:47:40
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.1-b02 mixed mode):
"ringo-worker-1" daemon prio=10 tid=0x00007fb698003800 nid=0x77e7 waiting on condition [0x00007fb6cb227000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000ec3cc6a0> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:811)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:842)

Oberhamsi's RingoJs benchmark

RingoJs comes with a HTTP Server and basic utilities to deal with JSGI. Unless you are building something very specific, you will want to use packages to ease web development. With this benchmark I try to shed some light on how much those (beta quality) packages for web development degrade RingoJs' performance. The benchmark tasks defined by this benchmark are simple but can give us an upper limit for the performance achievable in real world projects.

I am using the TechEmpower FrameworkBenchmarks. This benchmark tests web development frameworks by running multiple, standardized tasks at varying concurrency levels. The four tasks are outlined in more detail in the results section.

Ringo and friends

I benchmarked Ringo twice to see how a pure JSGI application, written just with the Ringo standard library, performs compared to an application utilizing all the libraries we recommend for convenient web development. Those

@oberhamsi
oberhamsi / lintit.js
Last active December 16, 2015 07:28
quick jslint with ringo
var fs = require('fs');
JSLINT(fs.read(require('system').args[1]), {
passfail: false,
undef: true,
vars: true,
bitwise: true,
sloppy: true,
white: true,
devel: true,
plusplus: true,
#!/bin/bash
REVISIONS=`svn log -q --stop-on-copy |grep "^r" | cut -d"r" -f2 | cut -d" " -f1`
for rev in $REVISIONS; do
prevRev=$(($rev-1))
difftext=`svn diff --old=$file@$prevRev --new=$file@$rev | tr -s " " | grep -v " -\ \- " | grep -e "$1"`
if [ -n "$difftext" ]; then
echo "$rev: $difftext"
fi
done
$.fn.listHandlers = function(events, outputFunction) {
return this.each(function(i){
var elem = this,
dEvents = $(this).data('events');
if (!dEvents) {return;}
$.each(dEvents, function(name, handler){
if((new RegExp('^(' + (events === '*' ? '.+' : events.replace(',','|').replace(/^on/i,'')) + ')$' ,'i')).test(name)) {
$.each(handler, function(i,handler){
outputFunction(elem, '\n' + i + ': [' + name + '] : ' + handler );
});
@oberhamsi
oberhamsi / ringojs.init
Created November 15, 2012 10:27
ringojs init.d
#!/bin/sh
#
# /etc/init.d/ringojs -- startup script for the Ringo JavaScript runtime
#
# Written by Miquel van Smoorenburg <[email protected]>.
# Modified for Debian GNU/Linux by Ian Murdock <[email protected]>.
# Modified for Tomcat by Stefan Gybas <[email protected]>.
# Modified for Tomcat6 by Thierry Carrez <[email protected]>.
# Modified for RingoJS by Hannes Wallnoefer <[email protected]>.
#
@oberhamsi
oberhamsi / sessiondatatest.js
Created November 7, 2012 15:56
req.session.data problem
var {Application} = require('stick');
var app = exports.app = new Application();
app.configure('route');
app.configure('session');
app.get('/', function(req) {
console.dir(req.session.data);
});
@oberhamsi
oberhamsi / proxytest.js
Created November 7, 2012 13:21
js Proxy in rhino
var myObject = {
"foo": true,
"author": "simon",
"env": 123
}
var myProxy = new JavaAdapter(org.mozilla.javascript.NativeObject, {
// The "start" argument is here for setters and getters living
// on a prototype, so they know what to use as "this"-object.
put: function(name, start, value) {
@oberhamsi
oberhamsi / collision.js
Last active October 12, 2015 09:37
tmx collision map
var gamejs = require('gamejs');
var $v = require('gamejs/utils/vectors');
/*
* · Each tile can hold a "block" property detailing its desired
* blocking behaviour. Possible blocking data values are:
* - "none" -> Tile does not block.
* - "always" -> Tile blocks.
* - "north" -> Tile does not allow to go through its north border.
* - "east" -> Tile does not allow to go through its east border.
/*!
* @version 1.0
* @see ORFON
* A setInterval which is pausable and does not trigger
* when the current document doesn't have focus.
*
* Must explictely be `start()`ed.
*
* Optionally, the callback can return `false` in which case the
* `interval` duration is increased in `intervalStep` up to `maxInterval` until a later callback