Author Archive

Wireshark and [truncated]

Posted on the May 10th, 2010 under Internet,Linux by Tohir

I’ve posted a tutorial on how to get wireshark up and running on Ubuntu. The one problem , though, is that sometimes (actually often) you get [truncated]. How can you untruncate or turn it off or increase its size.

This isn’t the answer, but a way of how to get access to the full response:

Right Click on the Packet in Line-based text data, then choose Copy > Bytes (Printable Text Only).

This will place the full response, and you can paste it in a text editor.

Starting to like the toolbar in Ubuntu 10.4 file manager

Posted on the May 4th, 2010 under Linux,Software and Technology by Tohir

The one thing that horrified me in the latest version of Ubuntu was the ‘new’ toolbar for Nautilus or the file manager.

However, after reading Deconstructing Nautilus and rebuilding it better, I have to admit, I enjoy it. Why?

Even though I tend to browser elsewhere by typing in the path, the UP button is probably the most used button by myself. Switching to the location bar provides no alternative, but keeping the button bar allows one a form of up button.

Secondly, CTRL+L is probably something I can live with.

Given the whole debate around this, the lesson I believe is that don’t ignore your existing users. If you are going to change something, inform your users!

Given the opensource community spirit, it wont be long before someone does a quick script to bring back the old toolbar. If you are looking to do that today, have a look at: https://help.ubuntu.com/community/RestoreNautilusLocationBar

Being in touch with the Nabi Muhammad (PBUH)

Posted on the May 3rd, 2010 under Reflections/Thoughts by Tohir

For the past couple of weeks, I’ve taken to reading Muhammad: His Life Based on the Earliest Sources by Martin Lings. One of the many touching incidents occurred in Madina.

The Prophet (PBUH) had to serve in multiple roles as the leader of the Muslims, governor of Madina, prophet, etc. At this time, he divided his day into three. 1/3 for family time, 1/3 for community affairs and a 1/3 to spent in worship and prayer.

Some of the companions felt as if they were losing touch with the Prophet, given his multiple roles, fixed time in them, and the large amount of people who were all vying for his attention.

In this regard, Allah revealed the verse:

Surely Allah and His Angels bless the Prophet. Oh you, who believe, call for blessings on him, and salute with (respectable) salutations. (Chapter 33: Verse 56)

This would be their (and our way) of staying connected with him!

The Prophet (PBUH) would also add: “Whoever invokes blessings on me once, Allah will invoke blessings upon him ten times”

Vodacom and Rotten DNS, Connected but not quite connected

Posted on the May 3rd, 2010 under Internet by Tohir

One of the most annoying issues using Vodacom to connect to the internet is that sometimes the DNS server used is so badly rotten, internet use is practically useless.

DNS is the system that converts a domain example www.google.com to an IP Address, something ‘computers’ can interpret and understand. When this process fails, it may appear the internet is down. All that is happening, however, is that the process of converting domain names to IP Addresses is slow (or dead).

One way to fix this is to use alternative DNS servers/addresses. By switching DNS addresses, you are basically saying, use this server to convert domains to IP addresses.

First things to check:

  1. You have an internet connection. This will not help if you do have one
  2. Check that entering an IP address works, example: http://41.1.224.101
  • http://41.1.224.101 (vodacom.co.za)
  • http://41.203.21.136 (mybroadband.co.za)
  • http:// 196.8.95.20 (standardbank.co.za)
  • http://74.125.43.106 (google.co.za)

If this works, but entering www.vodacom.co.za doesn’t, then changing DNS entries will help. Edit your connection settings, and try one of the following:

196.43.46.190 – SAIX
196.207.40.165 – Vodacom
168.10.2.2 – Internet Solutions (IS)
208.67.222.222 – OpenDNS
208.67.220.220 – OpenDNS alt

It is possible to mix them up, rather than using two by the same company.

Electricity Tariff Increase Calculator

Posted on the February 24th, 2010 under South Africa by Tohir

