Skip to content

Instantly share code, notes, and snippets.

@coffindragger
coffindragger / models.py
Created September 21, 2011 15:17
Django Caching Notes
- Cache One Object (Active Homepage Layout)
by_pk or by_* (any field)
lazy queryset methods (loaded and cached when first used)
warm queryset methods (preloaded by warming)
- Cache Entire Table (Categories)
load entire table into in-memory hash, indexes on pk and slug
.cached manager for loading from cached, use_for_related=True
- Cache Busy Queries (Page 1 of Story List by Category)
@coffindragger
coffindragger / example
Created October 14, 2011 18:48
Base class for creating commandline python scripts using optparse
class MyScript(OptionParserScript):
usage = "Usage: %prog <command> [arguments]"
options = {
('-v','--verbose'): {'help':"Be verbose", 'action': 'store_true', 'default': False},
}
def main(self, *args, **kwargs):
import pprint
pprint.pprint(args)
pprint.pprint(kwargs)
- csky/admin/defaultmodeladmin.py admin to pair with defaultmodel/slugmodel
- csky/models.py ActiveModel,DefaultModel,UserModel,SlugModel
- csky/middleware/ssl_redirects.py includes @https_required decorator redirect midddlware
- csky/decorators.py @https_required
- csky/forms.py
Abstract
A 54" TV sits blank in a room full of programmers who would happily script up visualizations and demos. A device is needed to provide video source for the display, that can be installed easily on the wall near the TV, either surreptisously, or perhaps artfully.
Fullscreen webkit browser, displaying HTML5/JS visualizations.
Dashboard Gadget Ideas
- twitter feed
- github activity feed
- activecollab activity graphs
- rss feed
- graphs of commits/checkouts
- upcoming beer vote
- bus schedules
@coffindragger
coffindragger / jquery.plugintemplate.js
Created October 30, 2011 21:29
jQuery Plugin Template
(function($) {
var PLUGIN = "" //TODO: The name of the plugin
var methods = {
init: function (config) {
var options = {
//TODO: Default Options
@coffindragger
coffindragger / game.css
Created December 21, 2011 18:58
Simplistic Chess Vision
body {
background: beige;
}
#display_container {
float: left;
}
#turn_container {
float: left;
#!/usr/bin/env python
import sys
import os
import optparse
class ExpandTemplateCommand(object):
def run(self, *args):
parser = optparse.OptionParser()
@coffindragger
coffindragger / gist:1754996
Created February 6, 2012 21:25
Gambling Chaturaji
Each player needs $4.50 in the following change:
10 x Quarters
2 x Dollars
To make a move, you must roll 2 4-sided dice.
You may make 0, 1 or 2 moves based on the dice rolls shown:
1 - Boat
2 - Knight
3 - Rook
Website allows users to create and manage accounts.
- user manages pubkey
- user is assigned a Git Repo
- can review Stats and Hand Histories
- can refill an empty account with credits 1/day.
User creates Code and pushes to Git Repo.
- using their pubkey to remote: git@sitename.tld:username.git