Author Archive

Where’s the PHPUnit command-line test runner?

Posted on the April 29th, 2013 under Linux,Productivity,Software and Technology by

After you have installed the PHPUnit via PEAR, how do you get access to the phpunit executable. Here’s the steps from the beginning on Ubuntu.

1) Install PHP Pear if you don’t have it installed

sudo apt-get install php-pear

2) Enable auto discovery

sudo pear config-set auto_discover 1

3) Install PHPUnit via PEAR

sudo pear install pear.phpunit.de/PHPUnit

4) Locate the PHP PEAR bin(ary) directory

 pear config-get bin_dir

Mine shows:

tohir@tohir-MS-7759:~$ pear config-get bin_dir
/usr/local/zend/bin

If you then list the files in that directory, you’ll see:

tohir@tohir-MS-7759:~$ ls /usr/local/zend/bin
apachectl extract_meta_data.sh jqd.sh monitor-node.sh pecl phpize scd setup_sc.sh uninstall.sh zdd.sh ZManifest zs-setup
clean_semaphores.sh gui_passwd.sh lighttpdctl.sh pear php phpunit scd.sh shell_functions.rc watchdog zdpack zmd
create_cert.sh jqd MonitorNode peardev php-config rulemerge setup_jq.sh support_tool.sh zdd zendctl.sh zs-manage

You can then create a symlink to make it easier to access:

sudo ln -s /usr/local/zend/bin/phpunit /usr/bin/phpunit

wkhtmltoimage crashing at 25%

Posted on the April 13th, 2013 under Uncategorized by

I’ve had to turn off this functionality till I could find a fix. Sometimes, it worked, sometimes it didn’t. One URL in particular I had difficult fixing was: http://www.musjidnoor.za.net/index.html

Console Results

xvfb-run –auto-servernum –server-num=1 wkhtmltoimage –disable-javascript –use-xserver -f png -n ‘http://www.musjidnoor.za.net/index.html’ /var/www/docprogress_temp/1365305896.png
Loading page (1/2)
Rendering (2/2)
^C==============> ] 25%

Thought came in my mind, maybe it’s because there page is either big or long. Let’s try cropping the height:

xvfb-run –auto-servernum –server-num=1 wkhtmltoimage –disable-javascript –use-xserver -f png –crop-h 6000 -n ‘http://www.musjidnoor.za.net/index.html’ /var/www/docprogress_temp/1365305896.png
Loading page (1/2)
Rendering (2/2)
Done

Wallah, that seems to fix it. I gradually increase mine to 6000 which is more sufficient in my case. Suggestion, try adding –crop-h {a height}, and see if this fixes it.

How to bring your mouse back to life in Ubuntu

Posted on the February 2nd, 2011 under Linux,Software and Technology by

Occasionally, I encounter the issue where my mouse moves around the screen, but I can’t left click. Right click does work. Instead of rebooting tonight, thought I’d try to find a solution tabbing away on the keyboard whilst I still had a browser open.

Solution:

  • Press Ctrl+F1 to go to a terminal screen
  • Login with your username and password
  • sudo mobprobe -r psmouse
  • sudo modprobe psmouse
  • Ctrl+F7

This removes the mouse ‘driver’ from the kernel, and re-adds it. Wallaa!

Installing Zend Server CE on Ubuntu Maverick (10.10)

Posted on the January 24th, 2011 under Internet,Linux by

Spent the day trying to install Zend Server on Ubuntu (10.10), but ran into so much blockers, thought it would be worth a blog!

After following all the steps, I got hit with:

W: Failed to fetch http://repos.zend.com/deb/ce/dists/ce/Release
Unable to find expected entry  non-free/source/Sources in Meta-index file (malformed Release file?)

Kept trying sudo-apt-get update whilst cursing Zend, and still the same.

Solution: Disable the sources repository in /etc/apt/sources.list.

#deb-src http://repos.zend.com/deb/ce ce non-free

Next, trying to install, and keep getting dependencies issues. There are two (old files) that need to be downloaded, and then everything works fine:

They were in older distributions, but no longer are!

Once those two files are manually installed (sudo dpkg -i), the rest is plain sailing.

Thunderbird + Correct Indentity Plugin

Posted on the January 5th, 2011 under Linux,Productivity,Software and Technology,Usability by

On both Ubuntu (and Windows if I ever had to use it), I prefer Thunderbird as my email client over Evolution or MS Outlook purely due to two reasons:

  1. I love the way it allows one to show an inbox for each account. I do not need to filter them, or create labels.
  2. The ability to set a limit on incoming mail. Once activated, it only downloads the first 50kb of each email giving an idea of what the email contains, and it saves the frustration of downloading emails with large attachments, particularly from people I don’t know.

However, the one mistake I often make is clicking “Write”, type in the email, and clicking send, without checking that I’m sending it from the right email address. Fortunately, another great thing with Firefox and Thunderbird is extensions, and there is one that fixes that called Correct Identity.