The National Energy Regulator of South Africa on Wednesday granted state-owned utility Eskom a 24,8% tariff increase for the 2010/11 financial year, falling short of the power firm’s request for a 35% hike. For the following two financial years, Eskom was granted increases of 25,8% and 25,9% respectively.

How much does that amount to for you? Try the calculator below:

Read the story on Mail and Guardian

Road Closures for opening of Parliament

Posted on the February 8th, 2010 under Internet,South Africa by Tohir

Here’s a Google Map of the road closures for the opening of South African Parliament


View Opening of Parliament 2010 in a larger map

Would it not have been easier for them to stick to DeWaal Drive, Roeland Street?

MySQL – getting two items per source in a single query

Posted on the February 4th, 2010 under Software and Technology by Tohir

Assume you have the following table called stories with the following data. And you have run the following query:

SELECT * FROM stories ORDER BY storydate DESC
id source title storydate
10 cnn Story 10 2010-01-21
9 bbcnews Story 9 2010-01-20
8 bbcnews Story 8 2010-01-19
7 skynews Story 7 2010-01-18
6 cnn Story 6 2010-01-17
5 bbcnews Story 5 2010-01-16
4 cnn Story 4 2010-01-15
3 skynews Story 3 2010-01-14
2 skynews Story 2 2010-01-13
1 cnn Story 1 2010-01-12

Now for the challenge. What happens if you are required to get the top two stories from each source? One option is to first get the order of the sources, and then loop through each one of them:

SELECT DISTINCT source FROM stories ORDER BY storydate DESC

<loop “source” as “sourceid”>

      SELECT * FROM stories WHERE source = "{sourceid}" ORDER BY storydate DESC LIMIT 2

</loop>

Another option is to do the in MySQL itself! Unsure if there is a better way of doing this, but here’s mine using UNION and Sub Selects:

(SELECT * FROM stories WHERE source =
(SELECT DISTINCT source FROM stories ORDER BY storydate DESC LIMIT 0,1) ORDER BY storydate DESC LIMIT 2)
UNION
(SELECT * FROM stories WHERE source =
(SELECT DISTINCT source FROM stories ORDER BY storydate DESC LIMIT 1,1) ORDER BY storydate DESC LIMIT 2)
UNION
(SELECT * FROM stories WHERE source =
(SELECT DISTINCT source FROM stories ORDER BY storydate DESC LIMIT 2,1) ORDER BY storydate DESC LIMIT 2)

Explanation:

The bold section are subselects and form the WHERE clause of the query. Here  we want the first, second and third as per source, but only one at a time. Once we have two results per item, we use UNION to join them together.

One thing to note though. Even though it returns the latest two stories per source, the final table is not sorted by storydate! This can be done using PHP sorting techniques. Is there a way of doing this one time in MySQL?

Getting started with Wireshark, the Fiddler for Ubuntu

Posted on the February 1st, 2010 under Internet,Linux,Software and Technology by Tohir

Fiddler is a useful tool for tracking http requests and responses. It’s similar to the Net tag in Firebug, except that it can be used to track all requests, not only browser-based ones.

For Ubuntu users, the recommended alternative is Wireshark. Wireshark is noted as being more powerful than Fiddler, but the focus will be on the features most commonly used by web developers for tracking.

Installation

Wireshark is found in the Ubuntu repositories, so simply search for wireshark in Synaptic, or enter sudo apt-get install wireshark

Usage

Under Applications > Internet, you will notice there are two options. Wireshark and Wireshark (as root). Run the second one (as root) as this gives you more data to track.

wireshark-1

After wireshark has started, the process is straightforward:

  1. Choose which network interfaces to capture traffic from
  2. Start capturing
  3. Filter captured requests

1. Choosing which network interfaces to capture traffic from. From the menu, choose: Capture > Interfaces

wireshark-2

This will bring up a list of network devices.

