Skip to content

Instantly share code, notes, and snippets.

Skylar Saveland skyl

Block or report user

Report or block skyl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@skyl
skyl / gist:866920
Created Mar 12, 2011
shruti system
View gist:866920
In [35]: shrutis = {
....: 0: (1/Decimal('1'),),
....: 1: (256/Decimal('243'), 16/Decimal('15')),
....: 2: (10/Decimal('9'), 9/Decimal('8')),
....: 3: (32/Decimal('27'), 6/Decimal('5')),
....: 4: (5/Decimal('4'), 81/Decimal('64')),
....: 5: (4/Decimal('3'),),
....: # 27/Decimal('20'),
....: 6: (45/Decimal('32'), 729/Decimal('512')),
....: 7: (3/Decimal('2'),),
@skyl
skyl / gist:849500
Created Mar 1, 2011
stashing a mediocre idea
View gist:849500
import djredis.models as djr
class MyMod(models.Model, djr.DredisMixin):
#...
currency = models.CharField(max_length=3)
djr_currency = djr.String()
cache_fields = (('currency', 'djr_currency'),)
@skyl
skyl / gist:778973
Created Jan 14, 2011
rough openlayers example
View gist:778973
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>
Example Site : Welcome
</title>
View gist:775697
@transaction.commit_on_success
def _action(action, o):
getattr(o,action)()
o.is_processing = False
o.save()
def _bulk_action(action, objs):
for o in objs:
_action(action,o)
@skyl
skyl / gist:764182
Created Jan 3, 2011
TxBl api sample
View gist:764182
v1 = Stepper(
[60,30,30,30,50,N] * 2 + [120,40,40,120,40,40] * 2
)
n1 = snd(cycle(
[R(60,48)]
))
d1 = rhodes_f()
player1 = Player(d1, n1, v1, interval=sixteenth)
player1.startPlaying()
View gist:753900
from django import db
from django.db import connection
from django.conf import settings
class LoggingMiddleware(object):
def process_request(self, request):
"""Logs the POST (and resets the queries if DEBUG)"""
View Tomjunk
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
@skyl
skyl / gist:423540
Created Jun 3, 2010
djongobjomposition
View gist:423540
from django.db import models
from mymongo.models import Mongo
class M(models.Model):
...
mongo = Mongo()
View djredis_iface.py
from djredis.models import DredisMixin
import djredis.models
class Blog(models.Model, DredisMixin): # inherit from the mixin class
author = models.ForeignKey('Author')
title = models.CharField(max_length=200)
# declaratively add your redis fields
viewcount = djredis.models.Counter()
View gist:297913
'''
keys:
::site-wide keys::
'users'
The set of usernames.
r.sismember('users', 'foouser')
'groups'
List of all groups
'groups_incr'
You can’t perform that action at this time.