open core »

Yeoman generator for Ink

Probably everybody knows now that SAPO’s Ink framework is an awesome alternative to Bootstrap. And there’s also this great scaffolding tool called Yeoman, that if you don’t know, you should really check it out. The same also applies to Ink.

About two months ago, during my short travel to London to attend the The Great British Node Conf, I developed a Yeoman generator for Ink, called generator-ink.

This generator creates a ready-to-use website layout using Ink. You can even choose from 11 available layouts (more coming soon), and start hacking right away with the basic dependencies already in place.

To install it , just type on your terminal (make sure you already have Yeoman installed first):

$ npm install -g generator-ink

Now create a folder for your project and cd into it:

$ mkdir my_awesome_project && cd my_awesome_project

And now to start generator-ink just run:

$ yo ink

If everything went well, you’ll be greeted with the layout choice menu:

generator-ink layout choice menu

Now it’s just a matter of choosing the layout that most adjusts to your needs, and hack it.

Need more site pages? No problem, there’s a sub-generator for that. Imagine we need to create an article page. Piece of cake! Just type:

$ yo ink:page article-page article.html

You just need to know the name of the layout (you can check all available layouts here), give it a name, and BAM! It’s there!

You can also contribute with your own layouts! Just make a pull request on Github and I’ll be glad to accept it!

Playing RTMP streaming on Mac with VLC and rtmpdump

VLC is a great piece of software, but currently lacks RTMP support. The good news is that there might be some RTMP support planned for the 2.1 release.

Meanwhile, to fix this, here’s a simple workaround using rtmpdump.

First make sure you have rtmpdump installed. If not, you can install it using the Homebrew package manager:

brew install rtmpdump

Now make sure you have installed VLC and use the following command to play the RTMP streaming:

rtmpdump -r rtmp://foobar/live/stream --quiet | /Applications/ -

This will open VLC with a file named fd://0 on the playlist. Just click it and the streaming should be working.

You can create a vlc alias to make the command a lot simpler. Just add this in your .bashrc, .zshrc or .profile (choose with one applies) and restart the terminal:

alias vlc=/Applications/

If you don’t like to mess around with long terminal commands, here’s a bash function that makes it simpler:

function rtmp_open() {
        rtmpdump -r $1 --quiet | /Applications/ fd://0 --playlist-autostart

Just copy paste this into your .bashrc, .zshrc or .profile (choose which one applies), and restart the terminal.

I had to use fd://0 instead of - to refer to stdin due to a bug in VLC that ignores the --playlist-autostart when using - as input.

Now to run this handy function just type the name and the URL of the RTMP stream you want to play:

$ rtmp_open rtmp://foobar/live/stream

And that’s it. Enjoy :)

Raspberry Pi fun

Raspberry Pi logo

I got my Raspberry Pi three days ago, and I’ve been so busy “playing” with it, that I’m only writing this post now.

If you’re living under a rock, let me tell you that the Raspberry Pi is an awesome credit-card sized computer that costs $35. But the Raspberry Pi website puts it better:

The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. It’s a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video. We want to see it being used by kids all over the world to learn programming.

Yep, that’s right: kids. And guess what? All the grown ups are loving it :)

It’s mind-blowing the tons of cool things you can do with this little computer. The first thing I did with it was to install Raspbian Wheezy image on the SD card (Debian for the RPi, available in the Downloads section of the RPi website) and put a Node server running on it. The performance is pretty acceptable.

And there’s also the community around the RPi. All kinds of people from experienced programmers to beginners are showing off everyday new things that can be done. It’s a nice way to learn about the lower level stuff that goes on in your computer, and you can use it to control other stuff too, like robots, leds etc.

I’ll be writing here some of my experiences with the RPi as I get to know it better.

Meanwhile, here’s a photo of the unboxing:

Raspberry Pi unboxing

And a photo of the RPi running headless and being configured through SSH:

Raspberry Pi up and running

I bought it from InMotion, a portuguese online store. So if you are in Portugal, I highly recommend buying your Rpi from this store. It costs about 42€ and the service is very fast (ordered on a thursday and had it on monday).

So go get one, and feed your inner geek :)

Nodo v0.2.0 released

A new version of Nodo is out. Version v0.2.0 has the following features:

  • New actions star and unstar that makes possible to mark ou unmark a task as important.
  • UI improvements and some bug fixes.

This new version is now available on NPM. To upgrade use:

npm udpate -g nodo

Please report any issues you find on the github issues page.

Nodo, the simple command line task manager

Nodo is a command line task manager, and I love it! Why? Mainly because I developed it, second, it does exactly what I needed from a TODO app: it’s simple, easy and of course, it’s on the command line.

I spend most of the time on the command line (I’m even writing this post on it with Vim) so it comes natural the fact that I needed to find a task management application that has a CLI, avoiding the constant switch from keyboard to mouse and vice-versa. But still, I used Wunderlist, an awesome mac/windows/iphone/android TODO app, that was lacking such interface.

But there are already command line task managers!

