melreams.com

Nerrrrd

Git tip of the day

Git is more than a little intimidating when you’re first getting started. Fortunately my friend Jen Reiher made this excellent flow chart to help you. Also, tell me that URL isn’t awesome :)

The reason I like this flowchart so much is that it’s really clearly broken down into steps and doesn’t drown you in information you don’t need. A lot of git guides start talking about branching and merging right away, and while those are important concepts they’re not necessary if you just want to put a simple project up on github so other people can see your code.

Javascript tip of the day

If you write javascript, you probably use console.log() all the time. The other day I stumbled across this video (quite possible in javascript weekly, a newsletter I recommend if you work in javascript regularly) with a really great and very simple tip: if you’re logging an object that contains other objects, use console.table() instead. I didn’t know that was a thing! It gives you really nice easy to read output in the form of, you guessed it, a table :)

Here’s the video so you can see what I’m talking about:

Linux Mint Cinnamon tip of the day

If you happen to run the Cinnamon desktop on Linux Mint I highly recommend the System Tray Collapsible applet. If you don’t run that exact distro and desktop, this post is going to be really boring for you :)

System Tray Collapsible lets you hide icons in the system tray. It’s probably meant to reduce the space your system tray takes up, but what I use it for is hiding notifications from myself. Slack, for example, adds a little blue dot to it’s tray icon when you have an unread message no matter what your notification settings are. If you’re totally incapable of ignoring a notification like I am, that can get pretty distracting. System Tray Collapsible to the rescue! If you can’t see the icon at all, there’s no blue dot to distract you.

One caveat: it can be tough to get your pointer in just the right place to see the context menu for the applet (which is the only way to tell it which icons to hide) instead of the tray icons inside the applet. Keep trying, it is possible!

Podcast of the day

As a person who takes the bus to work and has trouble reading in moving vehicles (motion sickness sucks), I’m a big fan of podcasts. My favourite tech podcast is Hanselminutes. It’s run by Scott Hanselman, a programmer, teacher, and speaker, to directly rip off his about page.

Hanselminutes is my favourite tech podcast because of the variety of topics and guests and Scott’s skill at interviewing. He’s had guests come talk about everything from data visualization to funding open source to getting started making video games, and no matter what they’re talking about the conversation always flows smoothly. It could be that Scott is amazing at picking guests and editing out the awkward bits, but I think he deserves some credit for being able to guide a conversation like that too :)

If you like podcasts at all and don’t already listen to it, give Hanselminutes a try. You can find it on iTunes or just by searching for Hanselminutes (yay for unique podcast names!) in any Android podcast app.

Authenticator tip of the day

Fun fact about authenticators like Google Authenticator and Authenticator Plus: they have their own internal clocks that can get out of sync with the server you’re logging into. Most of the time they don’t drift far enough to cause problems, but AWS is very, very particular about your clock being in sync with theirs.

If you find that AWS rejects your one time codes but the rest of your accounts work just fine, it’s probably a clock sync issue. In Google Authenticator the sync function is easy to find under ‘Time correction for codes’ in the menu. In Authenticator Plus it’s hidden behind ‘Others’ -> Sync with Google. Try that before you waste a morning trying to figure out how one and only one of your accounts got corrupted ;)

Perl tip of the day

If you have to use Perl, a) don’t feel bad about having trouble understanding it sometimes, everybody else does too, and b) there is an operator that’s extraordinarily difficult to google. If you happen to run into it, in Perl =~ returns true if the value on the left matches the regex on the right and false if it doesn’t.

That type of operator is called a binding operator and if you’re lucky and you already know that it becomes possible to google it. If you don’t, it’s kind of a terrible experience. Seriously, try googling “perl =~ operator” It takes some serious digging to find any useful results.

Mongo tip of the day

If you ever use Morphia and Jongo in the same codebase, be warned they can interact in very confusing ways. Quick note for people who may not have any idea what I’m talking about: Morphia maps Java objects to Mongo documents and provides a really nice fluent interface for querying. Jongo is not quite as friendly but gives you all the same functionality as the Mongo shell. Most of the time we use Morphia at work, but once in a while for weird queries that Morphia doesn’t support (like regexes) we use Jongo.

Morphia has annotations that let you have short, space-saving field names in your documents and nice descriptive field names in your code. Jongo can convert its results into Java objects for you, but it uses Jackson to do that. Neither Jongo not Jackson know about Morphia’s annotations, which means if you used annotations to change the field names in your document, Jongo will try its best to build objects out of your results but they will be empty because it can’t match your document field names to your object field names. My coworker Eric figured that one out after I spent all afternoon swearing at it.

Fortunately, there’s a workaround! If you don’t want to dirty up your code with Morphia and Jackson annotations, you can get Jongo to give you back JsonNodes by using the JsonResultHandler like so:

Iterable<JsonNode> iterable = jongo.getCollection("collection")
    .find("{ query }").map(new JsonResultHandler());

Pulling fields out of a JsonNode isn’t as nice as having an object already filled in, but on the upside it’s a lot less hassle (and ugliness) than doubling up on annotations. If Jongo misbehaves for you in weird ways, try getting simple JsonNode results back instead of messing around with object mapping.

Atom plugin of the day

Lately I’ve been updating some docs that we generate from YAML files and while I do like YAML as a format (beats the hell out of XML, but that’s the kind of bar you trip over), it can be really painful to figure out where exactly you messed up your indenting.

Fortunately, there’s an atom plugin for that! linter-js-yaml gives you incredibly fine-grained and helpful error messages. Isn’t that screenshot pretty? It’s got a nice obvious red dot and an underline and an error message that actually tells me what I got wrong! If you ever edit YAML, try linter-js-yaml, it’s awesome.

YAML linter screenshot showing a helpful error message
YAML linter screenshot showing a helpful error message

Atom plugin of the day

Since I switched to Linux, I’ve had to find a replacement for my beloved notepad++. I went with Atom because I like the project view in the sidebar and I’m too cheap to pay for Sublime.

Highlights!
Highlights!

Because I miss notepad++ so much, I’ve been slowly trying to make Atom behave as much like it as I can. One very simple plugin that helps me do that is selection-highlight, which highlights all occurrences of a word when you double-click it. For something so simple it’s really helpful, and something I missed a lot when I switched to Linux. Sometimes you just want to know whether the id you logged in a few different lines is actually the same, and it’s really nice to be able to do that with only two clicks.

If you use Atom, I recommend the selection-highlight plugin, and if you don’t use Atom, I recommend trying it out. It’s free and there are about a bajillion plugins :)