Skip to content

Instantly share code, notes, and snippets.

View jimjkelly's full-sized avatar
💭
Statusing

Jim Kelly jimjkelly

💭
Statusing
View GitHub Profile
@jimjkelly
jimjkelly / python-encoding.py
Created July 22, 2013 15:43
This gist shows how to properly handle encoding issues in Python 2.x
# All data coming across the intarwebs is encoded in a file encoding.
# This could be ASCII, UTF-8, UTF-16, Shift-JIS, etc. To properly
# handle data, you need to know the encoding. Thankfully on the web
# the de facto standard seems to be moving towards UTF-8.
#
# In order to safely deal with data - you want to decode this encoded
# data (referred to in Python world as a byte string) from its
# encoding to the generic unicode data type - Python can
# safely work with this in all situations. Let's pretend we
# have some data foo we have just read in from the intarwebs
@jimjkelly
jimjkelly / gist:5832532
Created June 21, 2013 16:42
I needed to take an existing git repo, and break each of its sub directories into their own independent repos, perserving history. Easy - but I had the added requirement that I wanted the master branch in the new repo to be pristine, with only an empty initial check-in, and have all the existing check-ins be in a dev branch. For the sake of this…
git clone [email protected]:bar.git
cd bar
git filter-branch --subdirectory-filter foo -- --all
git branch -M master hold
git checkout --orphan master
git rm -rf *
git commit --allow-empty -m "Initial root commit"
git checkout -b dev
git checkout hold
git rebase --onto dev master