27 December 2019
I will most likely be sunsetting this blog soon, and moving on to something like a static site generator for any future content. (I’m currently leaning in the direction of Hugo)
I started this blog back in May of 2006 as a place to post my thoughts, and during that time I’ve accumulated quite a lot of content. However, the rate of posts has slowed considerably, to only a handful each year, to the point where I don’t feel it makes sense for me to maintain this WordPress installation anymore. Continued
22 August 2018
If you’re developing with the Connect IQ SDK and have Java 9 or 10 installed (or any version beyond Java 8), you’ll probably run into an issue like this when trying to compile your app with monkeyc
or run it with monkeydo
, whether from the command line or the Eclipse Plugin:
$ monkeydo myApp.prg fenix5
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
at com.garmin.monkeybrains.prgreader.EntryPoint.parse(EntryPoint.java:71)
at com.garmin.monkeybrains.prgreader.EntryPoints.parse(EntryPoints.java:21)
at com.garmin.monkeybrains.prgreader.PrgParser.parse(PrgParser.java:50)
at com.garmin.monkeybrains.monkeydodeux.MonkeyDoDeux.execute(MonkeyDoDeux.java:244)
at com.garmin.monkeybrains.monkeydodeux.MonkeyDoDeux.main(MonkeyDoDeux.java:146)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 5 more
Continued
10 March 2018
We’ve talked about soft and weak references, and how they differ from strong references. But what about phantom references? What are they useful for?
Starting with Java 9, the intended usage of PhantomReference objects is to replace any usage of Object.finalize()
(which was deprecated in Java 9), in order to allow for this sort of object clean-up code to be run in a more predicable manner (as designated by the programmer), rather than subject to the constraints/implementation details of the garbage collector.
Continued
31 December 2017
In a previous post, I described what weak references were and how the JVM interacted with them and how they contrasted with strong references. In summary, a strong reference is what we typically think of as a reference in Java; that is, when we instantiate an object and assign its reference to a variable, that is a strong reference. Obviously, these objects will not be cleared by the garbage collector (GC) until the reference is removed.
By contrast, a weak reference doesn’t prevent the garbage collector from clearing the referred object. That is, if the only references that remain to an object are weak references, that object will be treated as if there are no strong references to it, and thus it will be cleared by the GC on its next run. Weak references are implemented mainly by the WeakReference
“wrapper” and WeakHashMap
, the latter of which only maintains weak references to the keys, so that once the keys are inaccessible (i.e. no strong references exist), the WeakHashMap
will automatically drop/remove the corresponding entries, which can also make the value objects eligible for GC so as long as there are no other references to them.
But how do these references contrast with a soft reference?
Continued
7 April 2016
I recently analyzed the 2011-2015 Boston Marathon results. You can see the results in this GitHub Repo, or go straight to the IPython/Jupyter Notebook for the details.
Boston’s getting competitive Continued
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:
$ ipython nbconvert --to PDF <your notebook>.ipynb</your>
Continued
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.
Continued
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.
Continued
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.
Continued
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.
Continued