melreams.com

Nerrrrd

Windows tip of the day

Windows actually has a builtin file hash function: in powershell, use Get-FileHash [filename] for a sha256 hash, and add the optional -Algorithm switch (-Algorithm MD5, for example) for other algorithms.

If you happen to be using Win8 in particular, stick with the powershell commandlet. Trying to find a windows file hash generator and then get Windows to actually run it will just make you unhappy. Screw you too, AppLocker.

Cmder rocks!

Cmder is an awesome tabbed command line interface for windows. Unlike the regular windows console, cmder is resizeable, includes handy linux commands like grep, and uses a font that isn’t hideous. Honestly, while the other features are great, being able to resize the freaking window was one of the biggest selling points for me. It’s incredibly irritating to try to read a log in a window that’s only 80 characters wide when you’re running a java server that sometimes throws very wide error messages.

Cmder can also be integrated with programs like Sublime Text. I haven’t done it myself but it’s cool to know I could. For git users, cmder has another really cool little feature – where the prompt usually shows you which directory you’re in, cmder adds which branch you have checked out to the end, and it turns that branch name red if you have changes you haven’t committed. It’s amazing how helpful that is.

Cmder with current git branch
Cmder with current git branch

If you use windows and you run anything from the command line, give cmder a try. Shiny shiny tabs await you :)

 

What the hell is using port 80?

Every time I need to figure out what process stole port 80 from my local server I have to look up the command again, so I’m going to share it here for my fellow windows users in hopes I’ll finally remember it :)

From a command shell running as admin:

netstat -anob

Thanks as usual to stackoverflow, where the collective memory of nerds lives.

And here’s another fun fact for windows users: Skype may well be the process that’s hogging port 80. It uses ports 80 and 443 by default because they’re usually not blocked by firewalls and hey, it’s not like developers use IM >:(

 

WordPress plugin of the day

A few weeks ago wordpress decided it didn’t feel like actually publishing my scheduled posts anymore. Technically I could’ve poured hours into figuring out exactly why wordpress was misbehaving but you know, part of being a senior dev is prioritizing :) Sometimes the five minute “install a plugin” fix is good enough. There are a bunch of plugins to fix the scheduled posts not actually posting issue, the one I chose is called WP Missed Schedule and it seems to be working well. If you have a wordpress blog that doesn’t always do what you told it to, give WP Missed Schedule a try.

 

Debugging tip of the day

loglevel=”TRACE”

Alright, I guess I can give some details :)

It’s amazing how helpful just turning up your log level can be when you’re working on a weird bug. If something you can’t immediately explain is happening, try turning up your log level. In java, where I have the most experience, it’s unusual to run your production logging at a level above warn or debug. Normally you wouldn’t want extremely verbose logs, which are what you get when you turn up the log level, but sometimes you really need that extra information.

I wouldn’t normally think of turning up the log level, but we happened to have some trace level logging in our code and when I ran into a weird bug. I thought it would be easier to turn up the logging than to change all the .traces to .debugs, and it turned out the debug level exception gave me much less information than the trace level exception which had been swallowed because we were logging at the debug level. The trace level exception pointed me at the real bug, which turned out to be an obscure issue to do with my particular version of java having a weird interaction with a couple of libraries we’re using. Just because there’s no good reason for it to break doesn’t mean it won’t break :)

The moral of the story is that your log doesn’t necessarily tell you everything and you should turn up your log level until you get answers.

Ember tip of the day

If you happen to find some example code that elegantly solves your exact problem, check which version of Ember it uses. Sometimes that perfect example is a few versions ahead and will do absolutely nothing for you. If you’re smarter than I am and check the version number right away, you can save yourself a good half hour of cleaning, rebuilding, and cursing.

On the upside, if you need to iterate over a map with {{#each foo in bar}}, you can hammer together a workaround using Ember.keys(map) – but again, only if you have the right version of ember. Ember.keys() was deprecated in 1.13, use Object.keys() instead if your version of Ember is later than 1.13.

 

Android app of the day

Smartphones are freaking amazing for absent minded people like me. I’ve been able to give people the totally false impression that I’m organized because I put reminders for absolutely every appointment into my calendar :) Another way I trick people into thinking I can remember to do things is by using a handy little android app called toastr (sorry iOS users, there doesn’t seem to be a version for you).

Toastr does one thing and one thing only. Every time you unlock your phone, it pops up a little notification with whatever text you set. That’s it. The interface is gloriously simple and requires absolutely no screwing around in convoluted settings menus. If you need a quick, easy reminder to do something (calendar reminders are great but they’re slow to enter and sometimes you don’t know exactly when you’re going to be able to do the thing), toastr is just about the perfect solution.

Toastr is also really satisfying from a design perspective. It knows what it’s for and doesn’t try to be all things to all people. It’s not pretty, but it doesn’t waste my time asking what it should look like. You can get a pro version of toastr for 99 cents that does have some largely useless notification customization features, but I can understand why the developer felt compelled to add more features to the pro version and at least it doesn’t beat you over the head with them.

If you need a really simple reminder now and then, give toastr a try.

SMTP testing tip of the day

Through painful experience, I’ve learned that most dummy SMTP servers you can use for integration tests do not support SSL. This is more than a little irritating if you want to automate testing for SSL connections. Fortunately, there is one dummy email server that I’ve found that actually supports just about any protocol you could want, including SSL: GreenMail.

The GreenMail examples are very helpful, but there is one more piece you need if you’re going to test sending email over an SSL connection:

Security.setProperty("ssl.SocketFactory.provider", DummySSLSocketFactory.class.getName());
GreenMail mailServer = new GreenMail(ServerSetupTest.SMTPS);
mailServer.start();

That first line of code prevents you from getting a giant SSLException stack trace when your email sending code tries to connect to the GreenMail dummy server. Thank you stackoverflow!

Play framework tip of the day

Sometimes Eclipse will randomly decide not to rebuild your project, insist you haven’t added something that you just added, and throw errors all over the place. You can trick it into behaving itself by closing and reopening the project. I don’t know why that works but sometimes it helps when nothing else does.

Cold & Flu tip of the day

Get the fancy tissues with lotion. Yes they sound stupid. Get them anyway, they are really and truly worth it. And don’t push yourself too hard, you’ll just make yourself sicker. I’m still working on that one myself, but it’s good advice in general.