Skip to content

Instantly share code, notes, and snippets.

View tauren's full-sized avatar

Tauren Mills tauren

View GitHub Profile
/*
* REST endpoint: /projects
*/
var projects = [
{
"id": 2,
"name": "Project 1",
"members": [
{"id": 1, "name": "Tom", "phone": "555-5555"},
{"id": 2, "name": "Sue", "phone": "555-5555"}
var user = new User({
id: 1,
username: "bob",
address: {
id: 1,
street: "232 SW Main"
city: "",
state: "",
zip: ""
}
var child = new Backbone.Model({name: "child"});
var parent = new Backbone.Model({name: "parent", child: child});
var json = parent.toJson()
This should return:
{
name: "parent",
child: {
name: "child"
}
@tauren
tauren / FindUserCollection.js
Created March 22, 2011 22:20
Handling different URLs with backbone.js
var FindUserCollection = Backbone.Collection.extend({
model: User,
baseUrl: "/api/v2/users",
url: function() {
return this.baseUrl + '?' + $.param({
search: this.search,
limit: this.limit
});
}
search: null,
tauren@godzilla:~$ ssh -vv foo@schedules.somewhere.com
OpenSSH_5.1p1 Debian-6ubuntu2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /home/tauren/.ssh/config
debug1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to schedules.somewhere.com [192.168.192.126] port 22.
debug1: Connection established.
screemake clean
python tools/waf-light clean
DEST_OS: linux
DEST_CPU: x64
Parallel Jobs: 8
tauren@godzilla:/projects/git/node$ ./configure --prefix=$HOME/local/node
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc or cc : /usr/bin/gcc
Checking for gcc : ok
Checking for library dl : yes
Checking for openssl : yes
app.get '/realms', (req,res) ->
name = req.query.jsonp || 'jsonp'
res.contentType 'application/x-javascript'
fs.readFile __dirname + '/../../data/realms.json', (err,data) ->
if err
throw error
res.send name + '(' + data + ');'
# Static site
app.get '/site/*:name', (req,res) ->
console.log 'Getting file ' + req.params.name
res.sendfile __dirname + '/public/' + req.params.name
@tauren
tauren / gist:1045906
Created June 24, 2011 23:56
Make it safe to use console.log always. How to convert to coffeescript?
// usage: log('inside coolFunc', this, arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
log.history = log.history || []; // store logs to an array for reference
log.history.push(arguments);
if(this.console) {
arguments.callee = arguments.callee.caller;
console.log( Array.prototype.slice.call(arguments) );
}
};