Go again

That’s years that I’m trying to do something real with go. I mean, it is a very attractive language with quite a special workflow and toolbox. From time to time I write some small script for keeping contact with that language. Last week I made this one to list links pinned in our Greenruby slackroom to prepare the letter, So I can open them all at once to check them in my browser. With time passing, seems that Go now has a really complete collection of libraries for a lot of usages. I think I will have push a little the slack api soon, and maybe do some real go coding.


linux trick: too many logs

Recently I found my self again in that situation on a linux server. The partition where logs are stored went 100%. In such case, It’s clever top purge old useless logfiles. Typical move for me would be to run logrotate manually with

logrotate -f /etc/logrotate.conf

But I had a case where that was not enough. A developer forgot to remove a debugging output and the logs were just gathering way too much information, more than what I could free with some janitoring.

To avoid losing logs, we can move the logfile where there is space and replace the file with a symbolic link. That’s good enough for until the partition gets resized of the logs get cleaned. But when it’s done on a live logfile, the running process that writes into it still has the same file descriptor. The process has to be relaunched so the new fd can be taken in account, on the new partition, as instructed by the symbolic link.

So a colleague pointed out that could be done without restart by using gdb. It’s a pretty neat trick (if you have gdb installed on your production server, which may not always be the case, and for good reasons). Anyways I had it at hand, and here is the sequence:

touch /path/to/new/logfile

gdb -p pid

(gdb) call dup(1)
$1 = 3
(gdb) call close(1)
$2 = 0
(gdb) call open("/path/to/new/logfile", 2)
$3 = 1
(gdb) call close($1)
$4 = 0

This gave me the taste of digging up a little bit more on how gdb can interact with live processes.


Happy year of the Goat

Here it was Chinese New Year this week. A good occasion for those who are not familiar with chinese state of the web to read about its web design trends 2015. This article is pretty deep and reflects accurately how China uses its connectivity.

So, xin nian kuai le, and of course, gong xi fa cai. And if you need related icons, here are some.

Hello in Firefox

Now that I’m working from Taiwan with a French company, I was have been searching for a decent solution for video conferencing. Because skype and google-hangouts are just not things I like to use. I found out that new versions of firefox include by default a one to one webrtc feature, named Hello. It works pretty nicely. I also tried out Glideroom and Hutt. There are also heavier solutions that I tried in the past like the big blue button.

Unfortunately some dude in the ops team pointed out that webrtc was not secure, so it’s not likely to become a standard for us. Hrum, well, that’s debatable how proprietary solutions are more secure. There is no way to get it figured out. Anyways Webrtc became a w3c standard recently, and the section 12, named security, says: TBD. Let’s hope it will be done properly.

Any of you have some first hand experience with any alternative video conference system, please send me a mail with your feedback.


More Screens

Some time ago, when I left Faria, I bought a laptop with a clear purpose. I wanted to have on linux the same screen experience that I had with the macbook pro connected to 2 thunderbolts. So I got an asus UX301L plus 2 Dell screens U2713HM who supports a 2560x1440 resolution. The laptop in itself is amazing, dazzling fast, and all worked well with an ubuntu install. This was not cheap but that was a while I didn’t spend anything on hardware.

I struggled a bit to find the proper connectors so I could enable the extra large resolution on connected screens. I ended up using the mini-hdmi connector plus a mini-display port converter to DVI for the second one. And finally it worked last week. I had to force the resolution in xrandr and now I have a damn huge double display for a total of 7680x1440. What a blast!

Debian, i3wm and urxvt

Well this is an old story. Some time ago I switched from debian + fvwm2/ion to ubuntu + cinnamon just because I had to know about it. The goal was to be able to convince my wife (and some other non-techies) to switch to ubuntu. But I had to know how it worked on a daily basis. And it was a success for most of it.

