melreams.com

Nerrrrd

Mongo tip of the day

Mongo can be very weird to adjust to if you’re used to “normal” (SQL) databases. One thing that tripped me up a little was discovering that mongo throws a DuplicateKeyException when you try to insert a duplicate into a field that has a unique index but is not a key. If you see that exception and there’s nothing obviously wrong with your _id field (mongo’s version of a primary key), have a look at any fields you have with a unique index.

Bonus tip: if you’re new to mongo I recommend their recorded Thinking In Documents webinar. It’s a pretty quick (1 hour) overview of how documents and querying work in mongo, I wish I’d found it before I spent so long fumbling around figuring mongo out on my own.

Mongo tip of the day

The other day I learned that it’s possible to convert a field in a mongo collection to uppercase. I didn’t know that was a thing until I went digging, so in case it’s news to anyone else, here’s the stackoverflow link. While I’m at it, you can use regexs in mongo too, but of course they’re slow so don’t go nuts with them.

Now we both know just enough mongo to really get ourselves into trouble :)

Linux tip of the day

For Eclipse users new to Linux like me, it can be pretty frustrating when you try to install some updates and Eclipse just tells you “Insufficient access privileges to apply this update.” I don’t know about you, but I run Eclipse as admin on Windows, which should give you some idea what the problem is :) Yep, on Linux you just need to run “sudo eclipse” from the terminal. Thank you stackoverflow. Don’t forget to close Eclipse and restart normally once you’re done updating, running as root will make your sysadmin sad.

Linux app of the day

I’ve been experimenting with switching to Linux (well mostly, I still need Windows for games), and so far it’s been weirdly easy. The only real problem I’ve run into so far, and it’s not much of a problem, is that I really love SlickRun and there’s no Linux version. Fortunately there is something SlickRun-like, Gnome Do. It works great for me on Linux Mint and it was really easy to change the settings so I can use the same keyboard shortcut I did to bring up SlickRun. I haven’t used it for anything besides launching programs yet, but it looks like it can do some really cool stuff.

Dev tool of the day

You know what’s incredibly helpful? RequestBin! Why is it so great? Because testing webhooks sucks and RequestBin makes it easy. Logging your output is a good start but that can’t tell you which IP your request is actually coming from. RequestBin can, which is awesome when you’re trying to figure out whether the Elastic IP you set up in AWS is working correctly. It also shows you all of your output (in a nice human-readable format, no less), which is handy if you really want to know exactly what your client receives.

It’s also free! On the downside your destination url only lasts for 48 hours and your data may be wiped out at any time (if you need a permanent solution look at Runscope’s Request Captures – seems only fair to plug the paid version when I’m talking about how helpful the free one is), but the price is right :)

Android app of the day

One of my very favourite Android apps is actually one of the ones I use the least. Gentle Alarm does what it says on the tin, it wakes you up gently instead of startling you awake like normal alarms. I don’t know about you but I really hate starting my day grumpy about how I got jolted awake.

Gentle Alarm is a bit more complicated to set up than the usual “blare loud noises” alarms, but I think it’s worth it not to wake up angry. I also don’t completely trust the “safe alarm” option – last time I tested it, which to be fair was ages ago, it was barely loud enough to hear. I’d still set a regular alarm for when you seriously need to be upright – it’s still annoying, but not nearly as bad as starting with the “blare loud noises” option.

There’s also a free version to test it out. The free version doesn’t ring on Wednesdays, but since it’s Thursday you’ve got almost a week to test it out :)

Chrome extension of the day

I have a bit of a tab problem. Just now I have 31 tabs open in Chrome. I could tell you I’m going to get that under control, but that would be a lie. I like the way Chrome handles tabs but they do eat up a lot of memory if you have a ridiculous number of them open. Fortunately, my problem is so common that there’s a Chrome extension to fix it: The Great Suspender. The Great Suspender does what you would expect from the name, it suspends your inactive tabs by doing some sort of magic that unloads your page but saves the url so you can reload it almost instantly when you’re ready. You can manually suspend tabs that you know you won’t use for a while or you can let it automatically suspend them when they’ve been inactive for long enough. It’s been great for memory usage and I really like not having to wait for all my tabs to load every time I restart Chrome.

greatsuspender

If you’ve given up on controlling your tab habit, give The Great Suspender a try. And donate a couple bucks to the creator if it helps you.

Mongo tip of the day

If you use Mongo’s mapReduce, pay close attention to which action you output to another collection with, especially if you’re using multiple mapReduces to perform a join. The merge action doesn’t do what you might expect – it merges at the collection level by overwriting the results of the first mapReduce with any results from the second that have the same key. If you want to merge at a document level, which is kind of important if you’re trying to join two collections, you need to use the reduce action, which runs all the documents for each key through your reduce function, which can then decide how to merge those two objects into one (null checks, lots of null checks).

As you may have guessed, I learned this the hard way when the fields set by my first mapReduce got set back to null by the second one. Just because you think you know what “merge” does that doesn’t mean you shouldn’t still read the docs.

Productivity tip of the day

I’ve been working through the Learning How to Learn course on Coursera, and one of the things the teachers recommend is using the Pomodoro Technique. When I first heard about it it sounded too simple to work, but you know, it’s actually really helpful. I personally have trouble getting started on tasks in part because I feel like it’s going to take all day to get it done and I just don’t wanna :) The Pomodoro Technique helps me because there’s a built-in stop time – when 25 minutes are up, it’s time for a break.

The Pomodoro timer I use is tomato-timer.com. I can’t say I really need another tab open all the time (if I counted correctly I have 42 tabs open right now), but it’s super easy to use and I like not having to install anything. If you have trouble getting started or staying focused, give it a shot. It can’t work any worse than what you’re already doing :)

 

Postman rocks!

Postman is one of my favourite Chrome extensions, it’s so helpful. If you work with REST APIs, you need postman or something like it. Yes, you could just use curl, but you could also not hate your life :)

Postman lets you easily test your REST endpoints by letting you name and save your calls and add them to collections. You can save your authentication data too and you can parameterize your calls so you can test the same call on local and then staging by just switching environments in the dropdown. Another really cool thing Postman added lately is the ability to sync your account across different computers. If you work from home sometimes and curse yourself for not exporting your calls and sending them to yourself (not that I ever do that), you’ll love that feature.

If Postman isn’t your thing, there are plenty of other apps for REST testing. Insomnia, for example, was built by a local!