Skip to content

Instantly share code, notes, and snippets.

@PamelaM
PamelaM / install_python.sh
Created September 1, 2011 15:33 — forked from jgumbley/install_python.sh
setup python 2.7.1 on CENTOS 5.* server
# wget -O install_python.sh https://gist.github.com/raw/777001/install_python.sh
# chmod +x install_python.sh
# ./install_python.sh
#!/bin/sh
echo "******************************************"
echo "Configure Centos box with a recent version"
echo "of Python. "
echo " - jgumbley 12/jan/11"
"""
Sample Output
$ python generatedtests.py -v
test_actual_one (__main__.ActualTest) ... ok
test_actual_two (__main__.ActualTest) ... FAIL
======================================================================
FAIL: test_actual_two (__main__.ActualTest)
----------------------------------------------------------------------
Traceback (most recent call last):
@PamelaM
PamelaM / For Max
Last active August 29, 2015 14:21
http://www.pythoncentral.io/how-to-traverse-a-directory-tree-in-python-guide-to-os-walk/
import os
import shutil
input_directory = "FROM_BIG_DEPOSIT"
output_directory = "CLEAN_BIG_DEPOSIT"
def _src_2_dst(src_directory, src_name):
'''
examplish:
@PamelaM
PamelaM / gist:106660e03dbdb06b9d4f7ca1416a3304
Created December 1, 2017 13:49
Advent of Code 2017 - Challenge #1
>>> TEXT = '9513446799636685297929646689682997114316733445451534532351778534251427172168183621874641711534917291674333857423799375512628489423332297538215855176592633692631974822259161766238385922277893623911332569448978771948316155868781496698895492971356383996932885518732997624253678694279666572149831616312497994856288871586777793459926952491318336997159553714584541897294117487641872629796825583725975692264125865827534677223541484795877371955124463989228886498682421539667224963783616245646832154384756663251487668681425754536722827563651327524674183443696227523828832466473538347472991998913211857749878157579176457395375632995576569388455888156465451723693767887681392547189273391948632726499868313747261828186732986628365773728583387184112323696592536446536231376615949825166773536471531487969852535699774113163667286537193767515119362865141925612849443983484245268194842563154567638354645735331855896155142741664246715666899824364722914296492444672653852387389477634257768229772399416521198625393426443499223611843
@PamelaM
PamelaM / aoc_2017_day2.py
Created December 2, 2017 12:48
Advent of code 2017, 2
DATA = """4168 3925 858 2203 440 185 2886 160 1811 4272 4333 2180 174 157 361 1555
150 111 188 130 98 673 408 632 771 585 191 92 622 158 537 142
5785 5174 1304 3369 3891 131 141 5781 5543 4919 478 6585 116 520 673 112
5900 173 5711 236 2920 177 3585 4735 2135 2122 5209 265 5889 233 4639 5572
861 511 907 138 981 168 889 986 980 471 107 130 596 744 251 123
2196 188 1245 145 1669 2444 656 234 1852 610 503 2180 551 2241 643 175
2051 1518 1744 233 2155 139 658 159 1178 821 167 546 126 974 136 1946
161 1438 3317 4996 4336 2170 130 4987 3323 178 174 4830 3737 4611 2655 2743
3990 190 192 1630 1623 203 1139 2207 3994 1693 1468 1829 164 4391 3867 3036
116 1668 1778 69 99 761 201 2013 837 1225 419 120 1920 1950 121 1831
@PamelaM
PamelaM / aoc_2017_day4.py
Created December 4, 2017 13:42
Advent of Code 2017 Day 4
PHRASES = """vxjtwn vjnxtw sxibvv mmws wjvtxn icawnd rprh
fhaa qwy vqbq gsswej lxr yzl wakcige mwjrl
bhnlow huqa gtbjc gvj wrkyr jgvmhj bgs umo ikbpdto
drczdf bglmf gsx flcf ojpj kzrwrho owbkl dgrnv bggjevc
ndncqdl lncaugj mfa lncaugj skt pkssyen rsb npjzf
kdd itdyhe pvljizn cgi
jgy pyhuq eecb phwkyl oeftyu pyhuq hecxgti tpadffm jgy
zvc qdk mlmyj kybbh lgbb fvfzcer frmaxa yzgw podt dbycoii afj
zfr msn mns leqem frz
golnm ltizhd dvwv xrizqhd omegnez nan yqajse lgef
@PamelaM
PamelaM / aoc_2017_day5.py
Created December 5, 2017 16:30
Advent of Code 2017, Day 5
MAZE = """0
0
1
2
0
1
0
2
-2
-6
@PamelaM
PamelaM / aoc_2017_day6.py
Created December 6, 2017 14:57
Advent of Code 2017, Day 6
INPUT = """14 0 15 12 11 11 3 5 1 6 8 4 9 1 8 4"""
def balance(banks):
max_blocks = max(banks)
for idx, v in enumerate(banks):
if v == max_blocks:
break
blocks = banks[idx]
banks[idx] = 0
@PamelaM
PamelaM / aoc_2017_day7.py
Created December 7, 2017 22:08
Advent of Code 2017, day 7
TEST = """pbga (66)
xhth (57)
ebii (61)
havc (66)
ktlj (57)
fwft (72) -> ktlj, cntj, xhth
qoyq (66)
padx (45) -> pbga, havc, qoyq
tknk (41) -> ugml, padx, fwft
jptl (61)
@PamelaM
PamelaM / aoc_2017_day8.py
Created December 8, 2017 17:07
Advent of Code 2017, Day 8
TEST = """pb inc 5 if a > 1
a inc 1 if b < 5
c dec -10 if a >= 1
c inc -20 if c == 10"""
INPUT = """uz inc 134 if hx > -10
qin dec -300 if h <= 1
ubi inc 720 if qin <= 306
si inc -108 if he <= 1
hx inc 278 if hx <= -10