Skip to content

Instantly share code, notes, and snippets.

View dakrauth's full-sized avatar

David A Krauth dakrauth

View GitHub Profile
@dakrauth
dakrauth / weather
Created June 9, 2011 17:37
Command line weather lookup script
#!/usr/bin/env python
import sys
import urllib2
from optparse import OptionParser
from xml.etree import cElementTree as ElementTree
#-------------------------------------------------------------------------------
def get_data(elem):
return dict([(e.tag, e.attrib['data']) for e in elem.getchildren()])
@dakrauth
dakrauth / problems.txt
Created January 18, 2012 17:28
Problem solving flowchart
+---------+
| START |
+---------+
|
V
YES +------------+ NO
+---------------| DOES THE |---------------+
| | DAMN THING | |
V | WORK? | V
+------------+ +------------+ +--------------+ NO
@dakrauth
dakrauth / boundaries.py
Created September 5, 2018 17:28
Compute monthly date/time boundaries
from calendar import monthrange
from datetime import datetime, timedelta
def month_boundaries(year, month):
start = datetime(year, month, 1)
month_days = monthrange(year, month)[1]
return [start, start + timedelta(days=month_days, seconds=-1)]
@dakrauth
dakrauth / git-scenarios.md
Last active November 5, 2019 20:00
git scenarios

Inadvertent Changes To Branch

git branch feature                # create new branch without checking out
git reset --hard origin/branch    # reset current to origin, blowing away changes now in `feature`
git checkout feature

Misc