Accessing’s API

July 7, 2017

In order to find jobs in via API you can get the credentials in

Jobs from Indeed

Tic Tac Toe bot in Bash

April 6, 2017

Bash’s tic tac toe code that translates the code from Perl’s bot.

I got inspiration from

Basically the bash code recreates the strategies for:

Making a winning move.

Preventing the opponent from making a winning move

Obtaining a “fork”

Preventing the opponent from being able to fork

Taking the center square

The challenges I faced are briefly summarized below:

  • Finding corresponding functionality in bash for perl’s grep and substitution.
  • Updating the variables, since they don’t get automatically changed like in perl. E.g. in Perl the expression grep { /$piece/ && /$move/ && /\d${piece}?\d/ } @wins would at the same time filter @wins and alter it.
  • Placing the returns in the appropriate places and to clear the variables used for accumulation.

The script: tttbot_blog

Note: You can use cygwin64 to run this script in windows.  However, DO NOT copy and paste the script, as windows introduces \r characters.  Rather, rename the script from tttbot_blog.doc to or tttbot_blog and run it in bash.

To-do: The performance of the bash program is slow. Please wait for up to 15 seconds in the second player’s move and 10 or less for subsequent moves.

awk: script created in 1988 still works

March 22, 2017

I have been using bash recently, and it turned out that some powerful regex options are available via awk.  I looked around and found a book written by the original awk authors Aho, Weinberger, and Kernighan:“The AWK Programming Language”

I found a graph in Chapter 6 that called my attention and I wanted to reproduce it:


So I copied the code from this old book and soon found out that parts of the code were not copied, parts were copied incorrectly (instead of $ y got 5, or instead of } I got ), etc), so I set off to debug it.

Finally I got it to work and after making up some entries for the data, there are two files you need to run it.  Only docx format is allowed in wordpress, so the files below have the extension docx but they are just plain text files.

graph1 (code)


You need to run them as shown below, i.e. either rename them to have no extension or copy the text to some files without extension.

awk -f graph1 data

So I got the following:


Notice that I used cygwin so I can run it in windows:

Additional reference:

AWK -wiki




Toshiba Satellite: Upgrading from Windows 8 to Windows 8.1

January 14, 2014

This post shows the steps needed to upgrade from Windows 8.0 into 8.1. 

The motivation for this is to be able to bypass the lock screen and the applications screen and to go directly to the Desktop.  This appears to be possible only with Windows 8.1 as it is explained in the link below:

So I set off to download windows8.1, which can be obtained for free for 8.0 users from this link

Once on that page click on the link WINDOWS STORE, which you will find surrounded by the text shown below:

“Already running Windows 8? Update to Windows 8.1 for free through the Windows Store.”

Make sure that your power settings are such that the disk never go to sleep or hibernate and the display never turns off.

With my internet connection it took several hours to download the 3.5 GB upgrade. I left it overnight downloading. It appears that after it finished downloading, it automatically restarted the laptop, which was unattended.  The day after I found out that the installation had finished.

Toshiba has some precautions prior to installing the upgrade:

However, as I said, I couldn’t get to act on them because the upgrade had finished, yet the upgrade appeared to have finished successfully.

I setup the laptop to boot to the desktop as mentioned in the link above: see the part highlighted:


Now my laptop has a look and feel closer to what I am used to.

Raspberry pi sending temperature readings to email

March 7, 2013

To send temperatures to an email address I based my script on Matthew Kirk’s.  In his work Matthew describes the devices and the connections to the rpi via the GPIO connectors.

Link to Temperature Sensor

1. I have created a script that collects the temperature every 10min.  Twice a day it sends it to an email specified in
2. The modified script also adds the file temp_start to /etc/init.d/  so that the script starts when the rpi is connected.

The contents of temp_start are:
sudo python /home/pi/

To move the file to the init.d folder and to make it executable:

sudo mv /temp_start /etc/init.d/

sudo chmod +x /etc/init.d/temp_start

sudo update-rc.d temp_start defaults is shown at the end.

3. Make sure to change your email address and password in  Script is shown at the end.
4. Change the UK time:
sudo dpkg-reconfigure tzdataScripts:

5. Sample contents of the email received:

Wed Mar  6 13:49:48 2013 79.25
Wed Mar  6 13:56:53 2013 79.10825
Wed Mar  6 13:59:49 2013 79.10825
Wed Mar  6 14:06:54 2013 78.96875
Wed Mar  6 14:09:50 2013 78.827
Wed Mar  6 14:16:55 2013 79.10825
Wed Mar  6 14:19:51 2013 79.3895
Wed Mar  6 14:26:56 2013 79.3895
Wed Mar  6 14:29:52 2013 79.25
Wed Mar  6 14:36:57 2013 79.25
Wed Mar  6 14:39:53 2013 79.3895
Wed Mar  6 14:46:57 2013 78.96875
Wed Mar  6 14:49:54 2013 79.10825
Wed Mar  6 14:56:58 2013 79.25
Wed Mar  6 14:59:55 2013 79.25
Wed Mar  6 15:06:59 2013 78.96875 …

