Skip to content

Instantly share code, notes, and snippets.

View fangpenlin's full-sized avatar
🚀

Fang-Pen Lin fangpenlin

🚀
View GitHub Profile
#!/bin/sh
FILES=$(git diff HEAD^ HEAD --name-only --diff-filter=ACM | grep -e '\.py$')
for f in $FILES
do
# auto pep8 correction
autopep8 --in-place --ignore=E309,E501,W293 $f
done
import winsound
import time
# Base tune
D_BASE = 264
# How long a meter is
METRE = 500
DO = 0
@fangpenlin
fangpenlin / gist:640c0e1aa647d905c587
Created August 11, 2014 07:16
parse_setup ansible module
#!/usr/bin/python
import os
import sys
import ast
import textwrap
def parse_setup(setup_filename):
"""Parse setup.py and return args and keywords args to its setup
function call
import time
import threading
import pytest
import psycopg2
def acquire(conn, poll_period=0.1):
cur = conn.cursor()
while True:
import sys
fa = open(sys.argv[1], 'rt')
fb = open(sys.argv[2], 'rt')
keywords = {}
for line in fa.readlines():
keyword = line.strip()
keywords[keyword] = 0
header#header {
.navbar-inner {
padding-right: 0;
padding-left: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}
.container {
for line in file.readlines():
parts = line.split(':')
print parts[-2], parts[-1]
break
import csv
f2_ids = set()
f2 = open('file2.txt', 'rt')
f2_reader = csv.reader(f2)
for row in f2_reader:
f2_ids.add(row[0])
f1 = open('file1.txt', 'rt')
for line in f1.readlines():
@fangpenlin
fangpenlin / gist:6204313
Created August 11, 2013 10:21
Billy test errors on master branch
EEEEEEEEEEEEEEEE
======================================================================
ERROR: Failure: InvalidRequestError (Table 'charge_subscription' is already defined for this MetaData instance. Specify 'extend_existing=True' to redefine options and columns on an existing Table object.)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\GitHub\billy\env\lib\site-packages\nose-1.3.0-py2.7.egg\nose\loader.py", line 413, in loadTestsFromName
addr.filename, addr.module)
File "C:\GitHub\billy\env\lib\site-packages\nose-1.3.0-py2.7.egg\nose\importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "C:\GitHub\billy\env\lib\site-packages\nose-1.3.0-py2.7.egg\nose\importer.py", line 94, in importFromDir
@fangpenlin
fangpenlin / gist:6204321
Created August 11, 2013 10:24
Billy errors on import fixed branch
EEEEEEEEEEEEEEE
======================================================================
ERROR: Failure: ImportError (cannot import name sample_customer_2)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\GitHub\billy\env\lib\site-packages\nose-1.3.0-py2.7.egg\nose\loader.py", line 413, in loadTestsFromName
addr.filename, addr.module)
File "C:\GitHub\billy\env\lib\site-packages\nose-1.3.0-py2.7.egg\nose\importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "C:\GitHub\billy\env\lib\site-packages\nose-1.3.0-py2.7.egg\nose\importer.py", line 94, in importFromDir