Skip to content

Instantly share code, notes, and snippets.

View mkocikowski's full-sized avatar

Mik Kocikowski mkocikowski

View GitHub Profile
@mkocikowski
mkocikowski / gist:59971a1bcf207628134c
Created May 9, 2014 03:19
.bash_profile for maven and jdk 7 mavericks
export M2_HOME=/usr/local/share/apache-maven-3.2.1
export PATH=$PATH:$M2_HOME/bin
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
@mkocikowski
mkocikowski / gist:9283114
Created March 1, 2014 01:00
Take str or unicode in, return utf-8 encoded string, with 'bad' characters stripped
def utf8(data):
"""Takes in str or unicode, returns utf-8 string, stripping invalid chars."""
if type(data) not in [str, unicode]:
raise TypeError("'data' must be str or unicode")
try:
if type(data) is unicode:
s = data.encode('utf-8', 'ignore')
elif type(data) is str: