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
Victory Bot is so excited for you! | |
Want more/better gifs? Open a pull request! | |
Bot driving you crazy? It responds to `@victorybot mute` which will mute it (for everyone). | |
Unmuting requires a password. | |
It also responds to PMs, whenever you need a little pick-me-up. |
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 re | |
import timeit | |
import string | |
double = re.compile(r"([a-z])(\1)") | |
double_var = double = re.compile(r"([a-z])\1") | |
single = re.compile(r"([a-z])") | |
# Make this string raw! |
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
WORDS = (word.strip() for word in open('sowpods.txt').readlines()) | |
def find_palindromes(): | |
pals = [] | |
for word in WORDS: | |
mid = len(word) / 2 | |
if word[:mid] == "".join(reversed(word[-mid:])): | |
pals.append(word) | |
longest = max(pals, key=len) | |
return longest |
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 dis | |
def ifbuzz(x): | |
if x % 5 == 0 and x % 3 == 0: | |
print "FizzBuzz" | |
else: | |
if x % 3 == 0: | |
print "Fizz" | |
else: | |
if x % 5 == 0: | |
print "Buzz" |
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
Tune-up prep | |
Macs | |
Move everything in .bash_profile to .bashrc | |
Have .bash_profile source .bashrc: | |
if [ -f ~/.bashrc ]; then | |
source ~/.bashrc | |
fi | |
Install Xcode + Command Line Tools |
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
(byterun_env)byterun [assorted-fixes $%] ⚲ tox -- tests.test_basic:TestIt | |
GLOB sdist-make: /Users/afk/Dropbox/python/byterun_env/byterun/setup.py | |
py27 inst-nodeps: /Users/afk/Dropbox/python/byterun_env/byterun/.tox/dist/Byterun-1.0.zip | |
py27 runtests: commands[0] | nosetests tests.test_basic:TestIt | |
.......................... | |
---------------------------------------------------------------------- | |
Ran 26 tests in 0.280s | |
OK | |
py33 inst-nodeps: /Users/afk/Dropbox/python/byterun_env/byterun/.tox/dist/Byterun-1.0.zip |
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
>>> class FalseContext(object): | |
... def __enter__(self): | |
... l.append('i') | |
... return self | |
... def __exit__(self, exc_type, exc_val, exc_tb): | |
... l.append('o') | |
... return False | |
... | |
>>> class TrueContext(object): | |
... def __enter__(self): |
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
>>> class Thing(object): | |
... def __init__(self, name, description): | |
... self.name = name | |
... self.desc = description | |
... | |
>>> b = Thing('box', 'empty') | |
>>> c = Thing('cat', 'fuzzy') | |
>>> collection = {'box': b, 'cat' : c} | |
>>> collection['box'] | |
<__main__.Thing object at 0x1073a2150> |
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
>>> class Test(object): | |
... var = 7 | |
... def __init__(self): | |
... self.ivar = 2 | |
... | |
>>> t = Test() | |
>>> s = Test() | |
>>> t.__dict__ | |
{'ivar': 2} | |
>>> t.var |
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
FAIL: test_generator_from_generator2 (tests.test_functions.TestGenerators) | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/Users/afk/Dropbox/python/byterun_env/byterun/tests/test_functions.py", line 239, in test_generator_from_generator2 | |
""") | |
File "/Users/afk/Dropbox/python/byterun_env/byterun/tests/vmtest.py", line 86, in assert_ok | |
self.assert_same_exception(vm_exc, py_exc) | |
File "/Users/afk/Dropbox/python/byterun_env/byterun/tests/vmtest.py", line 96, in assert_same_exception | |
self.assertEqual(str(e1), str(e2)) | |
nose.proxy.AssertionError: AssertionError: "unsupported operand type(s) for *: 'NoneType' and 'NoneType'" != 'None' |