Redis: Migrate Keys From One Instance To Another Based On Pattern Matching [node.js script]

If you work with Redis and a fairly big dataset it’s pretty likely that, at some point, you’re going to fill up all your RAM. This already happened to me more than once with; the easy fix, if the growth is slow enough, is to just add more memory.

Simpsons_Duff_Lite_DryWhen that doesn’t work anymore, the next move – while waiting for Redis cluster – is quite likely going to be using some manual sharding technique. When you do, you’ll probably going to need to split your dataset among more instances.

This is exactly what just happened to me, and I didn’t find any ready recipe or solution to easily split my rather large dataset. So I ended up creating a small node.js script which doesn’t use too much memory and that you can find here:


A Little Cross-Platform Productivity Boost

Sometime it is difficult to concentrate on the task at hand – especially if you are almost always at work, with a day job and a startup on the side. At those times, I find it particularly difficult to resist the temptation to compulsively wander to some interesting websites, like Hacker News or some other online news source.

I already had a little Windows software installed to block a list of distracting websites for a given time when I need it, but I often code on Linux and that program doesn’t work there. That’s how I came across Concentrate for Chrome, a Chrome extension that does that same thing – but works equally well on Windows and Chrome.

If you’re like me, and sometimes being a news-aholic interferes with your being a workaholic, this extension is highly recommended!

Save Even More Time On Hacker News

Some months ago I published a Chrome extension I had developed for myself to save time on HN; it allowed you to “mark as read” the news items that you already read or scanned.

The Chrome store tells me that 770 users are using it weekly, so I decided to take the time to update it with some more features that I’ve been experimenting with lately and found very useful.

Mark comments as read

The new feature I found most useful is the ability to also mark comments as read.

Using the orange button, you can mark all comments in the page as read. If you do so, those comments will appear with a slightly darker background, so when you reload the page you can easily spot the new ones – I found this a real time saver!

If you want to find the new comments even faster, you can check the “Hide read comments” option. This mode can be a little confusing, as you lose the context for the comment, but sometimes I found it useful anyway.

Follow comments for a news item

Sometimes, even if you already read an item and its comments, you want to follow the discussion as it develops, or be notified if a discussion starts at all. Instead of just leaving the comments page open, you can now tick the “Follow comments” checkbox (see picture above); when you do so, the news item will be shown in the home page even if it was marked as read and you are hiding read items.

Most importantly, if there are new comments since you marked all comments as read for that item, that will be shown with a green text in the home page. This can also be a good time saver – if you resist the urge to follow too many discussions, at least.

Collapse comment threads

This is a pretty obvious feature, but it helped me save time when, for example, the first comment for an item is something contentious that generated a long thread I’m not interested in. Just click the little “-” symbol to the left of the root of the thread, and the thread will collapse.

You can also collapse all thread with the “‐‐” to the left of the “Follow comments” checkbox. “+” and “++”, of course, will respectively expand one thread and all threads.

Show parent comment

I left the fanciest feature last; I don’t use it very often, but when I do I find it incredibly useful.

I like threaded comments, but sometimes you just get lost in them: You read a long sub-thread, then you find a comment answering something, but you can’t understand what it’s answering to. How can you find that out? Enters “show parent”.

With this feature, when a comment is part of a thread, but not the first answer to its parent, a “show parent” link appears. You can hover your mouse pointer on that link, and the mysterious parent is shown right above it. I really like this solution because it is non-intrusive and (in my opinion) solves a real pain of threaded comments. The only serious limitation I see is that it wouldn’t work well on touch screens, but if somebody wants to adopt it for that use case, it could become a touch-to-toggle.

Wow! How much do I need to pay for all this?

Nothing! You can get the extension for free from the Chrome store.

Other browsers? It’s open source

I packaged this as a Chrome extension because it’s just too convenient. If you want to use it on some other browsers, though, you’re free to get the source code on github and adapt it any way you want. Happy hacking!

Shameless plug

Did you like this project? Do you need somebody to help you develop your web app or idea? I just started to be open for consulting projects. If you need an expert at translating ideas into software solutions, from requirements analysis to full stack development, check out what I could do for you here.

