Skip to content

Instantly share code, notes, and snippets.

View thewhitetulip's full-sized avatar

Suraj Patil thewhitetulip

View GitHub Profile
@thewhitetulip
thewhitetulip / tasks.py
Last active March 31, 2017 05:33
tasks.py
import sys
arguments = sys.argv
arguments = arguments[1:]
command = arguments[0]
help="""
usage:
tasks.py add "learn python" "write code"
tasks.py delete [title]
@thewhitetulip
thewhitetulip / berkshire.py
Created December 12, 2015 13:23
A simple python script to to create links to download shareholder letts of bershire hathaway
start_year = 1977
end_year = 2015
ltr_year = 2004
link = "http://berkshirehathaway.com/letters/"
for i in range(start_year, end_year):
if i <ltr_year:
print(link+str(i)+".html")
else:
print(link+str(i)+"ltr.pdf")
@thewhitetulip
thewhitetulip / .short_pwd.py
Created August 29, 2015 14:26
Trim the username on the bash terminal
import os
from commands import getoutput
from socket import gethostname
hostname = gethostname()
username = os.environ['USER']
pwd = os.getcwd()
homedir = os.path.expanduser('~')
pwd = pwd.replace(homedir, '~', 1)
if len(pwd) > 30:
pwd = pwd[:10]+'...'+pwd[-20:] # first 10 chars+last 20 chars
@thewhitetulip
thewhitetulip / reminder.py
Last active October 13, 2015 23:11
A small python script to notify which new episodes are airing today
# -*- coding: utf-8 -*-
#/usr/bin/python3
"""
flash
April 21, 28, may 5, may 12, may 19
arrow
april 22, 29, may 6, may 13
person of interest
@thewhitetulip
thewhitetulip / mysqldb_error.py
Last active August 29, 2015 14:10
The curious case of %d in cursor.execute
#!/bin/python
def insert_post(post):
try:
cursor.execute("select max(post_id) from post_master")
fetched = cursor.fetchone()
if fetched is None:
post_id=0
else:
post_id = fetched+1
cursor.execute('insert into post_master\