Skip to content

Instantly share code, notes, and snippets.

View lukem's full-sized avatar

Luke Mewburn lukem

View GitHub Profile
@lukem
lukem / boost-1-56-recursive-directory.cpp
Created January 6, 2019 00:31
boost 1.56 changed Boost.Filesystem recursive_directory_iterator
/*
* Workaround Boost.Filesystem V3 behaviour change in boost 1.56.
* See original at http://thisthread.blogspot.com/2011/07/using-recursivedirectoryiterator.html
*/
void plainListTree(boost::filesystem::path path) // 1.
{
dump(path, 0);
boost::filesystem::recursive_directory_iterator it = createRIterator(path);
@lukem
lukem / iso8601-date-parsing.py
Created October 5, 2017 22:30
Parse ISO-8601 dates into UTC seconds since epoch
import calendar
import dateutil.parser
import time
def parseIso8601(timestr):
"""Parse `timestr` into UTC seconds since epoch."""
dt = dateutil.parser.parse(timestr)
if dt.tzinfo:
return calendar.timegm(dt.utctimetuple())
else:
@lukem
lukem / readline-6-workaround.py
Created January 12, 2017 00:37
python readline 6.0 portability fix
# readline 6.0 emits unexpected escape characters
# in rl_initialize() if TERM=xterm (and some variants).
# The python readline module calls rl_initialize() at
# module import, which triggers the issue.
# RHEL/CentOS 6.x uses readline 6.0.
# Workaround the issue by changing the TERM type if
# it starts with "xterm" before any module import.
#
# @see http://bugs.python.org/issue19884