Skip to content

Instantly share code, notes, and snippets.

.divDirectoryBody {
padding-top: 25px;
}
.ulDirectory {
font-family: Arial;
list-style-type: none;
margin: 0;
font-size: 18px;
}
.directoryItem {
@Ademan
Ademan / test_nested_transactions.py
Created November 11, 2013 19:40
Test the behavior of sqlite3 nesting
#!/usr/bin/env python
import sqlite3
import unittest
create_table = """\
CREATE TABLE test (
id INTEGER PRIMARY KEY AUTOINCREMENT,
data TEXT
2 0 LOAD_CONST 1 (0)
3 STORE_FAST 1 (sum)
3 6 SETUP_LOOP 24 (to 33)
9 LOAD_FAST 0 (xs)
12 GET_ITER
>> 13 FOR_ITER 16 (to 32)
16 STORE_FAST 2 (x)
4 19 LOAD_FAST 1 (sum)
@Ademan
Ademan / traceback.txt
Created October 18, 2013 21:23
I assumed that any callable could be a view. Any idea what's going on here?
Starting subprocess with file monitor
Traceback (most recent call last):
File "/home/dan/Projects/env/projekt/bin/pserve", line 9, in <module>
load_entry_point('pyramid==1.5a1', 'console_scripts', 'pserve')()
File "/home/dan/Projects/env/projekt/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 51, in main
return command.run()
File "/home/dan/Projects/env/projekt/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 316, in run
global_conf=vars)
File "/home/dan/Projects/env/projekt/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 340, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
@Ademan
Ademan / table.py
Last active December 25, 2015 11:39
In [22]: x = ([["Foos", "Bars"], [1, 2], ["lasdfasdf", "abc"], [123.45678, 0.000000001]])
In [23]: table.write(sys.stdout, x)
+-----------+-------+
| Foos | Bars |
+-----------+-------+
| 1 | 2 |
+-----------+-------+
| lasdfasdf | abc |
+-----------+-------+
@Ademan
Ademan / transformer.py
Created September 12, 2013 04:23
Quick IPython session demonstrating.
In [112]: test
Out[112]: {'0': {'bar': 'bar', 'foo': '1.00'}, '1': {'bar': 'baz', 'foo': '2.00'}}
In [113]: transform(test)
Out[113]:
{'0': {'bar': 'bar', 'foo': Decimal('1.00')},
'1': {'bar': 'baz', 'foo': Decimal('2.00')}}
#! /bin/bash
tempfile=$(mktemp)
fullpath=$(readlink -f "$1")
echo "import(\"$fullpath\");" >> $tempfile
openscad $tempfile
rm $tempfile
function sumTotalAmounts(entity, options, result, error) {
var sum = 0;
var allRecords = [];
SDK.JQuery.retrieveMultipleRecords(entity, options,
function receive(data) {
for (var i = 0; i < data.length; i++) {
allRecords.push(data[i]);
if (typeof data[i].TotalAmount !== "undefined" && typeof data[i].TotalAmount.Value !== "undefined" && !isNaN(data[i].TotalAmount.Value)) {
sum += parseFloat(data[i].TotalAmount.Value);
}
@Ademan
Ademan / gist:4712487
Last active December 12, 2015 04:08 — forked from gua1/gist:4712451
#! /usr/bin/env python
import timeit
import rsync
import random
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO