Karachi   ->   Sweden   ->   Karachi, again   ->   Dubai   ->   Bahrain   ->   Karachi, once more   ->   London and Leeds

Friday, November 01, 2013

Catching a COM+ Event in VBScript

Catching events in Visual Basic 6 was simple---the IDE provided you all the tools to define event handlers in a very easy and intuitive way. Similar approach was carried over to .NET based languages. But what if you are going to use a COM object in VBScript, where you don't have an IDE to help you at all?

Difference between CreateObject and WScript.CreateObject

The first point to note is that you need to use WScript.CreateObject to create your COM object in VBScript, if you want to attach a handler for events raised by the object. WScript.CreateObject takes an additional parameter---a prefix for your VBScript functions which will be called when the event is raised:

Set obj = WScript.CreateObject(ProgID [,strPrefix])

where strPrefix is the starting prefix of the function names which will act as the event handlers for the object created.

Event Handler - Practical Example

Let's say that I have a prog id of "Math.SimpleCalculator" and the event raised by the corresponding object is CalculationComplete. The VBSCript client which can create this object and receive the raised event will be declared as follows:

Set obj = WScript.CreateObject ( "Math.SimpleCalculator", "MyObj_")

Function MyObj_CalculationComplete ()
   MsgBox "Calculation is complete!"
EndFunction

call obj.doSomething()
call WScript.Sleep (1000)

Tuesday, October 22, 2013

Remittances to Pakistan by Pakistani Expats

Do you know what's the biggest export of Pakistan? It's still Textile, amounting to 1.1 billion USD in a single month (stats from Aug 2013). But you might be surprised to know that this export is now matched by the remittances sent in by Pakistanis from abroad to their families back home. The figure is more than a billion dollars in a single month!

Remittances from Pakistani Expats in Sep-2013

The data about remittances is publicly available from the State Bank of Pakistan. Below, we analyse some of the data from September 2013:

Source: State Bank of Pakistan (Home Remittances Sep-2013)

The above figures are in millions of dollars, remitted by Pakistanis in a single month, broken down by countries.

As you can see, the largest remittances come from four countries: Kingdom of Saudia Arabia, the UAE, the UK and the USA. Amount of money remitted from KSA to Pakistan in a single month is 373 million US dollars, followed by the UAE at 276 million USD. Being Pakistanis, we also know that besides Gulf countries, a large number of Pakistanis live in the UK and the US.

Year on year increase in remittances

The following graph shows yearly increase in the last 10 years. Mind that the figures are in USD, and hence, these remittances further strengthen the economy in the backdrop of Rupee losing against Dollar:

Source: World Bank Migration & Remittances Data

Why have the remittances gone up?

working paper by IMF (International Monetary Fund), published in 2011 studies the factors behind this trend of remittances.

The hypothesis presented in the IMF paper are interesting, especially considering the fact that the world economy hasn't been doing really well in general during the last 10 years. The working paper from IMF narrows down everything to the number of migrants moving out of Pakistan and their general skill-level. 

And once again, being Pakistanis, we know that the large outflux of skilled migrants is actually due to the law and order situation in Pakistan. While these migrants are helping a lot to the economy, the "brain drain" impact can't be ignored.

What method do you use for remittance?

Are you a Pakistani living abroad? I am sure you send money back home. What's the method that you use? Do you think you are getting the best rates with minimal transaction fee?

Sunday, August 18, 2013

Google Nexus Sound Mute Problem

So, my Google Nexus 4 suddenly went mute. I did a quick check to find out that it's only video and applications which have their volume stuck at 0; the phone itself was ringing fine; even the alarm function was working. This relieved me because it meant that the speaker itself wasn't faulty.

As with all software problem, a complete reboot came to mind. Unfortunately, that didn't help either. I even tried rebooting it to Safe Mode but with no luck---games, videos stored on the phone and Youtube all seemed to be completely silent.

The next idea was to check the phone with headphones, and to my surprise, things were fine if I plugged in a headphone. It was just the speaker which wasn't being used!

Some interesting articles on the web told me about similar situations where the audio which previously worked fine had stopped working; although all of these cases were a little di
fferent from what I was facing:

Similar Android Problems


Google Nexus Android Mute BugAndroid Bug: Volume for "media" stuck muted until device is rebooted is a bug reported for Android 4.2.1, which seems to remain unfixed till June 2013 (from the comments in the bug report). Interestingly, this one is an Android bug and effects all phones, including Galaxy SIII. The problem here seems to go away if the device is rebooted but that was not the case with me.

Another problem reported on Google forums is a sound problem which affects both speakers and headphones. You can see in the comments that people have different variations to this and no solution has been posted by anyone.

Many people suggest that if you face this problem, you have a third party application which is not letting your phone restore the volume. If reboot doesn't work, perhaps you should uninstall any recently added mobile phone applications?

What finally worked for me!

