10 February 2016
If you have an IPython Notebook (
*.ipynb file), you may want to convert to PDF for distribution. If you read the documentation for
ipython nbconvert, it seems fairly straightforward:
20 January 2016
We all know what debugging is – stepping through running code, line by line, inspecting variables and trying to figure out what’s wrong with your program while simultaneously tearing your hair out. However, usually when debugging Python code, the Python process is running locally on your system. What happens if you want to debug through code running on another server?
This is typically the case when working with OpenStack Swift, since the Swift-all-in-one (SAIO) instructions tell you to use a VM to run your Swift installation in, and a Vagrant VM provided by SwiftStack simplifies this. However, this means that the Swift code is not running locally; it’s running inside of your VM – so how do you debug into it?
Remote debugging aims to solve this by allowing you to inspect, trace and step through code running in a Python process on another machine. Setting this up requires some work, but is well worth the effort when debugging a non-trivial application running on a remote server or VM.
21 December 2015
Mounting (or sharing) a directory from the Docker daemon host into a container is simple enough. Example:
$ docker run -v [host directory path]:[container directory path] -it [image name]
However, on OS X and Windows, the Docker daemon (currently) runs inside of a Linux VM, that by default is run using VirtualBox. (Since Docker only runs natively on Linux) So, you’d be mounting a folder from the Linux VM, which is probably not what you want if you want to share files from your host machine into the container.
16 September 2015
In Go, interfaces are implemented implicitly by ensuring that the implementing type’s method set contains all the methods of the interface. That is, if a type A contains a method set that is a superset of interface I’s method set, then type A implements interface I.
This seems pretty straightforward, but can get a little convoluted when dealing with struct types that have embedded/anonymous fields.
30 March 2015
If you’re converting a large amount of CAD to USD (to buy US-listed/denominated securities, or to purchase US goods, or whatever) the spreads your bank offers you may not be the best way. Instead, if you have a brokerage account (one for both CAD and USD), you can use the Horizons DLR ETF to do the conversion for a lower cost.
Horizons has a nice PDF detailing the procedure, but I wanted to go through my experience with the process.
8 March 2015
I’m a fan of CBC Radio 2. Okay, that’s not exactly true, but I do have my $10 radio alarm clock tuned to 94.1 FM to wake me on weekdays. I often find myself in a stupor or only semi-awake when the tunes start blasting away before dawn, and as such, I often have trouble remembering what was exactly on the radio that morning. However, once during the day I remembered that a certain Ben Folds Five song had received airtime on CBC Radio 2 during my morning wake-up, but could not recall the exact day. It bothered me.
Thankfully, they did have broadcast/play logs of all tracks they had aired, along with the date/times, providing for a succinct history. Unfortunately, it didn’t seem possible to search them, and I didn’t feel like searching through each day’s play log for the particular title. What to do?
Scripting to the rescue!
3 March 2015
React is a great framework for building web UIs. (And perhaps other UIs as well) I’ve recently started using it in some side projects, and love its ability to easily manage view state and efficiently update the DOM, reducing a lot of the “grunt work” of building dynamic web UIs. On the other hand, it feels relatively lightweight in that it doesn’t impose a lot of structure in how you design your app. This may be a Good or a Bad thing, but the upside is that there isn’t a steep learning curve.
One thing I recently wanted to do with React was to build a component that would animate during its transition from state A to B; an example would be an On/Off button. It is possible to do so with React’s built-in animation addon, but it just required some attention to detail.
21 March 2014
If you’re using RequireJS’s shim configuration to load jQuery plugins while setting
Uncaught Error: No define call for iCheck http://requirejs.org/docs/errors.html#nodefine
13 March 2014
The SoftLayer REST API doesn’t seem to have an XSD, so you can’t use
xjc to generate classes. That’s a shame for a strongly-typed language, since you’d now have to manually create classes based on their Data Type Reference.
I didn’t like that and decided to code up a Java class generator (it’s written in Python) based on the Data Type Reference. You can use it to generate a Java class based on the SoftLayer Data Type you pass in. Enjoy!