ABalytics.js: Client-side A/B Testing With Google Analytics

I recently wanted to conduct a little bit of A/B testing on a project of mine, so I went exploring – yet again – the free options.

There are lots of very good server-side solutions, but what I wanted was one that I didn’t need to configure on the server, and that could be integrated into Google Analytics, where I already track my websites performances. I found on the web some how-tos about the use of GA custom variables for A/B testing, but no ready-made libraries to do so.

So I created my own javascript library; it is so simple that I decided to implement it without any external dependencies, so that if in the future I want to use it without jQuery (which I usually use) I’ll be able to do so. And it is so simple that it was easy to give a minimum polishing and make it ready to publish, to give it back to the community.

These are the main features:

  • Easy to set up
    • You just list the possible variants, the randomization is handled automatically
    • You just mark the html elements you want to test on with a class, the substitution is automatic
    • No need to set anything up server side, all the results are stored on Google Analytics
  • Consistent user experience: The selected variant is stored in a cookie, so the user will see the same one when coming back
  • No external dependencies: Pure javascript, you just need to include GA
  • Flexible: You can conduct multiple, independent experiments at the same time. Each experiment will use a custom variable slot

I’m releasing the library with an MIT license, and you can find it – with basic instructions on how to use it – on Github. Enjoy!

Never get lost in Hacker News threaded comments again

Did you ever get lost in HN threaded comments, unable to understand which parent a comment was answering to? This happens a lot to me, especially when threads become long… and most interesting.

Being appreciative of threaded comment systems in general, many times I wondered if there was a simple solution to that problem. Comments folding is useful, but it answers a different problem. But what if you could just visualize the parent a given comment was answering to, without having to scroll up and down all the time?

Having some time on my hands, I created a Chrome extension to do just that. Install it and, when a comment is answering to a parent that isn’t right above, a “show parent” menu item will appear. Hover your mouse pointer over it and the parent comment will be shown right above the child.

This is a feature I would have liked to see in threaded comment systems for a long time, but never saw it before (maybe I just didn’t pay enough attention). Hope I’m not the only one to find it useful!

PS: You might also be interested in my other little HN Chrome extension, Hacker News: Mark All Read.

Hacker News: Mark All Read Source Code Released

TL;DR: I just released under an MIT license the source code of the Hacker News: Mark All Read Chrome extension. You can find the code on github.

Background: I often thought about open sourcing many of the little projects I create from time to time, but until now I never went on with it. The reason: I’ve got pretty strong perfectionist tendencies against which I’m always struggling, and releasing unpolished code that I’ve quickly hacked up to solve some practical little problem doesn’t bode well with those tendencies.

But with this one I got many feature requests that I already know I won’t have time to implement. So I decided to publish the code anyway and see what happens. Just consider it what it is: A quick hack I created in one afternoon, and polished just a little bit the day after. Have fun with it!

PS: I thought about it and decided not to release the “artwork”, because having more extensions on the Chrome market with the same look would be confusing. The extension works anyway as it is, but if you add a button icon in an “images” folder it will look better.

To discuss on HN: link

Save Time On Hacker News: Mark All Read

Hacker News is and incredibly useful resource for hackers and startuppers. In true hacker style, its usability is pretty basic though.

In the myriad of widgets and extensions that hackers created to improve that usability, I’ve never find the one I wanted most: An optimal way to know which titles I already scanned and didn’t find interesting enough to open. So that, when I reload the home page, I don’t have to scan them again.

This is why I created Hacker News: Mark All Read. It is a (free) Chrome extension that solves exactly that problem, in a very simple way: After you scanned all the titles, you can click the “mark all read” button, and all news items will appear as if you visited the link.

This way, when you reload the page, you can immediately see what is new. It works across different pages (home, new submissions, second page etc.). And you can hide the news you marked as read, for super-fast scanning of the new news.

You can install the extension from the Chrome web store. If you have any comment… please do comment :)

Update: I also released the source code.