Go: How to Get the Directory of the Current File

In Python I often use the __file__ constant to get the directory of the current file (e.g., os.path.dirname(os.path.realpath(__file__))). While writing a Go app recently, I found that there wasn’t an immediately obvious (or searchable, even with “golang”) equivalent. But in the annals of the golong-nuts mailing list I eventually found out about runtime.Caller(). This returns [...]

Continue reading...

Run Django Unit Tests in a Sublime Text 2 Build System

With the dev builds of Sublime Text 2, you can easily set up a build system that runs Django unit tests. You do this by adding a build system to your Sublime Text 2 project file for the Django project. I’ll include an example project file in this post that runs manage.py test –noinput as [...]

Continue reading...

Python: How to tell what class a decorated method is in at runtime

When profiling a Python app, it’s helpful to have a decorator that wraps functions and reports details about their performance. Assuming you are doing this to report some metric about the function, you’ll want the decorator to work with both bound and unbound functions (IE, regular functions and methods of a class), and if the [...]

Continue reading...

Make Sublime Text 2 More like Vim: Wrap Code, Go To Last Edit, Jump Back, and More

I’ve been trying out Sublime Text 2 as a replacement for Vim. While I enjoy using it and I experienced the “Wow, this does 90% of what Vim does” moment, I kept a running list of all the features in the remaining 10% that I relied on every day. These included: Better code wrapping (gq) [...]

Continue reading...

Sharp Edges: Protecting Ourselves from Digital Publishing

Nicholas Carr wrote in a recent article that he considered the ability of publishers to change text after they had released it “insidious” and a “bane” of digital publishing — specifically, if such changes are made in response to market research. I agree that there is a challenge inherent in the new ease with which [...]

Continue reading...