Skip to content

Instantly share code, notes, and snippets.

@zuk
zuk / sleepy_mongoose_example.js
Created September 25, 2011 23:09
Sleepy Mongoose example
observations = $().sleepyMongo({sleepyUrl: WallCology.mongooseURL + "/observations/")
observations.find({}, function(data) {
// do stuff
})
@zuk
zuk / account_callbacks.rb
Created September 29, 2011 20:24
Example Rollcall plugin for Corral
require 'rest_client'
require 'uri'
require 'account'
# this is basically a monkey patch of Rollcall's Account class...
# it's one of those things you would never see in Java, because you can't really
# modify a class during runtime
Account.class_eval do
# here we tell the Account class to execute different methods before
@zuk
zuk / rollcall-play-example.java
Created October 25, 2011 02:22
Logging in to Rollcall using Java in Play Framework
// authenticate with rollcall
String rollcallUrl = Play.configuration.getProperty("sail.rollcall.url");
WSRequest req = WS.url(rollcallUrl+"/login.json");
req.setParameter("session[login]", username);
req.setParameter("session[password]", password);
WS.HttpResponse res = req.post();
JsonElement json = res.getJson();
@zuk
zuk / Strophe.AutoConnector.js
Created February 13, 2012 20:32
Modified for BOSH attach()
Strophe.AutoConnector = {
events: {
initialized: function() {
Sail.loadCSS(Sail.modules.defaultPath + 'Strophe.AutoConnector.css')
//
$(Sail.Strophe).bind({
connect_error: Strophe.AutoConnector.connectFailure,
connect_connfail: Strophe.AutoConnector.connectFailure,
connect_authfail: Strophe.AutoConnector.connectFailure,
@zuk
zuk / prosody.config.lua
Created February 13, 2012 22:33
prosody config file for sail deployment
---------- Server-wide settings ----------
-- Settings in this section apply to the whole server and are the default settings
-- for any virtual hosts
-- This is a (by default, empty) list of accounts that are admins
-- for the server. Note that you must create the accounts separately
-- (see http://prosody.im/doc/creating_accounts for info)
-- Example: admins = { "user1@example.com", "user2@example.net" }
admins = { }
event :do_magic_stuff? do
f = File.open('myfile.txt','r')
f.each_line do |line|
msg = Blather::Stanza::Message.new
msg.to = "somerooom@conference.aardvark.encorelab.org"
msg.type = :groupchat
msg.body = line
client.write(msg)
jQuery(veos).bind('gmaps.ready', function() {
/* dependent code goes here */
});
var r = new veos.model.Reports(); // creates the "reports" collection proxy object
r.on('reset', function(collection) {
navigator.geolocation.getCurrentPosition(function(currentLocation) {
var collectionFilter = function(installation) {
return isCloseBy(installation, currentLocation);
}
var filteredReports = _.filter(collection, collectionFilter);
createGrid(filteredReports);
@zuk
zuk / veos_photo_upload.js
Created April 17, 2012 21:46
VEOS Photo capture and upload examples
var photo = new veos.model.Photo();
// called when photo.upload() succeeds
function photoUploaded() {
console.log("Photo ID is: " + photo.id);
}
// called when photo.captureFromCamera() succeeds
function imageCaptured () {
// upload the captured image to the server
[1, 2, 3]
{1: 'a', 2: 'b', 3: 'c'}
[
{eq: 1, foo: "asdfasdf"},
{eq: 2, foo: "asdfasdfsdfasdf"}
]