Comments

Checkout a repo, brand new gemset, run the test suite which for sure is running green on at least 3 of your colleagues machines and Boom! the tests are not passing on yours!

And there it starts the infinite debugging.

One of the Cucumber tests not passing had a css selector like the following:

1
2
3
4
5
6
7
8
Then /^I can edit something$/ do
  within("#something tr td:nth-child(2)") do
    click_link "Edit"
  end

  # [...]

end

which had nothing strange in it; plus I could actually see in the browser, using save_and_open_page that the elements that Capybara was supposed to select, were actually there.

WTF THEN?!?

After some time shooting in the dark, reinstalling and banging the head against the desk, I figured that the problem should have been related to some system library I was using and it turned out I was right.

Capybara has a wrapper around our friend Nokogiri that wraps libxml2 and the only difference between my machine and my colleagues ones could have been exactly the version of libxml2. To prove the theory at that point, I just had to install and older version of libxml2 and reinstall nokogiri before running the test suite again:

1
2
3
4
5
6
7
8
9
10
11
12
~> brew versions libxml2
2.9.1    git checkout 31caa27 /usr/local/Library/Formula/libxml2.rb
2.9.0    git checkout 5dd45d7 /usr/local/Library/Formula/libxml2.rb
2.8.0    git checkout 763d946 /usr/local/Library/Formula/libxml2.rb
2.7.8    git checkout 497b13a /usr/local/Library/Formula/libxml2.rb
2.7.7    git checkout f4a925d /usr/local/Library/Formula/libxml2.rb
2.7.6    git checkout 8939a91 /usr/local/Library/Formula/libxml2.rb
~> brew tap homebrew/versions
~> cd /usr/local
~> git checkout 497b13a /usr/local/Library/Formula/libxml2.rb
~> brew install libxml2
~> brew link --force libxml2

and libxslt:

1
2
3
4
5
6
~> brew versions libxslt
1.1.28   git checkout 98d5e91 Library/Formula/libxslt.rb
1.1.26   git checkout 2053036 Library/Formula/libxslt.rb
~> git checkout 2053036 Library/Formula/libxslt.rb
~> brew install libxslt
~> brew link --force libxslt

then nokogiri:

1
2
~> gem uninstall nokogiri
~> gem install nokogiri

That was it! Tests running, all green! F@#k YEAH!

Now surely we can update the test suite to work with the latest libxml2 :P

Happy coding.

Comments

Today it was a total waste of time as I was trying to figure out why the F* nokogiri was not getting installed into my new project gemset. First thing I had to figure out, was that Nokogiri now ships with libxml2 and libxslt that get compiled and installed with the gem itself. Second thing was that libxslt was not getting compiled because it could not find an “acceptable grep”! Go figure! After many trials and unfruitful google searches I decided to try with a different user and that maybe, if google was not returning any useful result, it was my configuration that was weird. It turned out that I was correct and the problem was related to my GREP_OPTIONS. I had the following in my .zshrc

1
export GREP_OPTIONS="--exclude-dir=.svn --exclude-dir=.git -nR --color"

and, after removing the -nR options, I was finally able to install nokogiri correctly.

Comments

I’ve finally had the time and the strength to get back to my old blog and give it a new look.

I feel guilty about having abandoned it for long time :(

I promise, blog, I won’t leave you alone again.

Comments

I’ve been delaying this migrations for ages now but here we are, it finally happened: I can write a blog post with my favourite editor now (Vim) and publish it to the web like a pro on my favourite dev website (GitHub) using git… that’s too many emotions for one single day :P

So, how did I do it?

There are tons of tutorials already on the net that explain very well how to migrate from Wordpress to Octopress so I’m not going to explain here all the details but make just a quick summary even for myself as a note:

  • Download, install and follow the instructions of exitwp
  • Run a regex to fix the code blocks like:
1
perl -pi -e 's/([^\`]|^)(\`)([^\`]|$)/$1\n\`\`\`\n$3/g' *
  • If you have been using Disqus on Wordpress before moving to Octopress, for some reason exitwp doesn’t add the comments: true parameter in the posts so use this sed command to fix it:
1
2
3
find _posts/ -type f -print0 | xargs -0 -I file sed -i '' '2 i\
comments: true
' file
  • Octopress posts url is different from the Wordpress one so you’re going to have to remap the Disqus comments using their migration tool and a bit of patience

The next step will be playing with the theme to make it more “personal” :)

