Skip to content

Instantly share code, notes, and snippets.

View robi42's full-sized avatar

Robert Thurnher robi42

View GitHub Profile
diff --git a/modules/core/array.js b/modules/core/array.js
index 138131b..e35a1cd 100644
--- a/modules/core/array.js
+++ b/modules/core/array.js
@@ -135,7 +135,7 @@ Object.defineProperty(Array.prototype, "partition", {
falses.push(this[i]);
}
}
- return [trues, falses]
+ return [trues, falses];
// an-app/config.js
// [...]
exports.urls = ["./actions"]; // Simply an array of module names now.
// an-app/actions.js
// [...]
diff --git a/modules/ringo/webapp/websocket.js b/modules/ringo/webapp/websocket.js
index 17ecc55..c3105cd 100644
--- a/modules/ringo/webapp/websocket.js
+++ b/modules/ringo/webapp/websocket.js
@@ -59,6 +59,14 @@ exports.addWebSocket = function(context, path, onconnect) {
return outbound.isOpen();
},
/**
+ * Get the outbound WebSocket connection.
+ * @name WebSocket.instance.getOutbound
diff --git a/actions.js b/actions.js
index cccc9f0..a87d4bb 100644
--- a/actions.js
+++ b/actions.js
@@ -28,7 +28,7 @@ exports.edit = function(req, name) {
exports.list = function(req) {
return Response.skin(module.resolve('./skins/list.html'), {
- pages: Page.all().sort(strings.Sorter('name'))});
+ pages: Page.query().orderBy('name').select()});
@robi42
robi42 / app.js
Created December 11, 2010 12:17
Run with, e.g.: `$ ringo -i app.js`
var {html5} = require('hiccup/page');
var {htmlResponse} = require('stick/helpers');
var text = 'Hello World!';
var markup = html5(['head', ['title', text]], ['body', ['h1', text]]);
var app = exports.app = require('stick').Application()
.configure('error', 'notfound', 'route')
.get('/', function (req) htmlResponse(markup));
var {html5} = require('hiccup/page'),
{Application} = require('stick'),
{Response} = require('stick/helpers');
var text = 'Hello World!',
markup = html5(['head', ['title', text]], ['body', ['h1', text]]),
app = exports.app = Application('error', 'notfound', 'route')
.get('/', function (req) Response.html(markup));
if (require.main === module) {
var http = require('ringo/httpclient');
var {AsyncResponse} = require('ringo/webapp/async');
var app = exports.app = require('stick').Application()
.configure('error', 'notfound', 'route', 'params');
app.get('/proxy/*', function (req, path) {
var response = new AsyncResponse(req);
// Fetch MP3 from AWS S3.
(function (win) {
win.$mp = win.$mp || {};
win.$mp.makeMvcPipe = function () {
var _loadStyleSheet = function (path, media, fn, scope) {
var sheet, cssRules;
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
@robi42
robi42 / gist:1078959
Created July 12, 2011 20:52
Conveniently iterate over a java.util.HashSet in Ringo
$ ringo
>> set = new java.util.HashSet(['foo', 'bar'])
[java.util.HashSet [foo, bar]]
>> for each (var element in Iterator(set)) print(element)
foo
bar
>>
exports.app = (req) ->
status: 200
headers:
'Content-Type': 'text/plain'
body: ['Hello World!']
if require.main is module
require('ringo/httpserver').main module.id