Skip to content

Instantly share code, notes, and snippets.

View robi42's full-sized avatar

Robert Thurnher robi42

View GitHub Profile
// Add formatting convenience method on java.util.Date:
var JDate = helma.engine.extendJavaClass(java.util.Date);
JDate.prototype.format = function (formatString) {
var sdf = new java.text.SimpleDateFormat(formatString);
return sdf.format(this);
};
// Enable for-(each-)in looping on java.util.Map:
// Lives in: wiki-ng/db/
include('helma/file');
var data, dir = new File('Page');
dir.listFiles().forEach(function(file) {
data = JSON.parse(file.readAll());
data.revisions = [];
data.revisions.push(data.body);
include('fs-base');
var format = require('ringo/utils').format;
const ROOT = './20news-18828';
const MAX_FILES = 100;
list(ROOT).forEach(function (dir) {
print('Dir:', dir);
while (list(format('{}/{}', ROOT, dir)).length > MAX_FILES) {
for each (var file in list(format('{}/{}', ROOT, dir))) {
<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>
<groupId>org.ringojs</groupId>
<artifactId>ringojs</artifactId>
<packaging>jar</packaging>
<version>0.5.0-SNAPSHOT</version>
<name>RingoJS</name>
<url>http://ringojs.org/</url>
Index: src/org/ringojs/wrappers/Storable.java
===================================================================
--- src/org/ringojs/wrappers/Storable.java (revision 283dfdd4c41ea6b9e7965f6abe01cad6e9842a65)
+++ src/org/ringojs/wrappers/Storable.java Wed Apr 07 00:16:59 CEST 2010
@@ -1,23 +1,25 @@
package org.ringojs.wrappers;
import org.mozilla.javascript.*;
-import org.mozilla.javascript.annotations.JSStaticFunction;
import org.mozilla.javascript.annotations.JSFunction;
Index: src/org/ringojs/wrappers/Storable.java
===================================================================
--- src/org/ringojs/wrappers/Storable.java (revision 283dfdd4c41ea6b9e7965f6abe01cad6e9842a65)
+++ src/org/ringojs/wrappers/Storable.java Wed Apr 07 00:37:58 CEST 2010
@@ -16,7 +16,7 @@
private Object key;
private Object entity;
- enum FactoryType {CONSTRUCTOR, FACTORY};
+ enum FactoryType {CONSTRUCTOR, FACTORY}
// Test for Ringo's new async HTTP client with streaming Twitter API
// Run with:
// ringo twitterstream.js KEYWORD
// needs valid user credentials
var username = "user";
var password = "password";
include("ringo/term");
var {Client} = require("ringo/httpclient");
Index: src/org/ringojs/wrappers/Storable.java
===================================================================
--- src/org/ringojs/wrappers/Storable.java (revision 8afdca5b125784a121643a029b843cec33577e64)
+++ src/org/ringojs/wrappers/Storable.java Sun Apr 11 19:10:01 CEST 2010
@@ -85,7 +85,7 @@
}
@JSStaticFunction
- public static Scriptable defineClass(Scriptable store, String type, Object mapping)
+ public static Scriptable defineClass(Scriptable store, String type, Object mapping, Object settings)
var Person = require('ringo/storage/hibernate').defineClass('Person', {
table: 'persons', cacheable: false, props: {
firstName: {type: 'string', nullable: false},
lastName: {type: 'string', nullable: false},
birthDate: {type: 'timestamp', nullable: false},
birthYear: {type: 'integer'},
vitae: {column: 'resume', type: 'text', unique: true}
}});
#!/usr/bin/env ringo
// Lives in: `ringowiki/db/`
var fs = require('fs');
var path = fs.path('Page');
fs.list(path).forEach(function (file) {
var filePath = fs.join(path, file);