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
(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
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
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
<!DOCTYPE html> | |
<html lang="en-us"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
<title> | |
Example Site : Welcome | |
</title> | |
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
@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) |
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
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() |
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
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)""" |
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
<!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"> |
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
from django.db import models | |
from mymongo.models import Mongo | |
class M(models.Model): | |
... | |
mongo = Mongo() | |