And then I came to know about SoundAbout. This nifty application allows you to redirect your sound forcefully to one of the many audio output devices associated with your phone: external speaker, wired headphone, HDMI, Bluetooth, etc. There is a PRO version too, but the basic, free version was good enough to fix the issue for me.


The screenshot from Sound About on the right shows you the relevant screen in the application. By default, things are set to let the application to decide where to send the sound output. I changed it to "Speaker" and then played videos---Voila! Everything was back to normal! I changed the settings back to "Let App Decide" and things were still normal. I uninstalled Sound About, and yet the phone was still behaving as normal.

Friday, August 16, 2013

Is Coding the new Latin?

When New York Mayor, Michael Bloomberg, announced in 2011 that learning to program a computer was one of his new year resolutions for 2012, people started wondering if Coding is the new Latin.

Is it really important to learn to code, even though you don't intend to pursuit a career in computer programming?

Some people agree, while others think that it's just a hype. I somewhat tend to agree with the former group. Even though learning to code might not help you directly in your career, it will improve how you think about problems and make you a better computer user, if nothing else.

Whether you agree or not, it's true that some of the most influential (and rich) people in the recent history had something to do with software development. Below is a video prepared by code.org which features Bill Gates, Mark Zuckerberg and several others. The theme is "Every student in every school should have the opportunity to learn to code."


With the advent of Web 2.0, interactive e-learning has become fun and immersive. The best part is being able to learn programming right from within your web browsers! Below is a quick round-up of extra ordinary resources for learning and polishing your programming skills.

The criteria used here is that only sites with free courses, which are either interactive or provide an instructor lead sessions are included.

Introduction to Programming


Code Academy: This is perhaps the most famous of "learn to code" web sites. The main page of this web site starts interactively, and before you know it, you start programming! This is a good resources for coding in general but more importantly, there are several "track" courses such as those for learning JQuery, JavaScript, PHP, Python and Ruby. The non-track courses cover a diverse set of topics such as CSS Selectors and Evernote API.

Code Academy is a nice resource if you already know programming and would like to teach others!


Code School: Code School is really meant for people who already know the basics of programming and want to take the next step by building expertise in web technologies. There are courses available on Git, Backbone.js, SASS, Rails, JQuery and several others.



Learn Street: Like Code School, Learn Street also focuses on JavaScript, Python and Ruby.



Improving your programming skills


Code Learn: If you have done web development in the past, you would know that Ruby on Rails is getting popularity day by day. The aim of Code Learn is to teach you Ruby on Rails.

AppShed: With smart phones, "mobile application development" has made a number of people rich. The aim of AppShed is to teach you mobile application development.

Learn X in Y minutes: This is a community driven site, which provides an extremely quick overview of different programming languages. This could be very useful to get a quick grasp of common construct in a new language.

Saturday, July 27, 2013

The Boss in Leeds (or why politicians love industrialists)

So, The Boss visited Leeds this week. Bruce Springsteen was the first one to play in the newly completed £60m Leeds Arena. Previously, he is said to have visited the city in 1985 where the concert was held in Roundhay Park.

Bruce Springsteen - Leeds Arena - 24th July 2013
Bruce Springsteen - Leeds Arena - 24th July 2013 by Bradford Timeline

In another side news, some traffic warden issued parking tickets to the lorries carrying equipment for Bruce Springsteen's performance at the arena. Leeds City Council felt very embarrassed about it, and cancelled the tickets afterwards. This is what Leeds City Council had to say about the cancellation of the fine:
We accept this is a little embarrassing but the attendant was doing his job - if a little too efficiently," said a council spokesman. "When you prepare a city to open and host a huge, state-of-the-art new venue, you're bound to get the odd teething trouble ... Having considered the special circumstances, [Bruce's] tickets were quickly cancelled.

I wonder what's so embarrassing about it, and why weren't their clear instructions about it in the first place? If I am a ticket warden and my duty is to issue tickets, why would my boss be embarrassed about issuing tickets?

And when I wonder, my mind wanders...

Why is it that politicians are so much "in awe" of industrialists and capitalists? If a political figure is representing a common man, and they all surely claim to do so, why he/ she be so humble and flexible for those who are clearly not common?

‎(Comic) Does money give corporations more access to government? [yes]
(Comic) Does money give corporations more access to government? [yes] by mysticpolitics

Well, it surely has something to do with money. But not all politicians are corrupt; may be not entirely corrupt. But their love for industry and capital is ubiquitous.


So, this is what finally makes sense to me: A politician, even a genuine well-wisher-of-common-man type, wants to decide the fate of people; that's why he/ she is in politics in the first place. To do so, they require money. And the money comes from "big shots." The collective tax collected from common man must be peanuts as compared to sales and other corporation taxes collected by the government. So, modernisation is in the favour of politicians---it empowers them with more money to make decisions about the life of others; they will always like to do so, even if the common man is better off without the "modernisation" that they want to impose.