Skip to content

Instantly share code, notes, and snippets.

View mlynch's full-sized avatar
🍂
Building something new

Max Lynch mlynch

🍂
Building something new
View GitHub Profile
@mlynch
mlynch / app.js
Created May 11, 2012 17:01
Backbone Collections
var UserAppVersions = Backbone.Collection.extend({
model: UserAppVersion,
url: function() {
return '/api/v1/user/app/' + this.id + '/versions';
},
parse: function(response) {
return response.versions;
}
});
@mlynch
mlynch / app.js
Created May 11, 2012 17:03
UserAppVersions
var versions = new UserAppVersions();
versions.id = appId;
versions.fetch({
error: function() {
console.log('Unable to load user app versions');
},
success: function(versions) {
console.log('Versions', versions);
// iterate over them with the each function, or with a for loop over version.models
@mlynch
mlynch / versions.json
Created May 11, 2012 17:06
Version collection
{
"versions":[
{
"created_at":""
}
]
}
@mlynch
mlynch / api.py
Created May 16, 2012 14:42
Example request handler
def _v1_user_app(request, appid):
# check authentication
if request.method == "POST":
try:
app_parsed = json.loads(request.raw_post_data)
# app_parsed is now a dictionary or hash object
# ...
return HttpResponse() # OK!
except:
@mlynch
mlynch / api.py
Created May 16, 2012 14:49
Example request handler
def _v1_user_app(request, appid):
# check authentication
if request.method == "POST":
try:
app_parsed = json.loads(request.raw_post_data)
# app_parsed is now a dictionary or hash object
# ...
return HttpResponse() # OK!
except:
@mlynch
mlynch / app.js
Created May 16, 2012 15:08
UserAppVersions
var versions = new UserAppVersions();
versions.id = appId;
versions.fetch({
error: function() {
console.log('Unable to load user app versions');
},
success: function(versions) {
console.log('Versions', versions);
// iterate over them with the each function, or with a for loop over version.models
@mlynch
mlynch / button.css
Created June 7, 2012 21:51
Nice Bootstrap Button
.btn-custom {
background-color: hsl(241, 36%, 36%) !important;
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#3b3a7c", endColorstr="#3b3a7c");
background-image: -khtml-gradient(linear, left top, left bottom, from(#3b3a7c), to(#3b3a7c));
background-image: -moz-linear-gradient(top, #3b3a7c, #3b3a7c);
background-image: -ms-linear-gradient(top, #3b3a7c, #3b3a7c);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #3b3a7c), color-stop(100%, #3b3a7c));
background-image: -webkit-linear-gradient(top, #3b3a7c, #3b3a7c);
background-image: -o-linear-gradient(top, #3b3a7c, #3b3a7c);
@mlynch
mlynch / resources.js
Created June 12, 2012 18:38
Add a resource
initialize: function() {
this._fdb = new Firebase('http://gamma.firebase.com/opencountmadison/');
this._resources = this._fdb.child('resources');
},
// Add a new resource
_addResource: function(tag, name, max, count) {
var self = this, now = new Date();
var resourceData = {
tag: tag,
name: name,
@mlynch
mlynch / resources.js
Created June 12, 2012 18:40
resources
initialize: function() {
this._fdb = new Firebase('http://gamma.firebase.com/opencountmadison/');
this._resources = this._fdb.child('resources');
},
// Add a new resource
_addResource: function(tag, name, max, count) {
var self = this, now = new Date();
var resourceData = {
tag: tag,
name: name,
@mlynch
mlynch / resources.js
Created June 12, 2012 18:42
Resource Events
// Bind Firebase data events
_bindDataEvents: function() {
var self = this;
this._resources.on('child_added', function(resourceSnapshot) {
$(document).trigger('resource.oneAdded', resourceSnapshot.val());
});
this._resources.on('child_changed', function(resourceSnapshot) {
var resource = resourceSnapshot.val();