…with an open minded approach

Posts tagged “ruby

Ruby: pass file descriptor between processes with unix sockets

The gist is (hopefully) self-explanatory – if not, read the header notes

Long story short – use UNIXSocket.send_io/recv_io to pass a file-descriptor between 2 processes.

Also, learned some Jruby limitations (?bug?):

  • Jruby cannot fork()
  • Jruby has UNIXSocket#send_io/recv_io broken, so its not possible to pass file-descriptors with Jruby… what a pitty…

And learned that working with Unix socket in ruby is soooo easy 🙂

git overview

Git is outstanding… so much that at some point, it can get confusing to use it without properly understanding what is happening behind the scenes…

The best tutorial that I’ve found so far, for my level of understanding and my needs, is Vogella’s Distributed Version Control with Git, which is generously available for reading online or in amazon as a kindle ebook

Also found very usefull to see the interactive Git CheatSheet from NDP Software


An option I use a lot is ‘git merge –no-ff’, which does one git merge without fast-forwarding  – see this discussion which explains what is the difference between a merge with fast-forward and a merge without fast-forward. If you endup finally liking this option as much as I do, you can enable it for all your git merge’s, of all your projects (all of it, be aware!) by adding into your ‘~/.gitconfig’ the following:



There – hope it is as useful to you as it is for me 🙂

ascii.io: youtube-for-the-console

I’ve started using http://ascii.io/ as a way to easily share console-kung-fu-tricks

Have a look at my simple example here

Looks very promising, and the guy who made it, is going conference-after-conference talking about it, and seems raising the interest of many around him, so a promise is in the air for future capabilities such as embed asciicast in your own webpage, client-side (offline) player, etc

Testing a VPS machine

Just rented a Vps machine running ubuntu 12.04 lts 32bits… its virtualized with KVM, promissing 512MB Ram, 10GB HDD and 1TGB bw… for 3€/month with a promo until 6/01/2013 (what a bargain!) I can only think they are setting up the VPS service and need “testers”… the site itself is almost naked… and in less than a day, I’ve already experienced the first network-cuttof… but somehow it rocks for a “hobby” server

Well,  I’m very excited… a lot to play bound only by imagination limits 🙂

I’ll leave here some notes about what I did

Well, I’m overthrilled!!!!

DCI in Ruby

DCI paradigm is a hot topic in the ruby community right now – created by the same person that invented MVC paradigm, compatible with Rails, proposes a decouple between program Data and user Intereactions, …

If you want, have a look at the following link – the best one I found for my level of comprehension



Backup or clone RVM to other user: copy the “~/.rvm” directory

…and  a few other files


This method is not reliable- inside the .rvm folder, there are files which contain the pathnames (which contain the original user-name “user-x“) hardcoded inside.

See erhard karger comment which explains it, as he tried to clone the .rvm directory


user-x has RVM instaled in it’s home folder, with severall ruby versions, and severall gemsets… all goes well and he is very happy – he has everything very well setted up!

user-y does not have RVM installed, and he would like to have everything user-x has: the RVM, the rubys, the gemsets, the configuration tweeks…  everything as user-x


user-y could start to install the RVM, and then proceed to install the same ruby versions, and the same gems, etc… to end up with an instalation similar to that of user-x, that would end up to be same after some time.

But, there is a simpler solution: user-y can simply ask user-x to give him a full copy of the following files/directories from his $HOME:

folder: .rvm

files: .bashrc, irbrc, .gemrc

And by simply copying those from the /home/user-x into /home/user-y it is possible to have all the RVM cloned from user-x to  user-y.


– really easier/faster than to install ruby, gems, and install all step by tep…

– this can be used to make backups of the RVM installation

hope it helps someone – if it does, drop a comment 🙂

Note that this method is NOT FIABLE! Nonetheless, this worked for me – that was the reason why I wrote the post.  I used a Ubuntu box, with 2 users that belonged both to a same group – and copied and changed user-ownership of the copied files, and everything worked… but now it just seems a miracle 🙂  (although it keeps working!)

Final line is:  worked for my particular case, but it’s not a general or recommended method at all…

Ruby Version Manager: the way to manage multiple Ruby installations

If you use multiple Ruby versions, with multiple ruby gems for each version (for compatibility), then you *need* to learn about RVM, the Ruby Version Manager.

RVM in short will make it very easy to install any of the many ruby versions,  just by indicating the version (it will download, compile, etc…).

Plus, it can also manage separate “gemsets” which are groups of gems, so that you indicate which gemset you want the ruby to see/use.

And it can make it all within a user account, without the need to do any “system-wide” install (no sudo’s) – so why not give it a try?

I’ve installed it for the first time (very easy), and never more went back – do recommend.

RVM installation is already covered with plenty instalations tutorials over the net and usage is very well documented in the RVM site,  so you can easily get started.