Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# Crontab setting to bother you during wokring hours on weekdays
# 0 9,10,11,12,13,14,15,16 * * 1,2,3,4,5 /usr/local/bin/exercise_helper.py
from random import choice, randrange
from datetime import date
from math import ceil
import tkMessageBox
@mazelife
mazelife / spinnaker
Created September 16, 2013 21:22
Selects 10 product/name pairs for each vendor across all vendors.
select product, url from (
select row_number() over (partition by vendor order by product desc) as r, t.* from
(select vendor.name as vendor, product.name as product, coalesce(shelf.detail_url,shelf.buy_url, null) as url from shelf
join product on product.id = shelf.product_id
join vendor on vendor.id = shelf.vendor_id) as t) as x
where x.r <= 10
@mazelife
mazelife / gist:1229905
Created September 20, 2011 18:36
DJDT settings
def _djdt_check(request):
# Don't show the DJDTB in the admin.
if request.path.startswith("/admin/"):
return False
return True
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TOOLBAR_CALLBACK': _djdt_check
}
@mazelife
mazelife / gist:1132000
Created August 8, 2011 15:47
A thing you can do with javascript's function.length
// Implementation of the router pattern using function.length
var add_two_things = function(a, b) {
return a + b
}
var add_three_things = function(a, b, c) {
return a + b + c
}
var get_router = function() {