Skip to content

Instantly share code, notes, and snippets.

View davej's full-sized avatar
💭
Working on @ToDesktop

Dave Jeffery davej

💭
Working on @ToDesktop
View GitHub Profile
Verifying that +davej is my Bitcoin username. You can send me #bitcoin here: https://onename.io/davej
extendsScope_module = angular.module 'classy-extends', ['classy-core']
###
Note that this does NOT get the mixin class dependencies as of now.
###
extendsScope_module.classy.plugin.controller
name: 'extends'
localInject: ['$controller']
/*
* To create a plugin you need to include the `classy-core` module and then pass
* your plugin object into the `class.plugin.controller function`
*/
angular.module('classy-yourPlugin', ['classy-core']).classy.plugin.controller({
name: 'yourPlugin',
/*
* Dependencies placed in the localInject array will be available on `@` (`this`)
* in the plugins init and postInit methods.
###
# To create a plugin you need to include the `classy-core` module and then pass
# your plugin object into the `class.plugin.controller function`
###
angular.module('classy-yourPlugin', ['classy-core']).classy.plugin.controller
name: 'yourPlugin'
###
# Dependencies placed in the localInject array will be available on `@` (`this`)
define [
'base-ctrl'
], (BaseCtrl) ->
class AppController extends BaseCtrl
@register()
@inject('$scope')
init: ->
@$scope.foo = "bar"
@davej
davej / basecamp-todos-to-blimp-goals.py
Created January 22, 2013 20:17
A simple script to copy a Basecamp classic todo list over to Blimp as a goal with tasks
"""
A simple script to copy a Basecamp classic todo list
over to Blimp as a goal with tasks
@author: Dave Jeffery
@requirements:
pip install git+git://github.com/nowherefarm/basecamp.git
pip install blimp
"""
@davej
davej / gist:1680278
Created January 26, 2012 01:21 — forked from EGreg/gist:1678415
Asynchronous loop issues illustrative example
// Illustrative case
// YEAH -- ILLUSTRATIVE OF THE FACT THAT YOU CAN ISSUE PARALLEL QUERIES TO THE DATABASE INSTEAD OF SERIAL ONES LIKE A DUMB THREADED IMPLEMENTATION THAT IS INFERIOR FOR DOING WEB SERVERS
function (recentBlogPostIds, callback) { // obviously you need this, but use callback instead of return
var results = [], // Use array not object
, len = recentBlogPostIds.length; // Cache length since we'll be using it more than once
for (var i = 0; i < len; i++) {
var blogPostId = recentBlogPostIds[i];
@davej
davej / DRY.js
Created January 26, 2012 01:14 — forked from EGreg/DRY
Asynchronous cache failover example
function cacheOrDB (id, callback) {
asynchronousCache.get("id:"+id, function(err, myThing) {
if (myThing == null) {
asynchronousDB.query("SELECT * from something WHERE id = "+id, function(err, myThing) {
callback(err, myThing);
});
} else {
callback(err, myThing);
}
});
// helper function that goes inside your socket connection
client.connectSession = function(fn) {
var cookie = client.request.headers.cookie;
var sid = unescape(cookie.match(/connect\.sid=([^;]+)/)[1]);
redis.get(sid, function(err, data) {
fn(err, JSON.parse(data));
});
};
// usage
@davej
davej / hosts on Mac OS X
Created September 10, 2010 19:47
Redirecting DNS by editing /etc/hosts on Mac OS X
# /etc/hosts
127.0.0.1 local.domain
123.123.123.123 www.domain.com
# In the Mac OS X terminal type:
dscacheutil -flushcache