Skip to content

Instantly share code, notes, and snippets.

View ianb's full-sized avatar

Ian Bicking ianb

View GitHub Profile
import decorator
def multiplier(n):
def decorator(fn):
return Multiplier(fn, n)
return decorator
class Multiplier(object):
def __init__(self, func, n):
self.func = func
Traceback (most recent call last):
File "/usr/local/share/silverlining/mgr-scripts/master-runner.py", line 44, in application
return found_app(environ, start_response)
File "/var/www/zamboni.2010-04-01_003/lib/python/django/core/handlers/wsgi.py", line 241, in __call__
response = self.get_response(request)
File "/var/www/zamboni.2010-04-01_003/lib/python/django/core/handlers/base.py", line 143, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)
File "/var/www/zamboni.2010-04-01_003/lib/python/django/core/handlers/base.py", line 101, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/var/www/zamboni.2010-04-01_003/src/zamboni-src/zamboni/apps/addons/views.py", line 225, in home
## Descriptors
## Anything with __get__ and __set__:
class classinstancemethod(object):
def __init__(self, func):
self.func = func
def __get__(self, obj, type=None):
def repl(*args, **kw):
return self.func(obj, type, *args, **kw)
## Descriptors
## Anything with __get__ and optionally __set__:
class classinstancemethod(object):
def __init__(self, func):
self.func = func
def __get__(self, obj, type=None):
def repl(*args, **kw):
return self.func(obj, type, *args, **kw)
var app = $.sammy(function () {
this.element_selector = '#body';
this.get('#/', function (context) {
... stuff to do for the URL /#/ ...
});
this.get('#/view/:id', function (context) {
... stuff for e.g., /#/view/10 ...
... use this.params.id to get "10" ...
});
});
<body>
<div id="header">stuff...</div>
<div id="body">
</div>
<div id="templates" style="display: none">
<div class="page-main">
Template for the main page...
</div>
<div class="page-view">
Template for the view page...
templateDirectives = {
'page-main': {
...
},
'page-view': {
...
}
};
templates = {};
<div>
Person: <span class="name">Person's Name</span>
<span class="is-admin">ADMIN</span>
<br>
Addresses:
<ul>
<li class="address">
<span class="street">1234 Main St.</span><br>
<span class="city">City</span>
{"name": "bob",
"admin": 1,
"addresses": [
{"street": "19 Park Lane",
"city": "Heresville"}
]
}
{
".name": "name",
"li.address": {
"address<-addresses": {
".street": "address.street",
".city": "address.city"
}
},
".is-admin": function (ctx) {
return ctx.admin ? 'ADMIN' : null;