Where do we go now?

Score: 7/10.

I decided to make this technical, “boring” blog more fun ūüôā So from now on, I will occasionally write about the films I am watching. Today’s film was “Where do we go now?” by¬†Nadine Labaki. A few years ago I watched her¬†first film, “Caramel” in the cinema, which was a surprisingly well directed film. Labaki was not just the film’s director, script writer, but she also played the main character in the film.

Last year she made another great film, “Where do we go now?”, with the same roles above, but this time the script was written in¬†collaboration¬†with another four people. The movie is about a¬†group of Lebanese women trying to ease religious tensions between Christians and Muslims in their village. It is a colourful, fun, dramatic story.

I found the movie’s trailer a bit of a spoiler, but if you want to see it, here it is:

A Scotsman walks into the Bank of England…

A Scotsman walks into the Bank of England in Threadneedle Street, Central London and asks for the manager. He tells the manager that he is going to Australia on business for two weeks and needs to borrow £5,000.

The manager tells him that the bank will need some form of security for the loan, so Hamish hands over the keys and documents of new Ferrari parked on the street in front of the bank. He produces the Log Book and everything checks out. The manager agrees to accept the car as collateral for the loan.

The bank’s General Manager and its officers all enjoy a good laugh at the rough looking Scotsman for using a ¬£120,000 Ferrari as collateral against a ¬£5000 loan. An employee of the bank then drives the Ferrari into the bank’s underground garage and parks it there.

Two weeks later, Hamish returns, repays the £5,000 and the interest, which comes to £15.41.

The manager says, “Sir, we are very happy to have had your business and this transaction has worked out very nicely, but we are a little puzzled. While you were away, we checked you out and found that you are a multi millionaire. What puzzles us is, why would you bother to borrow ¬£5,000?‚ÄĚ

Hamish replies: “Where else in London can I park my car for two weeks for only ¬£15.41 and expect it to be there when I return:”

Ah, the mind of the Scotsman….

Preventing ssh disconnections occuring due to time out

If you are getting connection drop outs after a certain idle time while connected to an ssh server, this is probably due to some short time out periods set in the server’s configuration. That’s easy to solve, unless the problem stems from another network issue. When connecting next time, if you set the following ssh options, you shouldn’t be getting disconnected automatically anymore:

ssh -o TCPKeepAlive=no -o ServerAliveInterval=30 your_user_name@some_domain.com

You may either change your ssh client’s config to make these options permanent, or set an ssh name alias under your .bashrc in Linux:

alias ssh=’ssh -o TCPKeepAlive=no -o ServerAliveInterval=30′;

This way, you won’t have to specify these options again. Just start a new terminal or “source” your .bashrc after making this change:

source /path/to/.bashrc

This solution has the benefit of not requiring any configuration change on the server side, which is handy, because you may not have a permission to make any change on the server side.

Alternatively, if you have access to the server configuration, then you can add these lines to your server’s /etc/ssh/sshd_config file:

ClientAliveInterval 30
TCPKeepAlive yes
ClientAliveCountMax 99999

To activate the new settings you will need to restart your ssh server.

Linux tips — III

It is common practice to substitute or change all occurrences of a certain word, date or number etc. with something else in a text file. In Linux, the most typical way of doing this, of course, is to use a text editor such as Vi (Vim) or Emacs, but there is a command line alternative, which is faster particularly for large files. This command, for example, will replace all occurrences of “word1” in “file1” with “word2”, and save the edited version as a new file, called “file2”:

sed “s/word1/word2/g” file1 > file2

sed is a Swiss knife. It can do a multitude of things as this nice tutorial explains. It is one of the most advanced command tool utilities in Linux. Its use is not limited to making simple substitutions, it is a complete stream editor.

There are alternatives to sed. If you are already familiar with the Perl programming language, you can make substitutions in a text file without having to use an editor, that is, from the command line:

perl -i -pe ‘s/word1/word2/;’ myFiles*

By adding a find statement in front of this command, you can edit all files in all sub-directories at once, something no text editor can provide. For example, this command will convert all “protected” Java methods to “private”, in all files ending with “.java”:

find . -name ‘*.java’ -print | xargs perl -pi -e’s/protected/private/’

Happy fast text substitutions!