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 pyodbc | |
import numpy as np | |
import datetime | |
import pandas | |
def processCursor(cur, dataframe=False): | |
datatypes = [] | |
colinfo = cur.description | |
for col in colinfo: | |
if col[1] == unicode: |
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
#Traceback.format_exc() or sys.exc_info() will yeild more info if thats what you want. | |
import traceback | |
import sys | |
try: | |
do_stuff() | |
except Exception, err: | |
print traceback.format_exc() | |
#or |
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
# http://stackoverflow.com/questions/2561418/how-to-comment-out-a-block-of-python-code-in-vim | |
Ctrl-v | |
select text | |
Shift-I | |
comment keys | |
Esc |
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
# Create a new repository on the command line | |
touch README.md | |
git init | |
git add README.md | |
git commit -m "first commit" | |
git remote add origin https://github.com/c0ldlimit/vimcolors.git | |
git push -u origin master | |
# Push an existing repository from the command line |
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
# http://stackoverflow.com/questions/987142/make-gitignore-ignore-everything-except-a-few-files | |
# Ignore everything | |
* | |
# But not these files... | |
!script.pl | |
!template.latex | |
!.gitignore |
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
# http://www.blog.pythonlibrary.org/2012/06/08/python-101-how-to-submit-a-web-form/ | |
# with urllib | |
import urllib | |
import urllib2 | |
import webbrowser | |
url = "http://duckduckgo.com/html" | |
data = urllib.urlencode({'q': 'Python'}) |
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
# http://aymanh.com/python-debugging-techniques | |
# http://nblock.org/2011/11/15/pdb-cheatsheet/ | |
import pdb; pdb.set_trace() |
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 math | |
x=float('nan') | |
math.isnan(x) |
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
# http://www.peterbe.com/plog/uniqifiers-benchmark | |
def f5(seq, idfun=None): | |
# order preserving | |
if idfun is None: | |
def idfun(x): return x | |
seen = {} | |
result = [] | |
for item in seq: |
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
from datetime import date, timedelta | |
d=date.today()-timedelta(days=days_to_subtract) |
OlderNewer