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
| 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 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 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 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
| 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 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 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 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
| 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 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
| s = """Gur Mra bs Clguba, ol Gvz Crgref | |
| Ornhgvshy vf orggre guna htyl. | |
| Rkcyvpvg vf orggre guna vzcyvpvg. | |
| Fvzcyr vf orggre guna pbzcyrk. | |
| Pbzcyrk vf orggre guna pbzcyvpngrq. | |
| Syng vf orggre guna arfgrq. | |
| Fcnefr vf orggre guna qrafr. | |
| Ernqnovyvgl pbhagf. | |
| Fcrpvny pnfrf nera'g fcrpvny rabhtu gb oernx gur ehyrf. |
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 gen(): | |
| ... yield 1 | |
| ... yield 2 | |
| ... yield 3 | |
| ... | |
| >>> for i in gen(): | |
| ... print i | |
| ... | |
| 1 | |
| 2 |
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 two_sort(ex): | |
| ex_copy = ex[:] | |
| ex.sort(key=lambda tup: tup[1]) | |
| ex.reverse() | |
| print "Ex: ", ex | |
| ex_copy.sort(key=lambda tup: tup[1], reverse=True) | |
| print "Copy:", ex_copy |
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
| # This file must be used with "source bin/activate" *from bash* | |
| # you cannot run it directly | |
| deactivate () { | |
| unset pydoc | |
| # reset old environment variables | |
| if [ -n "$_OLD_VIRTUAL_PATH" ] ; then | |
| PATH="$_OLD_VIRTUAL_PATH" | |
| export PATH |
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 naive_add(lis): | |
| total = 0 | |
| for elem in lis: | |
| total += elem | |
| return total | |
| def recursive_add(lis): | |
| if len(lis) == 1: | |
| return lis[0] | |
| elif len(lis) == 0: |