Yes it’s true. I’m not going to mention them all, but let’s just say that none of them met my criteria. Some where too simple, some were just too complex (like TODO.txt) with tons of commands and options. Also, none of them supported my current Wunderlist database.

So I developed one task manager that suited my needs.

In Node.js? But I thought that Node.js was only good at X

Well, it turns out that Node is actually pretty good at allot of stuff. Including command line apps. But I have to agree that it’s not the best choice because there are no advantages in having non-blocking IO in this kind of app. But since I’ve been learning allot of Node lately, I really wanted to put in practice all my newly aquired skills. Also, NPM is a great package manager, and it’s ridiculously easy to publish new packages with it, not mentioning that it’s very interesting the fact that it’s entirely written in CouchDB.

Ok, so how does Nodo work?

It’s pretty simple. It has an NPM package, so you can install it with the npm command, just like this:

$ npm install -g nodo

A few seconds later, Nodo will be installed on your machine.

After install, Nodo comes with a default list called “inbox”. This list is where you should put all the tasks that you are not sure in which list to put them. So, to add a task to the inbox list just type the following:

$ nodo add inbox go shopping

Later, you decide to organize your tasks, so let’s create a list called “home” to contain all the home related tasks:

$ nodo add list home

And now, you can move your shopping task to this new list. Assuming that the shopping task has id 3:

$ nodo move 3 home

After you go shopping you can mark this task as done:

$ nodo done 3

This is just the Nodo basics. For the full usage instructions I recommend watching the screencast below, or visiting the Nodo page on Github.

Currently Nodo does not support adding/editing task notes, or setting a task as important, but these are all just features that are coming in the near future. Feel free to suggest features and/or fixes.

On using mac instead of linux ...

This is a very common and constant discussion at my workplace. And don’t get me wrong, I love linux. But Jamie Zawinski says it in way that is very similar to what I feel about it:

I use a Mac instead of Linux on the desktop for a reason: because I think that the design and consistency that Apple’s UI brings is extremely valuable. I don’t buy computers based on how fast they are, I buy them based on how easy it is to get things done with them, and Apple is the hands-down winner on this pretty much across the board. (Oh, also because I want my audio card to work, but that’s neither here nor there.)

This quote is taken from a post in his blog where he talks about why he prefers to use Safari instead of Firefox on his mac, and you can read it entirely here.

Having fun developing useless apps

I always thought that the first time I got on the Hacker News and Proggit front-pages would be with some awesome and complex project. I was wrong.

Part I - Like A Boss

On 25th November, while browsing the web, I found a funny project developed by Zach Holman called Fuck Yeah. This was a simple API developed in Node.js that received a piece of text, searched Google Images for that piece of text, and added that text along with a “Fuck Yeah!” to the first image found.

I found the project to be pretty cool, and since I got a little rusty with nodejs, I decided to fork the code and make a new version of the API, this time called Like a Boss. You can pretty much guess what it does. You can check out the code at Github by the way.

Since I had some spare time, I decided to go further and build a website that presented the generated images in a more good looking way. And here’s the result.

Hack Like A Boss

I decided to post the “Like a Boss” website to Hacker News. It got upvoted somehow, and BAM! Hacker News front-page. In 2 hours the website had about 2000 pageviews. This was cool, but not without some problems showing up that had to be solved in order to keep the code from crashing the server. Still, Heroku, the cloud application platform I used to host my nodejs app, handled all the traffic pretty well with only one web worker (included with the free plan).

After about 3 hours, the Hacker News post dropped from the front-page, and traffic almost vanished.

Part II - HTTP Cats API

On December 14th, again, while browsing the web, someone posted on Hacker News an awesome Flickr set of cat pictures authored by Tomomi Imura with each cat posing accordingly to a HTTP Status Code. These pictures ended up being a huge success.

I instantly thought about how awesome would be to have those cat images show up when an error occured on a web-server. I fired up vim and hacked some nodejs code to serve those images through a simple API. After some minutes, the HTTP Cats API was born. I pushed it to Heroku, and it was rocking. I sent the link to a couple of friends, we all laughed for a while and I thought that was it.

HTTP Cat 404 Not Found

After a while, I posted the API link to Hacker News and Proggit. The Hacker News post never got voted, the Proggit one got allot of upvotes, and soon I was on Proggit front-page. An avalanche of traffic ensued.

The post got duplicated on Hacker News, and this time it got allot of upvotes (probably a user with more influence). This was when all hell broke loose. Not only it got on the first-page it was also ranked in 2nd place.

The results where: on the first day I got 19.412 unique visitors. The second day, 21.764 unique visitors. The two days together summed up 255.034 pageviews. These values are amazing for a simple app that serves cat images. Actually, while I write this post, which is 2 months later, it still has around 100 unique visitors a day. And I’m not even counting direct API calls, just the index page visits.

So what?

Yeah, I know these web applications are pretty much useless, but I had allot of fun hacking them and watching the traffic hit the sites. And of course, it doesn’t really matter the fact that they are useless, as long as you have fun, learn and make other people smile, that’s what really matters.