Skip to content

Instantly share code, notes, and snippets.

import time
from contextlib import contextmanager
class TimedResult(object):
def __init__(self):
self.started = None
self.stopped = None
def start(self):
def get_dependent_tables_for(table, referenced=None):
referenced = referenced or set([table])
for fk in table.foreign_keys:
other_table = fk.column.table
if other_table not in referenced:
referenced.add(other_table)
get_dependent_tables_for(other_table, referenced=referenced)
@mdellavo
mdellavo / taskpool.py
Created April 24, 2017 00:28
asyncio task pool
import asyncio
from asyncio.queues import Queue
TERMINATOR = object()
class TaskPool(object):
def __init__(self, loop, num_workers):
self.loop = loop
self.tasks = Queue(loop=self.loop)
@mdellavo
mdellavo / .diff
Last active February 21, 2017 18:24
diff --git a/scumbag/scumbag.go b/scumbag/scumbag.go
index 1314abe..195c7e1 100644
--- a/scumbag/scumbag.go
+++ b/scumbag/scumbag.go
@@ -241,6 +241,9 @@ func (bot *Scumbag) processCommands(line *irc.Line) {
func (bot *Scumbag) getCommand(line *irc.Line) (string, string) {
fields := strings.Fields(line.Args[1])
+ if len(fields) == 0 {
+ return "", ""
import inspect
import pkgutil
import importlib
def find_subsclasses(package, baseclass):
for importer, modname, ispkg in pkgutil.iter_modules(package.__path__):
if ispkg:
continue
module = importlib.import_module(package.__name__ + "." + modname, package.__name__)
alias git-merge='git checkout master && git merge -'
alias git-push='git push origin HEAD'
alias git-undo='git reset HEAD~'
alias git-up='git checkout master && git pull && git checkout - && git rebase -i master && git push -f origin HEAD'
servers = (
{
address = "rubiks.pulsar-zone.net";
chatnet = "rubiks";
port = "9999";
use_ssl = "yes";
verify_ssl = "no";
}
);
@mdellavo
mdellavo / convert-pgp-to-ssh.sh
Created September 15, 2016 13:33
Convert PGP Public Key to OpenSSH
# import the public key
gpg --import ../alice.asc
gpg --export $KEYID | openpgp2ssh $KEYID
marc@quimby:~/Downloads $ grep -i liquor YourMoney_Agency_Purchasing.csv
2015,June 30 2015,HUMAN SERVICES,"Public Works, Park Equipment, And Construction Services",EAST COAST LIQUORS INC RESTOREPRO,$5777.00
2009,June 30 2009,ENVIRONMENTAL PROTECTION,Miscellaneous Commodities And Services,WEST CREEK LIQUOR & DELI,$171.00
2008,June 30 2008,ENVIRONMENTAL PROTECTION,"Food, Equipment, And Related Services",WEST CREEK LIQUOR & DELI,$153.00
2008,June 30 2008,LAW AND PUBLIC SAFETY,Rental And Leasing Services,TR LIQUOR LLC T/A HOLIDAY INN OF TOMS RIVER,$5268.00
2007,June 30 2007,ENVIRONMENTAL PROTECTION,Miscellaneous Commodities And Services,PINE BAY LIQUORS INC,$289.00
2007,June 30 2007,LAW AND PUBLIC SAFETY,Miscellaneous Commodities And Services,TR LIQUOR LLC T/A HOLIDAY INN OF TOMS RIVER,$1000.00
2007,June 30 2007,LAW AND PUBLIC SAFETY,Rental And Leasing Services,TR LIQUOR LLC T/A HOLIDAY INN OF TOMS RIVER,$4286.00
2006,June 30 2006,LAW AND PUBLIC SAFETY,Miscellaneous Commodities And Services,TR LIQUOR LLC T/A HOL
marc@quimby:~/Downloads $ grep -i CODINOS YourMoney_Agency_Purchasing.csv
2014,June 30 2014,TREASURY,"Food, Equipment, And Related Services",CODINOS ITALIAN FOODS INC,$17664.00
2012,June 30 2012,TREASURY,"Food, Equipment, And Related Services",CODINOS ITALIAN FOODS INC,$18750.00
2011,June 30 2011,TREASURY,"Food, Equipment, And Related Services",CODINOS ITALIAN FOODS INC,$13072.00
2010,June 30 2010,TREASURY,"Food, Equipment, And Related Services",CODINOS ITALIAN FOODS INC,$33075.00
2009,June 30 2009,TREASURY,"Food, Equipment, And Related Services",CODINOS ITALIAN FOODS INC,$75472.00
2008,June 30 2008,TREASURY,"Food, Equipment, And Related Services",CODINOS ITALIAN FOODS INC,$6840.00
2007,June 30 2007,TREASURY,"Food, Equipment, And Related Services",CODINOS ITALIAN FOODS INC,$16275.00
2006,June 30 2006,TREASURY,"Food, Equipment, And Related Services",CODINOS ITALIAN FOODS INC,$13225.00
2005,June 30 2005,TREASURY,"Food, Equipment, And Related Services",CODINOS ITALIAN FOODS INC,$6750.00