It allow one to set an alternative default email address for writing an email. Eg. The account is support@…, but whenever you send out email from that account, it should be from tohir@…, that’s the issue it solves!

Why CSS gets confusing and why you should use SASS

Posted on the September 30th, 2010 under HTML, CSS,Internet by

Take the following HTML file with CSS. How will div2 look?

<html lang="en">
<head>

<title>SASS Test</title>

<style type="text/css">
    div.div1 div {
        border: 4px solid yellow;
        background: yellow;
    }
    div.div1 {
        background: red;
        border: 4px solid blue;
    }
    div.div1 div.div2 {
        background: green;
    }
    div.div2 {
        border: 10px solid orange;
        padding: 10px;
    }
</style>
</head>
<body>
    <div class="div1">
        Div 1
        <div class="div2">
           Div 2
        </div>
    </div>
</body>
</html>

Based on the last definitions, you will expect div2 to have:

  • a green background color
  • a 10 pixel solid orange border
  • a padding of 10 pixels between the border and the text

Actually it will appear like this:

It does NOT have a 10 pixel solid orange border, but instead a four pixel solid yellow border. Even though CSS is cascading, it cascades by CSS rules, not by definitions. Even though an alternate definition is last, if it doesn’t cascade over an existing rule, it will not be applied.

Wireshark Filters – Ajax Example

Posted on the September 30th, 2010 under Internet,Linux,Software and Technology by

I’ve blogged about Wireshark before, and how to use it for Ajax. Next is a quick tip on how to use Wireshark’s filters feature to only watch for AJAX requests. In the filter tab, enter:

http.request.uri contains "php" ||  http.content_type == "text/html"

This effectively reads, only log items where:

  1. The HTTP request contains PHP, OR
  2. The HTTP response is “text/html”

Wireshark Filters

Useful, dont have to wade through whats an Ajax response, bypass images, etc. One thing that would be nice would be if the area that shows the filter expression was longer!

Preparing For Hajj – Some tips for techno hajjis

Posted on the September 27th, 2010 under Internet,Islam and Muslims,Reflections/Thoughts,South Africa by

Going on Hajj nowadays is so much different from years ago. As someone that was fortunate to be there in 1995 and last year (2009), the differences were stark. No longer did we have queue for prepaid phones, we could video chat (skype) with our family back home. No longer did people have to wait for photos to be developed. We shared them immediately on Facebook. And yes, we took photos of ourselves inside the Haram and MMS’d it home!

Opting to take our gadgets also came with its own preparation. Having learnt from the advice of well-wishers, as well as mistakes from previous trips, here are some tips we can offer.

Electricity – Get a Travel Plug Converter

Saudi Arabia uses the Type F plug, South Africa the Type M. One Hajji noted that his hotel also had the Type G plug (as used in the UK), but this is very rare.

I found a travel plug converter at Diskem, but its generally available at stores like Cape Union Mart. Also try places that sell suitcases. Type G to Type M is easier to find and available at Clicks for instance, but rather take the Type F. This also makes a handy gift to Hujaaj!

We also took with a multiplug allowing us to comfortably power the laptop as well as charge our cellphones, camera battery, electric tooth brushes, electric shavers.

Saudi Arabia also uses 220V so there’s no need to change the voltage on your equipment.

Type F Plug

Type F Plug

Type M Plug

Type M Plug

Type G Plug

Type G Plug

WiFi and Internet

Even if Wifi is advertised  free in your hotel, it may only be available on a certain floor. Check with your travel agent whether the hotels you are staying in offer WiFi and whether WiFi is offered on all floors or just some. I found WiFi more available in Medina than in Makka. It may be because of the construction work, but speculation on my side.

Internet on your Cellphone

Have a habit of quickly checking Facebook on your cell phone, I was shocked to see how expensive this is with airtime just running away. My guess is that it costs something in the region of Rs2 (Saudi Riyals) a megabyte which would be more expensive than South Africa.

Tip: Keep this is mind that their billing rate may be different. Also check your airtime balance regularly, and modify the settings of programs that connect to the Internet. In my case, one of them was one that downloads the daily weather.

3G Internet for Your Laptop

It is possible to take your 3G card with and purchase a one 30 day data bundle from a service provider in Saudi Arabia. There are two advantages to doing this:

  • If your hotel does not offer WiFi on your floor, you can comfortably Skype and video chat with your family in the comfort of your hotel room.
  • If your package involves moving to Azizia, you’ll have Internet access there! Azizia is nice, but WiFi is not standard there ;-)

Some tips on purchasing a data bundle

1) Saudi Arabia has two main operators: STC and Mobily. STC is the equivalent of Telkom, advertises everything but has nothing and unlikely to help you if they sense you are going to make them THINK or do some real work. The service from Mobily on the hand was wonderful. They knew their products, no queues.

2) Purchase the data bundle in Medina

