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
>>> class Foo(object): | |
... mylist = [] | |
... | |
>>> Foo.mylist.append("foo") | |
>>> f = Foo() | |
>>> f.mylist.append("bar") | |
>>> f.mylist | |
['foo', 'bar'] | |
>>> |
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 sys, os, os.path | |
sys.path.append('.') | |
# Weird hack, __import__("a.b.c") returns module a unless fromlist is non-empty, then it returns module c | |
filename = __import__(sys.argv[1], fromlist=["whatever"]).__file__ | |
os.system('subl ' + os.path.dirname(filename)) |
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
results = [ | |
(foo, bar*2) | |
for (foo, bar) | |
in thing.container.items() | |
if foo not in ("exclusion", "list") and | |
bar > 100 | |
] |
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://timothyfitz.wordpress.com/feed/] | |
name = Timothy Fitz | |
[http://progrium.com/blog/atom.xml] | |
name = Jeff Lindsay | |
[http://jf.posterous.com/rss.xml] | |
name = Joël Franusic | |
[http://feeds.feedburner.com/andymoore/mainfeed] |
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
#!/cygdrive/c/Users/timothy/Packages/pypy-1.9/pypy.exe | |
#!/cygdrive/c/Python27/python.exe | |
import platform | |
print "Running on", platform.python_implementation() | |
import pyglet | |
pyglet.options['debug_gl'] = False |
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
import ctypes, time, array | |
count = 64 ** 2 * 24 | |
t0 = time.time() | |
for x in range(100): | |
v = [0] * count | |
t1 = time.time() | |
print "python list", (t1-t0)*10, 'ms' |
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
>>> def foo(arg, optional='bar'): pass | |
... | |
>>> foo(optional='baz') | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: foo() takes at least 1 argument (1 given) |
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
Sublime Text Cheat Sheet: | |
Cmd-F to search, Alt-Enter to multiselect | |
Cmd-Ctrl-G: "Find_all_under" | |
Ctrl+Shift+Up/Down: multiselect line | |
Windows: | |
Cmd+Shift+#: Changes number of windows | |
Ctrl+Shift+#: Move window to group # |
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
My traceroute [v0.71] | |
mbp-2.local (0.0.0.0) Wed Apr 25 09:49:48 2012 | |
Keys: Help Display mode Restart statistics Order of fields quit | |
Packets Pings | |
Host Loss% Snt Last Avg Best Wrst StDev | |
1. 10.0.1.1 0.0% 1517 0.7 0.7 0.6 35.4 1.4 | |
2. 192.168.1.1 0.0% 1516 1.0 1.0 0.8 9.2 0.6 | |
3. 74.108.111.1 1.8% 1516 4.6 6.4 4.3 117.2 5.6 | |
4. G0-14-1-5.NYCMNY-LCR-21.verizon-gni.net 2.0% 1516 6.3 7.5 5.0 69.4 5.8 | |
5. 130.81.151.228 |
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
$ traceroute google.com | |
traceroute: Warning: google.com has multiple addresses; using 74.125.226.200 | |
traceroute to google.com (74.125.226.200), 64 hops max, 52 byte packets | |
1 10.0.1.1 (10.0.1.1) 2.055 ms 0.698 ms 0.580 ms | |
2 192.168.1.1 (192.168.1.1) 1.998 ms 0.954 ms 0.818 ms | |
3 74.108.111.1 (74.108.111.1) 5.601 ms 5.420 ms 4.968 ms | |
4 g0-14-1-5.nycmny-lcr-21.verizon-gni.net (130.81.177.80) 6.173 ms 5.833 ms 5.347 ms | |
5 130.81.151.228 (130.81.151.228) 6.291 ms 6.501 ms 7.297 ms | |
6 0.so-3-2-0.xt2.nyc4.alter.net (152.63.9.249) 5.849 ms 6.507 ms 6.479 ms | |
7 tengige0-7-2-0.gw8.nyc4.alter.net (152.63.21.129) 7.606 ms |
NewerOlder