Skip to content

Instantly share code, notes, and snippets.

View hns's full-sized avatar

Hannes Wallnoefer hns

View GitHub Profile
Parser.addOption("-i", "--init")
.action("set")
.destination("init")
.defaultValue(false)
.type(Boolean)
.help("Init repository if it doesn't exist");
Parser.addOption("-i", "--init", {
action: "set",
destination: "init",
const Token = org.mozilla.javascript.Token;
function parse(source, name) {
var exportedFunction;
var exportedName;
var exported = [];
var jsdocs = [];
var seen = {};
var checkAssignment = function(node, root, exported) {
helma> var Parser = require('helma/args').Parser;
helma> var p = new Parser();
helma> p.addOption("s", "silent", null, "Ignore errors and warnings")
helma> p.addOption("x", "extend", "FOO", "Extend core functionality using FOO")
helma> p.addOption("v", "verbose", null, "Be verbose")
helma> p.help()
-s --silent Ignore errors and warnings
-x --extend FOO Extend core functionality using FOO
-v --verbose Be verbose
helma> var args = ["-s", "-x", "foo"];
exports.app = function myAsyncApp(request){
return function(responder) {
responder.init(200, {});
var i = 0;
var intervalId = setInterval(function(){
responder.write("Every second another message");
if(i++ == 10){
responder.close();
clearInterval(intervalId);
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
Apache Maven 2 POM generated by Apache Ivy
http://ant.apache.org/ivy/
Apache Ivy version: 2.1.0 20090925235825
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
diff --git a/src/org/ringojs/wrappers/Storable.java b/src/org/ringojs/wrappers/Storable.java
index 2ee3055..302fa40 100644
--- a/src/org/ringojs/wrappers/Storable.java
+++ b/src/org/ringojs/wrappers/Storable.java
@@ -70,7 +70,7 @@ public class Storable extends ScriptableObject {
}
@JSStaticFunction
- public static Scriptable defineClass(Scriptable store, String type)
+ public static Scriptable defineClass(Scriptable store, String type, Object mapping)
@hns
hns / twitterstream.js
Created April 8, 2010 13:38
A RingoJS script that tracks one or more topics via Twitter's streaming API
// Test for Ringo's new async HTTP client with streaming Twitter API
//
// NOTE: I started working on a package for asynchronous JSON parsing that contains
// a better working version of this script: http://github.com/hns/jetson
//
// Run with:
// ringo twitterstream.js KEYWORD[,KEYWORD]
// needs valid user credentials
var username = "user";
@hns
hns / gist:360650
Created April 8, 2010 23:00
Examples for current Async JSGI implementation in RingoJS
include('ringo/scheduler');
exports.app2 = function myAsyncApp(request){
// Sends a message once a second 10 times
var progress, finished;
var i = 0;
var intervalId = setInterval(function(){
i++;
progress({
status: 200,
@hns
hns / promise.js
Created April 22, 2010 20:51
Implementation of free-threaded promises in Rhino
var {setTimeout} = require("ringo/scheduler");
export("defer");
var NEW = 0;
var FULFILLED = 1;
var FAILED = 2;
/**
@hns
hns / file.js
Created April 23, 2010 12:36
Compatibility shim for modules using Narwhal's file module
var map = {
base: "basename",
changeWorkingDirectory: "chdir",
workingDirectory: "cwd",
directory: "dirname",
makeDirectory: "mkdir",
makeTree: "mkdirs",
lastModified: "mtime",
removeDirectory: "rmdir",