This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([], function() { | |
/* See also: "Learning Javascript Design Patterns" by Addy Osmani | |
* http://addyosmani.com/resources/essentialjsdesignpatterns/book/ | |
* | |
* for examples on how to use pubsub as event aggregator (Mediator) | |
* | |
*/ | |
var pubsub = function(){}; | |
(function(q) { | |
var topics = {}, subUid = -1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "------------------------------------------------------------------------" | |
if [[ "$#" -ne 2 ]]; then | |
echo "IMG Burner -- Built for macbook pros w/ the SD card slot on the right." | |
echo " - Insert a blank SD card" | |
echo " - run with two args - img file and destination disk (typically disk2, disk3, etc. NEVER disk1 or sda1)" | |
echo " - run $ mount to see what disks are available" | |
echo " - Example: $ ./resin.img.burn.sh path/to/resin.img disk2" | |
exit | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(Object.prototype, "extend", { | |
enumerable: false, | |
value: function(from) { | |
var props = Object.getOwnPropertyNames(from); | |
var dest = this; | |
props.forEach(function(name) { | |
if (name in dest) { | |
var destination = Object.getOwnPropertyDescriptor(from, name); | |
Object.defineProperty(dest, name, destination); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl http://npmjs.org/install.sh | sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_or_none(model, *args, **kwargs): | |
""" | |
look for a model instance, return None if it doesn't exists | |
""" | |
try: | |
return model.objects.get(*args,**kwargs) | |
except model.DoesNotExist: | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
def email_template( | |
template_name = None, | |
template_context = None, | |
subject = '', | |
recipients = None, | |
sender = settings.DEFAULT_FROM_EMAIL, | |
fail_silently = False, | |
use_markdown = False, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# don't forget each model needs | |
# class Meta: | |
# app_label = 'app_name' # or whatever the app name is | |
PACKAGE = 'project_name.app_name.models' # <--- SET YOUR PACKAGE NAME | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['ko','ko.mapping','underscore','moment'], | |
function(ko,mapping,_,moment) { | |
console.log('dashboard VM loaded:',arguments); | |
return function(){ | |
var self = this; | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage inside a vm: | |
var fooVM = function(){ | |
var self = this; | |
var resource_uri = ko.observable('/api/v1/foo/'); | |
var bar = ko.observable(1); | |
var baz = ko.observable(1); | |
ko.saveOnChange(self,['bar']); | |
} | |
var f = new fooVM(); | |
f.bar(2); // causes a PUT to /api/v1/foo/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Payment = kb.Model.extend({ | |
urlRoot: '/api/v1/payment_backbone/' | |
}); | |
var PaymentCollection = kb.Collection.extend({ | |
model: Payment | |
// Constructor method | |
, initialize: function(data, options) { | |
this.limit = options.limit || 20; |
OlderNewer