Skip to content

Instantly share code, notes, and snippets.

View hns's full-sized avatar

Hannes Wallnoefer hns

View GitHub Profile
@hns
hns / async-jsgi.js
Created April 26, 2010 19:23
Example of async JSGI with ringo/promise
var {defer} = require("ringo/promise");
var {setTimeout} = require("ringo/scheduler");
exports.delayed = function(request) {
var response = defer();
setTimeout(function() {
response.resolve({
status: 200, headers: {}, body: ["Delayed"]
});
}, 1000);
@hns
hns / FastString.java
Created April 29, 2010 20:57
An early glimpse on rhino performance improvements i'm working on
package org.ringojs.wrappers;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.annotations.JSFunction;
import org.mozilla.javascript.annotations.JSStaticFunction;
// Note: there's nothing special about this host class (except for the missing
function outer(x) {
var y;
for (var i = 0; i < 10000000; i++) {
y = inner();
}
function inner() {
return x;
}
return inner();
}
diff --git a/auth.js b/auth.js
index 0ae0627..b324f8e 100644
--- a/auth.js
+++ b/auth.js
@@ -6,11 +6,11 @@ module.shared = true;
exports.middleware = function (app) {
return function (env) {
- if (auth[env.PATH_INFO.replace(/^\//, '').replace(/\/$/, '')]) {
+ if (auth[env.pathInfo.replace(/^\//, '').replace(/\/$/, '')]) {
@hns
hns / ringo-websocket.js
Created May 17, 2010 09:49
Get Websocket demo chat running in Ringo
/*
to get websocket protocol running in ringojs, do the following:
* copy jetty-websocket-7.*.jar into your classpath (e.g. lib/)
* add the following line to your webapp's config.js module:
exports.extensions = ["ringo-websocket"];
with "ringo-websocket" being the module name of this file.
* download the client script from this page:
http://blogs.webtide.com/gregw/entry/jetty_websocket_server
change the location to:
var {Response, skinResponse} = require('ringo/webapp/response');
var {ContinuationSession} = require('ringo/webapp/continuation');
var log = require('ringo/logging').getLogger(module.id);
// the main action is invoked for http://localhost:8080/
exports.index = {
GET: function(req) {
return skinResponse('./skins/welcome.txt', {title: 'Demo'});
}
var {Response, skinResponse} = require('ringo/webapp/response');
var {ContinuationSession} = require('ringo/webapp/continuation');
var log = require('ringo/logging').getLogger(module.id);
// the main action is invoked for http://localhost:8080/
exports.index = function(req) {
return skinResponse('./skins/welcome.txt', {title: 'Demo'});
};
Index: cometd-java/server/src/main/java/org/cometd/server/AbstractBayeux.java
===================================================================
--- cometd-java/server/src/main/java/org/cometd/server/AbstractBayeux.java (Revision 1264)
+++ cometd-java/server/src/main/java/org/cometd/server/AbstractBayeux.java (Arbeitskopie)
@@ -1348,10 +1348,8 @@
return;
}
- if (_securityPolicy.canPublish(client,channel_id,message))
- {
@hns
hns / httpclient-async-wait.js
Created June 15, 2010 10:35
Example RingoJS code for making multiple asynchronous HTTP requests and waiting for all to complete
var {request} = require("ringo/httpclient");
var urls = [
"http://www.henso.com/",
"http://www.ringojs.org/wiki/",
"http://github.com/"
];
var responses = urls.map(function(url) {
return request({
Stream.prototype.forEach = function(callback) {
var length = 8192;
var buffer = new ByteArray(length);
while (true) {
var read = this.readInto(buffer, 0, length);
if (read < 0)
break;
buffer.length = read;
callback(buffer);
buffer.length = length;