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
/** | |
* Basically like doWithM, just that your callback need not call done() at the | |
* end. | |
* | |
* ex. | |
* var linkFuture = doWith(element("a.myLink").attr("href"), function(href) { | |
* console.log("got link", href); | |
* }); | |
*/ | |
angular.scenario.dsl('doWith', function() { |
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
/** | |
* Defines a block to execute before each it or nested describe. | |
* | |
* beforeAll()s will be called before beforeEach()s. | |
* | |
* Note: unlike beforeEach(), this needs to be called on "this", ie. | |
* | |
* this.beforeAll(...) | |
* | |
* This can be fixed but would require too much hacking. |
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
(defmacro binding-ns | |
"Like binding, but bindings are based on all publics in ns." | |
[from-ns & body] | |
(let [ns-vars (fn [-ns] | |
; fnext to get var from ns-publics name-var pairs | |
(filter #(:dynamic (meta (fnext %))) | |
(ns-publics -ns))) | |
var-ize (fn [from-name-vars] | |
(loop [ret {} from-name-vars (seq from-name-vars)] | |
(if-let [[name from-var] (first from-name-vars)] |
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 [y,x] = make_quad(Q) | |
n=size(Q,1); | |
x=sym('x', [n 1]); | |
assume(x,'real'); | |
y=simplify(1/2 * x' * Q * x); | |
end |
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
""" | |
Use setattr | |
""" | |
# Normal | |
item.price = self.request['price'] | |
item.quantity = self.request['quantity'] | |
item.shipping = self.request['shipping'] | |
item.save() |
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
## Based on http://code.activestate.com/recipes/519639/ (r1) | |
## and http://code.activestate.com/recipes/496741-object-proxying/ (r1) | |
import copy | |
def proxy(cls, target): | |
""" | |
A, the class of the object to be proxied, intentionally takes an argument. | |
This foils any proxy techniques that instantiate the class of the proxee. |
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
# | |
# original: http://code.activestate.com/recipes/65287/ | |
# | |
# place in lib/python2.x/sitecustomize.py | |
import bdb | |
import sys | |
def info(type, value, tb): | |
if hasattr(sys, 'ps1') \ |
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/sh | |
# Usage: name host ['common opts'] ['1st run opts'] ['2nd run opts'] ... | |
if test "$#" -lt 2; then | |
echo "too little arguments!" | |
exit 1 | |
fi | |
RSYNC=rsync |
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.db.backends import BaseDatabaseFeatures | |
from django.db.backends.mysql.base import ( | |
DatabaseFeatures as MySQLDatabaseFeatures, | |
DatabaseOperations as MySQLDatabaseOperations, | |
) | |
try: | |
from django.util.functional import cached_property | |
except ImportError: | |
# Backport from django 1.4 |
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/sh | |
# was it a merge? | |
if test `git rev-list --parents -n 1 HEAD | wc -w` -lt 3; then | |
exit 0; | |
fi | |
if test `git rev-list ^HEAD^1 HEAD^@ -- sq/migrations | wc -l` -gt 0; then | |
echo '#' | |
echo '# WARNING: Migrations detected in merge; you may want to apply them.' |