Skip to content

Instantly share code, notes, and snippets.

@zuk
zuk / drowsy_jquery.js
Created June 5, 2012 18:50
DrowsyDromedary usage with jQuery
// This line might not be necessary, but try it if you see weird HTTP errors.
jQuery.support.cors = true;
var drowsyUrl = "http://localhost:9292";
/** List available databases **/
jQuery.ajax(drowsyUrl, {
type: 'get',
success: function (dbs) {
@zuk
zuk / drowsy_backbone.js
Created June 5, 2012 19:06
DrowsyDromedary usage with Backbone.js
var drowsyUrl = 'http://localhost:9292';
var db = 'fridge';
/** Set up a basic Model class for Drowsy that we will extend from **/
var DrowsyModel = Backbone.Model.extend({
idAttribute: '_id',
// needed to deal with the way Drowsy returns ObjectIds
parse: function(data) {
data._id = data._id.$oid;
@zuk
zuk / roadshow_config.js
Created June 25, 2012 17:49
roadshow config example
self.config.mongo
// db: roadshow_config:
// coll: runs:
[
{'name': 'roadshow_monday_12323', 'locations': ['Poster 1', 'Poster 2', 'Poster 3'], '_id': '137c29183864e49dd9a00000'},
{'name': 'roadshow_tuesday_1232', 'locations': ['Poster 1', 'Poster 2'], '_id': '137c29183864e49dd9a00001'}
]
@zuk
zuk / serial_rw.pde
Created August 28, 2012 21:22
read serial character in arduino
#include <stdio.h>
char cmd;
#define CMD_ROCK 'r'
#define CMD_PAPER 'p'
#define CMD_SCISSORS 's'
void setup() {
Serial.begin(9600);
@zuk
zuk / rock_paper_awesome.ino
Created August 29, 2012 16:31
rock_paper_awesome
#include <stdio.h>
#define SERIAL_BAUDRATE 9600
#define MILLISECONDS_PER_FRAME 30
// the pins that control the brightness of RED, GREEN, and BLUE LEDs respectively
#define R 9
#define G 10
#define B 11
@zuk
zuk / rock_paper_awesome_simpler.ino
Created September 12, 2012 15:55
rock_paper_awesome
#include <stdio.h>
#define SERIAL_BAUDRATE 9600
#define MILLISECONDS_PER_FRAME 30
// the pins that control the brightness of RED, GREEN, and BLUE LEDs respectively
#define R 9
#define G 10
#define B 11
@zuk
zuk / someone_joined_room.rb
Created October 26, 2012 21:19
Someone Joined Room
def initialize
@students = {}
end
someone_joined_room do |stanza|
stu = lookup_student(Util.extract_login(stanza.from), true) unless stanza.from == agent_jid_in_room
if stu
log "#{stu} joined #{config[:room]}"
// npm install git://github.com/zuk/Backbone.Drowsy.git
// ... or just put the git URL in in package.json's dependencies
var jQuery = require('jquery');
var _ = require('underscore');
var Backbone = require('backbone');
Backbone.$ = jQuery;
var Drowsy = require('backbone.drowsy').Drowsy;
model.User = model.db.Document('users').extend({
setPhaseData: function(phaseKey, value) {
var pd = this.get('phase_data');
pd[phaseKey] = fooBar;
this.set('phase_data', pd);
}
});
@zuk
zuk / wakeful_collections_init.js
Created April 10, 2013 16:35
initing wakeful collections in node.js
CK.Model.init(config.drowsy.url, DATABASE).done(function () {
CK.Model.initWakefulCollections(config.wakeful.url).done(function() {
// do your stuff here
});
});