2 years ago at Faria I was given a mac. Well, it was good to know a bit more about it, my mac knowledge was dating from system 6.7 time. But if the hardware is really good, the OSX experience didn’t really satisfy the geek that was deep inside me.

Then I got back into a team that is deeply attached to pure linux traditions, when I joined Gandi. I now switched back to a debian jessie with i3wm on my work laptop. Wow this feels good to be back to such a rude but flexible environment. As a matter of fact all went perfectly well and all the tricks I knew 10 years ago are still very valid.

I also took that occasion to get back into urxvt, for my terminal emulator. It’s a very badly documented over-powerful tool. But when you get the grasp on it, possibilities are much more satisfying than with gnome-terminal. I’m still working on my configuration to match few features that gnome terminal had (like font resizing, clipboard management). The notification plugin, combined with dunst, gives amazing results.

It feels good to be back into the cave. To mark this change, I didn’t shave for 3 months so now I’m really bearded like the old-fashioned linux bears. Muhaha!

PS: no worry, I’m still fullstack at heart and I still love ruby!


Greenruby 102


This week I got in contact with Sylvain from while42. It’s a social network for french tech engineers, but with a special touch on it. There is no facebook page or google group. They intentionally decided to be irl-first. For people that are most likely to be online all the time, this sounds so therapeutic! So, I decided, with Thomas from Gandi, to setup a Taiwan chapter. If you want to know more (and are french, engineer, and living in Taipei) just drop me a mail.

Traveling ruby

This is a project from the Phusion people, called Traveling ruby. Its purpose is to make it easy to build auto-sustaining tarballs for ruby programms, including ruby binary and all gems in it. That way you can publish a tarball and your customer/user will just launch whatever you put in it. No need to install ruby or any gems.

I gave it a try yesterday on my zabbix-ruby-client gem, and after a few tweaks (mostly because I wanted to use an unpublished version of my gem), it all worked pretty fine. Result is a tarball of 8M. Uploaded to the server (an old squeeze), it just ran the self-contained ruby 2.1.5 with no hassle. It reminded me a bit of the feeling when you upload a go executable on the server. Really neat.

Palm control

There are tiny things that can change a lot. My recent tiny thing is the palm control technique. Every sunday when I prepare Green Ruby I do a huge amount of copy pasting all over the place. Recently I found on a post about keyboard someone talking about the palm control technique for avoiding the copypaste fatigue.

Well, you need to have a keyboard that makes it possible. Mine is a Logitech washable k310. I already liked its look, and even better, it’s perfect for this palm thing because keys are prominent. Use the palm to push control and then it’s only a matter of hitting c or v with the index. Honestly, it changed my life!


Console columns

When you live in your console, it’s always good to find ways to stay there. The column command was recently brought to my attention by https://sysadmincasts.com/episodes/36-cli-monday-column-and-tr and despite years of console life, godamn I was unaware of this simple tool.

It is very useful for displaying csv files in a readable way, for example:

$ head members_export_0bfc48c38f.csv

yuck. Let’s prettify it.

$ head members_export_0bfc48c38f.csv | column -t -s,
24.7798   120.93     TW  HSZ
52.0927   5.1158     NL  UT
25.0389   121.509    TW  TPE
47.6836   -122.122   US  WA
24.1403   120.682    TW  TXG
37.4055   -122.078   US  CA
37.4055   -122.078   US  CA
37.4055   -122.078   US  CA
26.1405   -80.1738   US  FL

ohh, my world just changed!


Pretty json

JSON prettifying is a reccurent topic, every coder needs it to keep some sanity. My way to do it has been something like this for a while:

ruby -rjson -ropen-uri -rawesome_print -e "ap JSON.load(open('http://jsonip.com/'))"
       "ip" => "",
    "about" => "/about",
     "Pro!" => "http://getjsonip.com"

because when you are rubyist everything can be solve with ruby, obviously.

But well, then one day I did

pip install pjson

and then

