Floating Point to Hex update, and writing tests as a sign of maturity

Over the weekend I published an update to my Floating Point to Hex calculator that allows you to swap the endianness of the hex bytes! Pretty exciting, no? (the answer is: meh)

It was actually more work than it looks like, because I decided to go ahead and update the backing script to Python 3, which meant I had to recompile the C module it uses. When I was about to start doing this I was disappointed to see that I didn’t have any tests in the project, so I went ahead and wrote those before changing everything. And even before I started changing things I found a few bugs (oh negative zero, you are tricky), so it was time well-spent!

I did have to refactor a few things to make the script testable, but I can’t imagine doing a refactor with only the help of spot-checking things, which is what I used to do. Just like writing clean code, writing tests is useful for future you as well as others!

Airport Guides is now available for Android!

I’m happy to announce that Airport Guides (now with terminal maps for over 90 airports worldwide) is now available as a free app for Android! (the Windows 10 version is still available, too!)

Now that Xamarin is included for free with Visual Studio, I thought it would be fun to try it out. Xamarin lets you make apps for Windows/Android/iOS by writing code in C#. Usually you have to then design your UI in the appropriate language (Java for Android, Objective-C/Swift for iOS), but with Xamarin.Forms you can even write a cross-platform UI in C#!

Since most of the work in the Airport Guides app is maintaining the maps themselves, the app is pretty small so I thought it would be a good candidate for porting as opposed to something like Bridge Scorer which has a ton of custom UI. The experience was pretty good – writing the UI in Xamarin.Forms is a lot like writing it in UWP for Windows 10, except all the keywords are different 🙂

I did run into some frustrations along the way. One was not realizing that you can’t test in-app purchase stuff without a real device. (although in retrospect the documentation does mention this…somehow I missed it) Another was that while the Android emulator for Visual Studio is literally 10x faster than the default emulator, there’s at least one bug that doesn’t show up in the real emulator. For the record, it was fetching a particular web page that would always timeout…I still never figured out why! Pinch/zoom was also tricky to get working until someone pointed me to MR.Gestures (which I always pronounce “Mr. Gestures” in my head 🙂 ), but I still am disappointed that every platform doesn’t have an easy builtin way to make pinch/zoom on an image work. Shoutout to Alan Clark from Xamarin for helping me through some of these!

Man, Javascript is still kind of dumb

I’m working on rewriting my floating point to hex converter with React. This time I thought I’d do it “right” and use all the nifty Javascript tools that everyone complains about instead of just putting a bunch of inline Javascript/JSX in an HTML file, even though that works well enough. Long term, I’d like to rewrite the marriage map with React and D3.js, so I thought this would be a good dry run.

But, maaaaan:
– I literally had to buy a React+d3.js ebook to figure out how to get all this crap set up. (the book is pretty good, by the by)
– The book recommends starting from a particular git repository. To clone that on my linux machine I had to set up some SSH key stuff, which seemed like overkill. (why do I need to do that for anonymous access?)
– To set it up, it downloads something on the order of 300 packages through npm. I wish I were exaggerating.
– Building it (even without minifying the source!) takes a solid 6 seconds on my desktop machine. This is for a ~100 line javascript file. The non-minified version is more than 2 MB of Javascript! Even the minified one is ~180K, which seems like way too much.
– React now recommends you use ES6 instead of calling React.createClass(), and there are some niceties there. But there also some stupid gotchas, like the fact that you have to call .bind(this) on every method for it to be able to access this, because Javascript is the worst.
– For some reason I’m not able to debug with Firefox’s debugging tools. (luckily Edge seems to work well)
– I wasted an hour because the new fancy fetch standard (not supported in some versions of IE so you need a polyfill) has a method called text() that returns the text of the response. Wait, no, it actually returns a promise that has the text of the response. I never realized how much I liked C#’s standard of ending asynchronous methods with “Async” before…

Anyway, I think I’m past all this crap, but I’m starting to remember why Javascript is terrible!

clue solver redux!

After revamping gregstoll.com to support SSL, I spent some time looking at all of my projects and making sure that they still worked with SSL. Turns out most of them didn’t! (although the fixes were generally pretty quick)

That led me to revisit the Clue Solver, which seemed to have partially broken since I wrote it almost 10(!) years ago, probably because I used an ancient version of the Google Web Toolkit.

So I rewrote the UI from scratch using React, which I’m trying to get more experience in and is just generally a really nice Javascript framework. And now it’s done! Here’s the new version, and here’s the original one.