Makka is full. Since it is also winter there, there is a shorter time between the Waqts and also to get to the Haram on time. By the time you get to the front of the queue, its time for Salaah. However, try and purchase it closer to the end of your stay in Medina, but with enough time to go back to them if any issues arise (about three days before you leave). A data bundle lasts for 30 days. The later you purchase your data bundle, the later for your stay in Makka you can use it. Otherwise you run in the dillemma of wanting to purchase a data bundle just a few days before Haj and risk losing the balance of data/airtime.

3) Requirements

I purchased the data bundle at the Mobily Store in Central Medina (opposite the Hilton hotel). They required a photocopy of my passport (which I did not have) but accepted my Al Anwar card. Best to take a photocopy of your passport with.

4) The connection settings for Mobiliy is built into Ubuntu, just setup a Mobile connection. For Windows users, they are:

Number: *99#
APN: web2

However, the pamphlet given is quite handy. The salesman will also tell you that you can bring your laptop to them and they will help you set it up!

AIR Time

Recharge Card

Recharge Card

Airtime is sold in various denominations. However, if you buy a larger, you stand to gain extra airtime. For example, a Rs100 airtime card gives your Rs150 airtime (cant recall exactly, but it was in this region).

Best of all, the cards have two scratch areas, so even if it is a single card, the airtime can go on to two phones. As they say in Cape Town, “Klap together”.

This also offers the opportunity for the budding entrepreneurs in Makka and Medina. Check that you are not paying the extra Rs50 when you dont have to. Also, some of them will sell you half the card for Rs75. There are so many of them, just walk away and move to the next guy.

Internet Banking

The number one rule: Update your profile to receive your One Time Password (OTP) via email. By default, most people receive their OTP via SMS. Unless you have international roaming activated and WORKING, you may not receive this, which may stop you from performing any transactions via the Internet.

Standard Bank users can only opt to receive their OTP via SMS or email. FNB users have the option of receiving the OTP via email in addition to SMS.

However, for both of them, you need to setup the OTP via email before leaving your hometown. Usually someone from the branch has to phone you, ask you to verify your details, etc. before they set this.

For Standard Bank, if you set up a recipient, you will not need to enter a OTP when doing a transfer to them.

ATMs, Banking in General

Please check that your card does not expire whilst you are on Haj. Banks usually have your new card a month before they expire, and you can request them to send you one earlier as well.

You are able to do cash withdrawals at Al Rajhi bank. In Makka, they are situated in front of the Hilton hotel. In Medina, there’s an ATM on the first floor of the Hilton Hotel. In most of the more modern malls, they do accept cards. Some of the smaller shops usually share one machine that services a group of them, so you may have to walk to another point to have your card swiped.

Wires

Make a checklist of all the wires and cables you need to take with. Its annoying to be on the other side of the world only to discover you dont have a cable you need.

Back Home Preparation

Apart from checking that you are hooked up, ensure that your family is likewise. Are they able to connect to the Internet, start skype, etc.? Does their webcam give a grainy or feed, etc.? Run a few checks before you leave, and also put them in contact with someone thats knowledgeable. If they are going to use someone else’s Internet connection, ensure that you have budgeted for this as well.

Lastly,

Where possible, assist your fellow Hujaaj if you can. The Holy Prophet Muhammad (PBUH) said that the best of people are those who assist others, and how much greater is this in the Holy Cities. If you find any of these tips handy, please make Duah that the Almighty grants the author to apply these tips himself in the Holy Lands, Insha Allah

[Video] Shaykh Sadullah Khan’s Khutbah at Claremont Main Road Masjid

Posted on the September 4th, 2010 under Internet,Reflections/Thoughts by

The khutbah is available online, but sometimes it’s just easier to watch it online.

Installing SASS 3.0 on Ubuntu 10.4

Posted on the July 9th, 2010 under HTML, CSS,Linux,Software and Technology by

Currently, the HAML/Sass version on Ubuntu is 2.2.17. Version 3, also known as Classy Cassidy, includes new features. So how can you install it on Ubuntu.

Firstly, you need Ruby:

sudo apt-get install ruby

Thereafter (without sudo):

gem install haml-edge

This will install Haml and Sass into your directory, but at least you will have access to the latest version. Message that appears:

WARNING:  Installing to ~/.gem since /var/lib/gems/1.8 and
 /var/lib/gems/1.8/bin aren't both writable.
WARNING:  You don't have /home/tohir/.gem/ruby/1.8/bin in your PATH,
 gem executables will not run.
Successfully installed haml-edge-3.1.49
1 gem installed

You can test that it is the latest version by:

~/.gem/ruby/1.8/bin/sass -version

Which should return:

Haml/Sass 3.1.49 (Bleeding Edge)

Lastly, there is a nice command to watch files and auto generate an updated version:

~/.gem/ruby/1.8/bin/sass -t compact --watch [inputfile]:[outputfile]

like:

~/.gem/ruby/1.8/bin/sass -t compact --watch browseView.scss:browseView.css