Comments

Canonical, seriously, what’s wrong with you people? How dare you calling the 12.04 a LTS version? Have you testend on EC2? and cloud-init? It’s a bloody mess!

So, you upgraded and mod_rpaf behind your proxy is not working anymore? Do this:

FROM =====>

1
2
3
4
5
<IfModule mod_rpaf.c>
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1
</IfModule>

TO =======>

1
2
3
4
5
<IfModule mod_rpaf-2.0.c>
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1
</IfModule>

Find the differences and thank this guy that find it before me.

Comments

Just dont waste your life and use curl if you need to do that.

I know, this is a useless post but I just wasted a huge amount of time trying to find a solution and I feel like giving this advice to someone.

happy testing :)

Comments

Tired of this:

1
2
3
4
5
6
7
8
9
10
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_CTYPE = "en_GB.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

Do this:

1
2
3
4
5
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales

Be happy again :)

Comments

new ruby version is out and it’s time to upgrade! The first try gave me this error:

1
2
3
?  ~  rvm install 1.9.3-p125
Error running ' ./configure --prefix=/Users/antonio/.rvm/rubies/ruby-1.9.3-p125 --enable-shared --disable-install-doc --with-libyaml --with-opt-dir=/Users/antonio/.rvm/usr ', please read /Users/antonio/.rvm/log/ruby-1.9.3-p125/configure.log
There has been an error while running configure. Halting the installation.

Adding the compiler option “—with-gcc=clang” worked:

1
2
?  ~  rvm install 1.9.3-p125 --with-gcc=clang
Install of ruby-1.9.3-p125 - #complete

enjoy Ruby :)

Comments

Thanks to a gist (which I forked and slightly changed) I was able to finally install Nokogiri on my mac:

If you had MacPorts previously installed, it might still not work so

1
sudo mv /opt/local /opt/local_old

and try again.

Enjoy :)

mac
Comments

The easiest way of getting an OpenVPN client on mac is with Tunnelblick but you will join the VPN only when you have logged in. Sometimes you need your mac to connect at startup instead and I’ll show you how to do it:

create /etc/rc.local and copy/paste the following three lines in it:

1
2
3
#!/bin/bash
/sbin/kextload /Applications/Tunnelblick.app/Contents/Resources/tap.kext
/sbin/kextload /Applications/Tunnelblick.app/Contents/Resources/tun.kext

then create a Launch script like this for each of the vpn you want to connect to, replacing YOURVPNNAME, YOURCONFIGFILE, YOUR/CONFIG/FOLDER accordingly:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.openvpn.YOURVPNNAME</string>
<key>OnDemand</key>
<false/>
<key>Program</key>
<string>/Applications/Tunnelblick.app/Contents/Resources/openvpn</string>
<key>ProgramArguments</key>
<array>
<string>openvpn</string>
<string>--config</string>
<string>YOURCONFIGFILE.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>TimeOut</key>
<integer>90</integer>
<key>WorkingDirectory</key>
<string>YOUR/CONFIG/FOLDER</string>
</dict>
</plist>

save each script into /Library/LaunchDaemons/ folder using a name for the file like org.openvpn.YOURVPNNAME.plist, then change the user and group to root:wheel with the following command in a terminal window:

1
sudo chown root:wheel /Library/LaunchDaemon/org.openvpn.YOURVPNNAME

last commands to register and execute your Launch scripts are:

1
2
sudo launchctl load /Library/LaunchDaemon/org.openvpn.YOURVPNNAME.plist
sudo launchctl start org.openvpn.YOURVPNNAME

a restart should be the very last thing to do and once your mac has started you shoud be connected to your vpn network(s)!

enjoy ;)

UPDATE: the new version of tunnelblick 3.2beta26 does have the the “connect when computer starts” functionality that automatically makes this post obsolete. I’ll just keep it for the records :)