Just a quick note that I whipped up a PhantomJS script to capture screenshots of Reveal.js powered slide show slides.
-
-
Spidering JavaScript-manipulated HTML with PhantomJS
Even if you are in an automated context, not using a typical browser, fetching the data/webpage from an URL is easy. There are command line tools like wget and curl, and every programming library has its share of libraries to build on.
But what if you need the HTML …
-
Git cherry-pick without whitespace
A colleague of mine at work has set up his IDE to clean up all trailing whitespace on save. Nothing wrong with that, except that he is the only one, which very often means in practice that his commits are sprinkled with fixes of other people's whitespace mixups. Because of …
-
Get stacktrace in Python catch body
So you have some Python code in a try-catch, and you want the typical Python stacktrace (aka traceback, aka backtrace) in a way you can manipulate?
Here are some ways to handle it:
import traceback import logging try: stuff() except Exception: # Just print traceback print "something went wrong, here is …
-
Check iTunes library for inexistent files and broken links with Python and PyObjC
Music files come, music files go. And after some time your iTunes library is sprinkled with cases of
The song “Monsieur Cannibale” could not be used because the original file could not be found. Would you like to locate it?
Being annoyed by this and having no idea how "healthy …
-
Unicode Fun in Python
Here is some Python powered unicode fun (command line oneliner version):
python -c 'for c in range(0x1F410, 0x1F4f0): print (r"\U%08x"%c).decode("unicode-escape"),'
result:
-
Git: resolve conflict after stash pop in working directory (no staging/index)
In git, when you do
git stash pop
of unfinished code after upstream merges, you might get a conflict between the stash and the upstream changes you pulled in.You git clone now has "unmerged paths" aka is in conflict state. For example,
git status
shows:# Unmerged paths: # (use "git …
-
Python: determine installation prefix
Here's a simple bash oneliner to determine the installation prefix (and more) of a python interpreter:
python -c 'import sys;print("\n".join("{0:16s}: {1!r}".format(x, getattr(sys, x)) for x in ["executable", "version", "prefix", "exec_prefix"]))'
(Replace "python" with the actual python executable you want to …
-
Python trick: asynchronously reading subprocess pipes
Update: I reworked the code below a bit and put it on github and pypi to make it pip installable
As its name suggests, the Python subprocess allows you to spawn a child/sub process and keep an eye on its standard output through a pipe for example. Very handy …
-
Duviz: command line tool for disk usage visualization
duviz.py is a simple UNIX command line utility written in Python to visualize disk space usage. See it in action here:
I started writing it a couple of years ago (2009 according to the git commit log), but I just recently decided to make it more public. As a …