Skip to content

Instantly share code, notes, and snippets.

@fvbock
fvbock / rolling_sum.sql
Created December 4, 2012 12:58
rolling sum in sql - window aggregates and CTE much faster than subquery or join
-- table
-- name number
-- 1 10
-- 2 20
-- 3 10
-- 4 30
-- ...
-- result
-- name amount
@fvbock
fvbock / cleanup_globals.py
Created September 1, 2011 13:29
clean up the globals to an initial state
dont_clean = [ 'initial_vars' ]
def cleanup():
print dont_clean
vars_to_free = [ k for k in set( globals().copy() ).difference( initial_vars.union( set( dont_clean ) ) ) ]
print vars_to_free,
for c in vars_to_free:
del globals()[ c ]
print "cleaned"