This file contains hidden or 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
""" | |
params.py | |
Friends to help you generate SQL named params for safe querying. | |
Because it's a hassle to generate param names for batch inserts like this one: | |
INSERT IGNORE | |
INTO t |
This file contains hidden or 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 argparse | |
import re | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-o', '--outfile') | |
parser.add_argument('-d', '--outdir') | |
parser.add_argument('template') | |
parser.add_argument('extras', nargs=argparse.REMAINDER) | |
args = parser.parse_args() |
This file contains hidden or 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 $ = require('jquery'); | |
var p = $.Deferred() | |
, q = $.Deferred() | |
, r = $.Deferred() | |
, xs = ["A", "B", "C"] | |
, splice = function (i) { console.log('splicing', i, 'out of', xs); xs.splice(i, 1); console.log('and it becomes', xs);} | |
; | |
p.then(splice); |
This file contains hidden or 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 observ = require('observ'); | |
function withPeriodicSaving(observable) { | |
var unsaved = [] | |
, pushPending = false | |
, savePending = false | |
; | |
return observable(function (value) { | |
console.log('ch-ch-changes!', value, pushPending, savePending); |
This file contains hidden or 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 extend = require('xtend'); | |
var observ = require('observ'); | |
var observStruct = require('observ-struct'); | |
function Immutable(route, value) { | |
var stack = [] | |
, _unsaved = [] | |
, observable = observ(value) | |
; |
This file contains hidden or 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
call pathogen#infect() | |
syntax enable | |
filetype plugin indent on | |
set hls | |
set nobackup | |
set directory-=. | |
set directory^=~/.vim/.tmp// | |
set noautoindent nosmartindent |
This file contains hidden or 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
Theorem plus_n_Sm : forall n m : nat, | |
S (n + m) = n + (S m). | |
Proof. | |
intros n m. induction n as [| n']. | |
Case "n = 0". | |
simpl. reflexivity. | |
Case "n = S n'". | |
simpl. rewrite -> IHn'. | |
reflexivity. | |
Qed. |
This file contains hidden or 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 dingus import patch | |
def load_fixture(orm, fixture_name): | |
_get_model = lambda model_identifier: orm[model_identifier] | |
with patch('django.core.serializers.python._get_model', _get_model): | |
from django.core.management import call_command | |
call_command("loaddata", fixture_name) |
This file contains hidden or 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 realgood.models import A, B | |
>>> b = B(frob="Y") | |
>>> b.save() | |
>>> b.id | |
1 | |
>>> b.save(force_insert=True) | |
Traceback (most recent call last): | |
File "<console>", line 1, in <module> | |
File "/home/cj/.virtualenvs/dashboard.dev/lib/python2.6/site-packages/django/db/models/base.py", line 458, in save | |
self.save_base(using=using, force_insert=force_insert, force_update=force_update) |
This file contains hidden or 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 apps.agreements.standard.models import StandardAgreement as SA | |
>>> SA.objects.latest('pk') | |
<StandardAgreement: 1: (none)> | |
>>> s = SA.objects.latest('pk') | |
>>> s2 = s.save(force_insert=True) | |
Traceback (most recent call last): | |
File "<console>", line 1, in <module> | |
File "/home/cj/dev/agreement-dashboard/dashboard.git/dashboard/apps/agreements/models.py", line 104, in save | |
super(Agreement, self).save(*args, **kwargs) | |
File "/home/cj/.virtualenvs/dashboard.dev/lib/python2.6/site-packages/django/db/models/base.py", line 458, in save |
NewerOlder