Displaying the name of the table when using sp_MSforeachtable

February 27, 2013

sp_MSforeachtable is very handy in displaying the contents of tables.

Besides displaying the contents, also displaying the name of the table can be done with the ? variable surrounded by ”.  Notice that for each single ‘, two must be used:

declare @q1 varchar(1000) =

exec(”select ””?”” as [table_name]”)
declare @q varchar(1000)
set @q=”select top 10 * from ?”

EXEC sp_MSforeachtable @command1=@q1


– If something doesn’t work, troubleshooting the contents of @q1 can be done with:

select @q1

-A filter can be added to the sp:

EXEC sp_MSforeachtable @command1=@q1,@whereand=’and object_id in (your_list_here) ‘

–the @whereand comes from:
select * from sys.objects where object_id in (your_list_here)

Transferring mail from Mac 10.4 to Mac 10.8.2

February 10, 2013

The process of transferring mail using Migration Assistant didn’t work.  It showed a message along the lines of “Upgrade Migration Assistant in the source Mac”.  I have not been able to upgrade the app.

Instead, I opened Mail for the first time in the new Mac and that created the necessary folders in the Mail folder (

Trying to display the Mail folder under the Library in order to copy and paste can be done with (

Launch Terminal from Spotlight or Launchpad -> Utilities, and enter the following command to show or hide the directory:
chflags nohidden ~/Library/

The users Library folder will immediately become visible again. Reverting this back to the standard Lion setting is simple too:

This returns to the default setting of hiding the user Library directory:
chflags hidden ~/Library/

Changes take effect immediately again, and Library becomes invisible to the user.

After doing that, I copied the Mail folder from the old Mac into the Library with a name Mail_old.

I overwrote INBOX.mbox and Sent Messages.mbox in the  Mail/V2/POP-user@incoming.server  with the old contents.

Ensure you quit Mail.

Delete the Mail/V2/MailData/Envelope Index* to force Mail to reindex upon starting it again.  See

Upon reopening Mail, the Mail Message  Import process gets started and the mail shows in the Inbox and Sent boxes.

Connecting to the raspberry pi via TightVNC Viewer

January 12, 2013

The information below was taken from the link:    The modifications I used are underlined.

Well here we go.

Login to your RPi with putty

#sudo apt-get update  #run this if you need an update
sudo apt-get install vnc-server

follow the instructions to add a server password confirm the password say no to the view only option

Close your putty window but leave your RPi running if you reboot shutdown or restart your RPi you will need to re-run vncserver from the command line as it’s not added automatically to the start up script.

NOTE: If you use sudo su or sudo bash or one of the other commands to change to a root login to install vnc-server you need to get back to a pi login before you run vncserver to set the password it goes through the motions if your logged in as root but if you look at the response root is debarred from this action.

Setting up the PC

Now you need to get some software for your PC use your browser and visit

I got the Installer for Windows (32-bit) (1,744,896 bytes) rather than the Java viewer [florespino remark]

Go to

Start | TightVNC Viewer

Type your IP address for your RaspberryPi followed by the port 5901 into the Remote Host field.  E.g.

Click connect.  You will be asked for the password you setup when installing vncserver in the rpi.

And voi’ la:
Inline image 2

How to setup a headless raspberry pi via wifi

January 12, 2013

The steps to setup a headless raspberry pi involve installing the usb wifi, in this case I used the Edimax EW-7811Un.

The site is very clear and it explains how to setup:

1. To start with, I have a headless rpi connected via Ethernet cable:

2. install the wifi usb using the $10 usb device.  I mind you, there are two pitfalls in running the otherwise excellent script

Hence, first backup /etc/network/interfaces file.  I copied it to interfaces.bkup

The first problem is, don’t copy and paste it to a windows text editor.  That process introduces strange characters.  Just download the file to your pc and then copy it to the rpi via:  scp pi@x.y.z.a://home/pi/ .

The second problem is, if you enter the password for your router incorrectly then the usb wifi is partially installed and it doesn’t work properly. You will need to remove the /etc/network/interfaces file and restore the original interfaces.

3.  Once you run the script and enter the proper user id and password for your wifi network, you can find out the ip address with: ifconfig. That’ll give you the inet addr of your wifi connection to the rpi !

Note:  For additional details about installation, check out the instructions given in:

2012 in review

December 31, 2012

The stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

600 people reached the top of Mt. Everest in 2012. This blog got about 6,900 views in 2012. If every person who reached the top of Mt. Everest viewed this blog, it would have taken 12 years to get that many views.

Click here to see the complete report.