This file contains hidden or 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
#!/usr/bin/env python3 | |
import sys | |
to_smallcaps = { | |
"a": "ᴀ", | |
"b": "ʙ", | |
"c": "ᴄ", | |
"d": "ᴅ", | |
"e": "ᴇ", | |
"f": "ꜰ", |
This file contains hidden or 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 collections import deque | |
def fizzbuzz(n): | |
return "f f bf fb f i i ui iu i z z zz zz z z z zz zz z b u z z "[n % 15 :: 15].strip() or n | |
if __name__ == "__main__": | |
deque((print(fizzbuzz(n)) for n in range(100)), maxlen=0) |
This file contains hidden or 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 https://wiki.python.org/moin/UdpCommunication modified for Statsd + debugging usage | |
import datetime | |
import socket | |
UDP_IP = "127.0.0.1" | |
UDP_PORT = 8125 | |
sock = socket.socket( | |
socket.AF_INET, # Internet | |
socket.SOCK_DGRAM) # UDP |
This file contains hidden or 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
scala> // "return" binds to the nearest method, not function literals. | |
scala> def myfun() { | |
| val foo = List(1, 2, 3); | |
| val bar = foo map { x => | |
| println(x) | |
| if (x == 2) return | |
| } | |
| println("Dead code") | |
| } |
This file contains hidden or 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
# http://en.wikipedia.org/wiki/Strategy_pattern | |
# class_strategy.py: | |
# class IntegerStrategy(object): | |
# @staticmethod | |
# def add(a, b): | |
# ... | |
# class FloatStrategy(object): | |
# @staticmethod | |
# def add(a, b): |
This file contains hidden or 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
#!/usr/bin/env python | |
import os | |
import sys | |
from time import sleep | |
usable_files = ( | |
'.py', | |
'.php', | |
'.yaml', |
This file contains hidden or 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 sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.orm import relationship, sessionmaker | |
import sqlalchemy as sa | |
# >>> sa.__version__ | |
# '0.7.9' | |
engine = sa.create_engine('sqlite:///cartesian_subquery.db', echo=True) | |
Base = declarative_base() |
This file contains hidden or 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
diff -r a73a349ee7ec lib_pypy/pypy_test/test_transaction.py | |
--- a/lib_pypy/pypy_test/test_transaction.py Wed Mar 06 23:46:03 2013 +0100 | |
+++ b/lib_pypy/pypy_test/test_transaction.py Mon Mar 18 15:55:30 2013 -0400 | |
@@ -76,6 +76,27 @@ | |
assert num_foos == 1, lsts | |
+def test_number_of_transactions_reported(): | |
+ before = transaction.number_of_transactions_in_last_run() | |
+ transaction.run() |
This file contains hidden or 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 cStringIO import StringIO | |
log_file = StringIO( | |
'posix_timestamp,elapsed,sys,user,queries,query_time,rows,' | |
'accountid,userid,contactid,level,silo,method\n' | |
'1343103150,0.062353,0,4,6,0.01690,3,' | |
'12345,1,-1,3,invoice_InvoiceResource,search\n' | |
) | |
import pandas as pd | |
from datetime import datetime |
This file contains hidden or 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
$ hg parent | |
changeset: 61237:3b4ede83d81c | |
branch: stm-thread-2 | |
tag: tip | |
user: Armin Rigo <[email protected]> | |
date: Thu Feb 14 14:49:25 2013 +0000 | |
summary: Unclear why it occurs here and not on "default", but we need to prevent multiple #includes of this file | |
[translation:ERROR] Error: |
NewerOlder