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
(function() { | |
// Save a reference to the global object. | |
var root = this; | |
/* do stuff */ | |
root.public_method = function() {}; | |
}).call(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
/* Pretend app setup stuff is here */ | |
/* Kick off app */ | |
jQuery(function($) { | |
var Gallery = app.module("gallery"); | |
app.Router = Backbone.Router.extend({ | |
routes: { | |
"add": "main_add" |
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 backbone_validation = require('backbone-validation'); | |
backbone_validation(app, '/libs/backbone-validation.js'); | |
// and access the browser side validation with | |
// <script src="/libs/backbone-validation.js"></script> |
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 Db = require('mongodb').Db; | |
//... | |
options.noOpen = true; | |
myDb = Db.connect(mongouri, options); | |
// or | |
options.noOpen = 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
var tobi = require('tobi'), | |
browser = tobi.createBrowser(8000, "localhost"); | |
json_browser = (function(){ | |
var json_header = {headers: | |
{ | |
"Accept": "application/json", | |
"X-Requested-With": "XMLHttpRequest" | |
} | |
}; |
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 mongoose = require('mongoose'), | |
Schema = mongoose.Schema, | |
ObjectId = Schema.ObjectId; | |
var myS = new Schema({ | |
name: {type: String, required: true} | |
}); | |
var My = mongoose.model('My', myS); | |
var my = new My({'name': 'bika'}); |
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 mongoose = require('mongoose'), | |
async = require('async'), | |
Schema = mongoose.Schema, | |
ObjectId = Schema.ObjectId; | |
var MyS = new Schema({ | |
feeling: String | |
}); | |
MyS.pre('save', function(done){ | |
async.parallel([ |
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
''' A model field to store and retrieve Google Protocol Buffer objects easily. | |
Uses the BlobField available on GAE for storage. | |
Usage: | |
myfield = ProtobufField(protoclass=MyProtocolClass) | |
where MyProtocolClass is a protocol descriptor class generated from a .proto file. | |
The field is supposed to store only the given kind of protocol messages. |
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
import logging | |
import facepy as facebook | |
from django.conf import settings | |
from django.contrib.auth.signals import user_logged_in | |
from django.db import models | |
from django.contrib.auth import logout | |
from django.contrib.auth.models import User | |
class FBAuthMiddleware(object): | |
def __init__(self): |
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/python | |
import os | |
from boto.s3.connection import S3Connection | |
import subprocess | |
from datetime import datetime, date | |
import argparse | |
import tempfile | |
import json | |
parser = argparse.ArgumentParser(description="Downloads logs from S3, and parses them with goaccess.") |
OlderNewer