SSH Keep Alive

Something that annoys me is when after a period of a couple of mins a firewall kills your ssh connection! Then you have a dead terminal that can take ages to timeout. So this is a solution, keeping it alive…

ssh -o TCPKeepAlive=yes user@some.host.com

Dead easy. I also have an alias in my .bashrc file in my home directory.

alias shortname=’ssh -C -o TCPKeepAlive=yes user@some.host.com’

So all have to do is type ‘shortname’ in the terminal and it would connect me to some.host.com. Much better. The big ‘C’ btw is for compression.

Text Message Alerts

I have long been interested in setting up my computer so that it is possible for it to tell me what is going on via sms messaging. This would be useful for both my day job and also to alert me to interesting things that it might detect. So I finally got round to setting it up.

Using an old Huawie E220 GSM modem and the linux package called gammu-smsd all of my software can now send me texts. I used to use the modem for mobile broadband but I upgraded to MiFi so I got an ordinary pay as you go sim card for the modem and set it up. These modems are perfectly capable of sending texts. I chose the gammu-smsd because it has the option of using a mysql backend. One tip is that the mysql tables are provided in a file which is included in the distributed source code. Also I ran tail on /var/log/messages (Opensuse – do the same for your version of linux) to see which device the modem is attached too. You can force it use the same one if you like. I might end up doing this if it causes a problem.

Using mysql is handy because you can send a message by directly writing the messsage details in the the outbox table in the database. Easy. I wrote a very simple Java interface to the mysql database that all of my programs can connect to. Any program can use the Java library to inject a message into the database and then it is promptly sent. The computer set up to send the sms messages doesn’t even have to be the computer that is running the simulation. One machine with an accessible database can provide a messaging service for any number of computers. There are alternative approaches but this seemed the easiest to set up quickly.

This is helpful because often simulations take a long time to run and it is useful to be able to leave them to it knowing that I will be notified when the task has completed, or if the task failed for some reason (there is nothing more annoying than finding out that a simulation stopped for some reason the minute you turned your back). I can then log back into the machine and either start the next simulation or whatever. I can also set it to alert me to interesting market events.

Making R Load libraries at startup

There are sometimes things that I want to do, and have to spend a while figuring out. So I am going to store that knowledge on here.

Loading R libraries at start… (works in Opensuse linux)

Easy, create a file in /usr/lib64/R/etc called ‘Rprofile.site’. Put in that file the libraries you want to load.

library(ggplot2)

When you load R those libraries with be loaded.

Right, next time I reinstall my system I will know where to look if I have forgotten…

WP HTTP Error: connect() timed out!

That error up there has been causing me some head scratching. I couldn’t figure out what the problem was, and it causes issues with different parts of WordPress. I was seeing it on the Dashboard but it stops things like upgrades and plugins installing. I tried different solutions, adding .htaccess files etc etc. None of it looked that convincing, and none of it worked. Then one evening, this evening in fact, as I uploaded the newest version of WordPress (3.2) because the automatic update wouldn’t work it occured to me that I hadn’t tried poking the firewall.

It was the bloody firewall! Blocking all outgoing connections. Although this is good for security its not good for WordPress. So if you are seeing this error and have tried everything else. Take a look at your firewall. I wish I had weeks ago.

Making dirs in linux

I sometimes forget how to do stuff so I think I will start writing it down….

Here is how to makes some dirs…

make one dir

mkdir the_dir

make a whole path

mdkir -p ~/the/path/of/dirs/to/make

make a dir with more dirs inside it

mikdir -p a_dir/{inside_dir,inside_dir2}

I will probably remember it all now…