27 Feb 2015

Links for the weekend 09 - 2015

Interesting links I’ve bookmarked this week:

21 Feb 2015

Linux, display local IP before login prompt

I might need to ship one of my applications to a customer as a VM. This application is a web app, so in order to use the application they’ll need to run the VM and just point their browser to the VM IP address.

I’d like to show the local IP address without login in the VM first.

It turns out that the file I’m looking for is /etc/issue (there’s another one for remote logins called /etc/issue.net, but I don’t think I need this).

Whatever you put in this file, it will be displayed before the login prompt.

Now we just need to update this file every time the system starts. For that I added this code to /etc/rc.local:

#!/bin/sh -e

IP=$(hostname -I)
echo "Hey, navigate to http://$IP to use my awesome app!" > /etc/issue

20 Feb 2015

Links for the weekend 08 - 2015

Interesting links I’ve bookmarked this week:

13 Feb 2015

Links for the weekend 07 - 2015

Interesting links I’ve bookmarked this week:

06 Feb 2015

Links for the weekend 06 - 2015

Interesting links I’ve bookmarked this week:

01 Feb 2015

Migrated to Hugo

As I explained a few weeks ago, I’m migrating all my blogs and static sites from Wordpress to Hugo.

Even though this site was not using Wordpress but Jekyll, I feel it’s better to just use one tool across all my websites. Also, I like Hugo more ;)

I’d say that migrating from Jekyll to Hugo is even easier than migrating from Wordpress. The main pain point are the templates.

I’m incapable of doing a beautiful site, so I’ve grabbed the purehugo theme and made some tweaks here and there.

Also this blog is now in a public repository in github.

31 Jan 2015

Exploring reactjs

There’s been a lot of activity around the announcement of React Native this week. I’ve been wanting to take a look at reactjs for sometime. I don’t know exactly where I am on the javascript learning ladder, but I’m starting to feel the urgency of putting some kind of organization on my javascript code.

The best way to experience a new technology, language, framework or library is to build something for yourself. So after reading a couple of tutorials I decided to try to build something.

I keep a list of the movies I watch, just because, you know, maybe someday will be interesting to analize the data. Anyway, I’ve tried to use reactjs to show the posters of those movies. Who knows, maybe I could use it in the future to show the movies I watch in this blog.

In order to get the posters I’m using the Rotten Tomatoes API. The code just uses an array of movie titles, make an API request for each one and returns it’s image.

It was necessary to throttle the AJAX requests as the API only allows you to make 5 req/s.

Here is the code in case you are interested: react-movies in github

react-movies image

I have to say that I like reactjs. I plan to dive deeper to see if it will help me improve my javascript applications.

28 Jan 2015

git cherry

Today I learned about git cherry. I knew about cherry-pick, which I use from time to time, but this is a different cherry.

In one of my projects, a desktop application, I maintain a branch per released version. This way I have branches like production-5.0, production-5.1 and so on.

From time to time I make some changes that need to go to master too. Instead of merging and getting a lot of noise, I sometimes cherry-pick those commits to add them to master.

The problem is that sometimes I don’t know which commits has been back-ported to master. git cherry is useful in this situation:

$ git cherry -v master production-5.1
- d326c2997eb355eb79d4974e2e4a75a4bcc7755d gen_searches fix description
- d326c2997eb355eb79d4974e2e4a75a4bcc7755d gen_searches sex filter
+ 7b804f83de325f31b43f372793a5acaf563b8ec9 select result and compare it as known parental against other results

In this example, the first two commits are already on master, and the third one is not.

Now I only have to cherry-pick the third one and I’m done.

26 Oct 2014

Removing complexity hosting static websites

The incident

One of my product websites was hit with the Google Viagra Hack. This hack injects different content to your website when is fetched by Google.

It’s subtle because you might not be aware of it for weeks. When you visit your site everything seems fine. If you take a look at your source files, everything is fine. However, when Google crawls your site it only finds Viagra links and related content.

When you google your site, you’ll find that it displays an scary message:

This site may be hacked

And the descriptions altered with medicine ads.

The investigation

Ok, so someone somehow managed to change the content of my website, at least to Google. After the initial panic, I used Google Webmaster Tools to see my website through Google eyes. It was a mess.

I investigate a bit this hack and it seems that it’s just a script that takes advantage of some PHP plugin or misconfiguration. On my website root folder there was an obfuscated PHP files called stats.php.

This website, as many others I have to maintain, are just static content. HTML, CSS and JS client code. Some of these websites are hosted on Dreamhost, together with some old WP blogs and old PHP websites, and they are likely to be the door to this hack.

My resolution: simplify

I’ve been migrating my websites away from WordPress for some months. First I discovered Jekyll but now I’m using Hugo. It just feels right to have my content as version controlled files instead of having a full PHP framework running including a MySQL database.

In my view the next logical step is to get away from traditional hosting all together. There are several alternatives like using Dropbox+Github or using Amazon S3.

I chose the later.

Hosting static websites in Amazon S3

The setup is very simple.

Basically you create a bucket with your website address, put there your files, configure the bucket to serve the website and update DNS records using Amazon Route 53.

22 Oct 2014

Make vim and command-T work on Yosemite

The upgrade from Marvericks to Yosemite went smoothly except for one thing: vim is segfaulting every time I use Commant-T

The most common answer is that vim has been compiled with a different ruby version than Command-T. However, after being sure to recompile Command-T the problem was still there.

Turns out that I had Command-T on the vim’s plugin directory. After removing it and cloning it into ~.vim/bundle, and recompiling it with:

ruby extconf.rb

it started working again. Be sure to leave no Commant-T files on the plugin folder. I left commant-t.vim by mistake and even though I was no longer getting SEGFAULTs, command-t was not working properly.

Older posts...