This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'),) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'),), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(tut)skyl@skylarwerk:~/Code/gui/slut$ python tcp_client.py | |
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted/internet/_sslverify.py:5: DeprecationWarning: the md5 module is deprecated; use hashlib instead | |
import itertools, md5 | |
You are running [slut v0.9.0] happy hacking! | |
2011-05-01 01:57:45.984 python[79813:903] *** __NSAutoreleaseNoPool(): Object 0x1014e3d50 of class NSCFData autoreleased with no pool in place - just leaking | |
fCoreAudioDriverUID AppleHDAEngineInput:1B,0,1,0:1 | |
Enabled joystick: OSCulator HID 1 | |
Enabled joystick: OSCulator HID 2 | |
-> Default interaction model loaded. | |
[F11] -> toggle fullscreen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import random | |
class ClusterCenters(object): | |
""" | |
>> d = ((0,0,0), (0,1,0), (0, 2, 0), (1,2,0), (55, 55,50), (50,50,50), (-100,-100,-100), (-80,-80,-100), (60,60,50)) | |
>> cc = ClusterCenters(d, 3) | |
[[55, 55, 50], [0, 1, 0], [-90, -90, -100]] | |
>> cc = ClusterCenters(d, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [61]: l | |
Out[61]: [1, 2, 3, False] | |
In [62]: i | |
Out[62]: 1 | |
In [63]: not i in l | |
Out[63]: False | |
In [64]: (not i) in l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
minmax = (value, low, high) -> Math.min Math.max(low, value), high | |
class ImageProcessor | |
constructor: (@img, parent=document.body) -> | |
@canvas = document.createElement("canvas") | |
@context = @canvas.getContext("2d") | |
@canvas.width = @img.width | |
@canvas.height = @img.height | |
parent.appendChild @canvas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import requests | |
exposure_liability_map = { | |
"people": [ | |
#("RESDQ", "All residents Day"), | |
("RESNQ", "Night Residents"), | |
("RESFDQ", "Female residents Day"), | |
("RESN4Q", "Night residents < 4yo"), | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# templatetags/kwacros.py - Support for macros in Django templates | |
# | |
# Based on snippet by | |
# Author: Michal Ludvig <michal@logix.cz> | |
# http://www.logix.cz/michal | |
# | |
# modified for args and kwargs by Skylar Saveland http://skyl.org | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = """ | |
Extensions are not supported. | |
Alphabetic phonenumbers eg 1888-FOR-RILZ are not supported. | |
Of course, you'll want to prevent injection by stripping html tags first. | |
It switches the numbers to international format (or sth) - suggestions welcome! | |
706 555 5001put some | |
ill formed(404) 555-1397text in here | |
+34712938479 to make it interesting...5 | |
404.555.1239. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% exec %} | |
try: | |
f = durs[duration] | |
f.field.widget.attrs['placeholder'] = duration | |
print f | |
except KeyError: | |
pass | |
{% endexec %} | |
OR |