2. Since my work involves debugging work off my laptop (http://localhost etc), I only start device lo (127.0.0.1). This is useful as it immediately ignores all other traffic.

3. The one thing you will notice is that fiddler will log both the TCP and HTTP requests. For the purpose of debugging AJAX, etc., we are only interested in HTTP requests, TCP requests are not required. These can be hidden by adding a filter.

wireshark-3

In the field next to Filter:, enter http and click on Apply.

wireshark-4

The steps will now show all traffic coming on 127.0.0.1 via HTTP. The last step is picking up the AJAX parts for debugging. Notice that for each request, there is a response. Unlike Fiddler, Wireshark does not combine the request and the response. So click on the response line, and then expand the Line-based text data row. This will show the text of the AJAX response.

wireshark-5

Conclusion

Wireshark takes more steps than Fiddler, and Fiddler is a more focussed program than Wireshark. Wireshark also captures traffic without having to install a plugin into firefox, etc., so it’s useful for debugging applications as well. The biggest improvement to make Wireshark truly replace Fiddler is to turn off truncation of the response text. Wish I knew how!

Before you commit sin, ask yourself

Posted on the January 8th, 2010 under Reflections/Thoughts by Tohir

Before you commit sin, ask yourself:

Do you know what day it is today?

Is it not perhaps Friday, the day of Jumuah?
Is it not perhaps Thursday, the day after Jumuah?
Is it not perhaps Saturday, the day after Jumuah?
Is it not perhaps Monday, the day the Prophet was born?

Would you like to commit sin on such a day?

Do you know what Islamic month it is?

Is it not perhaps the Holy month of Muharram, that start of the new year, where we resolve to rid ourselves of past bad ways?
Is it not perhaps the Holy month of Ramadaan, the month of fasting, where the Shaytaan is chained?
Is it not perhaps the Holy months of Hajj?

Whatever time it is, do you really have to commit that sin

Advice on Hajj and Old People

Posted on the November 3rd, 2009 under Reflections/Thoughts by Tohir

This year, I have the fortune to be on the Hajj or Muslim Pilgrimage. I am sharing this experience with many people, some of them double my age. Travelling with old people is both humbling and rewarding.

Humbling to note that despite their age and the accompanying reduced health and strength, they haven’t given up on undertaking this magnificent journey. Humbling because they are the ones who prevail calm, patience and sabr at long queues and bureacratic annoyances.

Rewarding because it provides us younger people with the opportunity to assist them in the holiest cities where the Prophet Muhammad (PBUH) said: “The best of people are those who are most beneficial and helpful to people”.

On my journey, I’ve compiled a list of a few short tips aimed at the children of old people, and what they can do to make their parent’s journey much easier.

Cellphones:

1) Provide them with a cellphone that has a distinct on/off button.

Cellphones need to be switched off on aeroplanes. To save space, some cellphones link the switching on/off button to an existing button, but this grouping confuses some old people

2) Disable the sim-card pin

Sim-card pin are there for protection, but it also means having to remember their number. Many are not aware this even exists, as they’ve needed to switch their phones on/off before.

3) Activate international roaming – even if just for sms

Some people have this activated, and they may not have. Explaining international roaming, and that it has to be done prior to leaving South Africa for it to be activated takes some effort.

4) Convert all essential contact numbers to an international dial out.

For example, a house number in Cape Town locally would be: 021 555 1234. Rather convert this to +27 21 555 1234. +27 is South Africa’s dialling code, 21 is for 021 minus the zero, and the rest is the number.

This way, older people do not have to remember to add the +27, and drop the one zero, etc.

5) If possible, provide them with a slide-out keyboard.

It’s painful to watch someone spend five minutes typing out an SMS

Bags:

It would be easier said that done, but encourage them to travel with as few bags as possible, and rather a bigger overnight bag, than multiple small bags. South Africans are usually provided with a shoe bag which gets used as an additional stuffed travel bag. Take into account that they will have with them:

a) overnight bag
b) Haj operator bag for carrying passport/documents
c) Chair for Salaah
d) Shoe bag

Quite a lot to not only carry, but also manage.

Camera:

Even one fitted to a cellphone will allow them to capture moments that are special to them. However, bare in mind they will probably have no place to download their photos to. My suggestion is to provide them with a large memory card or multiple memory cards so that they wouldn’t have to delete any photos they might have already taken.