curl -s http://jsonip.com | pjson
  "Pro!": "http://getjsonip.com",
  "about": "/about",
  "ip": ""

Faster, easier, happier.


Tree command

There is a shell tool that I install systematically on any new machine/server, it’s tree.

apt-get install tree


brew install tree

Its very basic usage is to show the content of a dir in an arborescent way, and there are a lot of options. It can be a good alternative to find sometimes. But I mostly use it for having a quick overview of the content of a dir.

mose@momac > ~ > tree projects/lolita
├── Gemfile
├── Gemfile.lock
├── README.md
├── config.default.yml
├── config.yml
├── lita-faria
│   ├── Gemfile
│   ├── LICENSE
│   ├── README.md
│   ├── Rakefile
│   ├── lib 
│   │   ├── lita
│   │   │   └── handlers
│   │   │       └── faria.rb
│   │   └── lita-faria.rb
│   ├── lita-faria.gemspec
│   └── spec
│       ├── lita
│       │   └── handlers
│       │       └── faria_spec.rb
│       └── spec_helper.rb
├── lita_config.rb
├── log 
└── tmp 

9 directories, 15 files

Some options:

mose@momac > ~ > tree projects/lolita -hfih -I 'spec|lib' --du
[ 164]  projects/lolita/Gemfile
[1.2K]  projects/lolita/Gemfile.lock
[1.2K]  projects/lolita/README.md
[ 177]  projects/lolita/config.default.yml
[ 222]  projects/lolita/config.yml
[2.6K]  projects/lolita/lita-faria
[  39]  projects/lolita/lita-faria/Gemfile
[1.0K]  projects/lolita/lita-faria/LICENSE
[ 357]  projects/lolita/lita-faria/README.md
[ 117]  projects/lolita/lita-faria/Rakefile
[ 769]  projects/lolita/lita-faria/lita-faria.gemspec
[1.2K]  projects/lolita/lita_config.rb
[ 102]  projects/lolita/log
[ 102]  projects/lolita/tmp

 7.4K used in 3 directories, 11 files

man tree for more (but the basic tree view is the real deal, for more detailled listings, find is better).


SQL in a shell

There is a package that is not installed by default that I now grab systematically, it’s called parallel.

apt-get install parallel

or on mac

brew install parallel

The parallel command is a pretty complex beast, but the package also comes with the sql command, which simplifies queries to any database from the console. There is just one command whatever the sql backend you use.

I first setup my dburl in .sql/aliases as:

:dbmb mysql:///managebac
:dboa mysql:///openapply
:dbis psql://isis:password@localhost/intersis

And I can then use those aliases for quick sql commands:

sql :dbmb "select count(*) from users"
sql --show-processlist :dbis

Check http://www.gnu.org/software/parallel/sql.html for more examples of use. Also check http://www.gnu.org/software/parallel/package it’s very powerful, but a bit complicated to catch it, maybe I will provide some examples of practical use in a later tip.


Less first

When working on a remote server, I use less instead of tail or vi to check files, the more I can.


  • with &searchstring it will hide all lines not matching searchstring, like a very simple grep from the console
  • just & with nothing to get back to full view

edit file

  • when in less /etc/hosts if I find out I need to edit it I just type v it opens it in vi
  • when you quit the editor you are back in less

follow mode

  • when in less production.log, if you want to follow incoming changes type F it will become like a tail -f but it keeps the syntax highlighting that was made with a / search - when in follow mode with F you can ctrl-c any time and examine the new stuff
  • note that if you are in filter mode the follow respects it (like if you did a grep something/var/log/auth.log | grep 'Invalid user')


  • you can open several file and navigate like in vim with :n and :p
  • when less is open you can open a new file with :e

call options inside less

  • you can call any launch option from inside less, one I use often is -S that will enable/disable wrapping of long lines, very useful when parsing web server log files
  • to disable/enable search highlighting just -G
  • any other launch option can be called from inside less, pretty convenient