Thursday, December 10, 2015

CSV Reading Error (Python)

Just encountered a very ambiguous error in Python while reading a .csv file using the csv library in Python.

The solution made me feel pretty dumb. That is why I am blogging this to remember. From: This is the code snippet I was trying to execute to read csv file at path /home/superuser/Desktop/day.csv.
import csv
with open('./day.csv', 'rb') as csvfile:
  r = csv.reader(csvfile, delimiter=' ', quotechar='|')
  for row in r:
    print ', '.join(row)
Python shell was showing error,
AttributeError: 'module' object has no attribute 'read'
Which made me thing that I'm importing wrong csv library. May be this import csv isn't importing the correct CSV I need. I was correct.
But the solution was pretty awkward. I was saving my file as "" and my program "" itself was importing itself.
Renaming the script to some other name resolved this issue.
Thanks to bernie's answer here:

Thursday, December 3, 2015

Raspbian on Raspberry Pi 2

Following are the steps you need to know before installation of Raspbian - a distribution of Linux for Raspberry Pi 2.
  1. Download image of Raspbian from
  2. Linux
    If you are using Linux/Unix, you need to burn (copy contents from) this image file (.img) into the SD card using following sequence of commands,

    df -h

    To check the list of all the drives mounted into system. Figure out from this list what is the name of your device mounted into /dev/device_name. This device name usually ends with p0, p1 and so on, which indicates the partition indexing. Make sure your card has one partition, at the time of installation and configuration of Raspbian, it automatically partitions into necessary parts.

    Easiest way to figure out what is the newly mounted SD card name in /dev/*, simply df -h before mounting SD card into PC, and then plug and find the newly plugged entry record from df -h output.

    Make sure you unmount the card before burning image into it, by using

    umount /dev/

    Run following command

    sudo dd bs=1M if=[DISK IMAGE NAME] of=[FILESYSTEM]

    Here, in bs=1M means the size of read and write of the bytes at a time equals to 1 mega. Sometimes 1M works while burning the SD card. If this doesn't work for your SD card, try using 4M or some other sector size.
    Wait for a while and your card will be burned with OS.

    Use Win32 Disk Imager software to burn the SD card .img.
  3. Plug SD card into Raspberry Pi and plug it to 5V power, plug LED on HDMI port, keyboard and mouse on USB ports
  4. You will be logged in to Raspbian
    Default username password combination is pi and raspberry respectively
  5. You can expand storage by using raspi-config on terminal after you log in to LDX

Monday, November 30, 2015

Display Bits of an Integer

To display bits of an integer you have to check each and every bit so if I have an integer i = 12, it has binary representation 0000 0000 0000 0000 0000 0000 0000 1100.

Lets do it with C++ code. C++ provides bitwise operators for but twiddling, you can simply perform bitwise OR, AND, XOR and other operations like bit shifting using builtin operators.

To check single bit of integer on bit level you need to access each of 32 bits in integer. This is achievable using & operator. & operator has property, the result comes 1 by applying it with two operand bits only if the two bits are 1.

This & is applied to all the bits individually in integer and answer is computed in form of another integer. So if you apply & operation between 2 and 3.

2 = 0000 0000 0000 0000 0000 0000 0000 0010
    &&&& &&&& &&&& &&&& &&&& &&&& &&&& &&&&
3 = 0000 0000 0000 0000 0000 0000 0000 0011
2 = 0000 0000 0000 0000 0000 0000 0000 0010

By using same logic, we can create a mask to check if each bit is zero or 1. If mask is set to 1 and later on shifted on left on each bit check some of the mask check for a 4 bit number iterations are like 0001, 0010, 0100, 1000. So after 4 left shift operations and performing & operation on original number, this mask goes zero, which can be used as loop termination condition.

Non-recursive Solution in C++

    int number = 12, mask = 1;
    while (mask > 0) {
        if ((number & mask) == mask)
            cout << 1;
            cout << 0;
        mask <<= 1;

But there is an issue with this code, bit pattern will be printed in reverse.

    int number = 12, mask = 1;
    stack s;
    while (mask > 0) {
        if ((number & mask) == mask)

        mask <<= 1;

    // print elements in stack

This way the bit pattern will be displayed correctly.

There is another efficient way to print in correct order by using an unsigned integer.

For this, consider the following code,

    int number = 12;
    unsigned int mask = INT_MAX + 1;

    while (mask > 0) {

        if ((number & mask) == mask)
            cout << 1;

            cout << 0;

        mask >>= 1

Now, INT_MAX gives 2,147,483,647 and by adding 1 to it make it equal to 2,147,483,648 that is equal to 2 ^ 31. That means the 32nd bit of the mask will be ON. Shifting it to the right till it becomes zero and performing & operation prints correct bit pattern of integer.

Note: INT_MAX is present in climit header file.

Recursive Solution in C++

void displayBitwise(int num, int mask = 1) {
    if (mask == 0) return;

    displayBitwise(num, mask << 1, ++count);
    cout << ((num & mask) ? 1 : 0);

To make this bit pattern more readable, make chunks by separating by space,

void displayBitwise(int num,
                    int mask = 1,
                    int count = 0) {
    if (mask == 0) return;

    displayBitwise(num, mask << 1, ++count);

    if (count != 32 && count % 4 == 0) cout << ' ';
    cout << ((num & mask) ? 1 : 0);

Here if count != 32 isn't checked, space will be printed after first backtrack call. count % 4 == 0 prints a space after every four characters. Good luck!

Friday, November 20, 2015

شگفتہ لوگ

شگفتہ لوگ بھی ٹوٹے ہوے ہوتے ہیں اندر سے 
بہت روتے ہیں وہ جن کو لطیفے یاد رہتے ہیں

Thursday, November 5, 2015

An Achievement!

Working on some embedded system modules that aren't touched by anyone in opensource community is a real pain in the ass. A few days ago, I was chewing nails over some failures in work. Problems that become hard obstacles are milestones for me. I seek pleasure solving problems because when you get successful solving a problem, it becomes clear to you that problem of such difficulty level can be resolved. After solving a few different problem sets from different domains, you start realizing that nothing seems impossible to you anymore. That is the lesson I learned from the recent work I am doing.

Main focus these days is embedding communication protocols in Arduino Yun (cloud in Chinese). I was stuck embedding C/C++ libraries with Arduino. Because I wasn't seeing the real picture and wasn't considering the fact that Yun is technically more capable than Uno (Arduino board I was previously working with in my college days).


Real problem arose when I started looking at the system as an incapable machine and tried to put responsibilities on myself rather exposing full functionality of board itself.

I wasn't been able to embed C/C++ libraries into Yun.

One thing to be considered while working with Arduino is concept of library. A library in Arduino is not some sort of embed-able unit with the binary file that is to be deployed in it. In Arduino, library is just a bunch of classes providing functionality. Not like .dll/.so (dynamic) or .lib/.a (static library) in C/C++.


By using the Arduino Yun's Leonardo side (a linux-based processor) running kernel of OpenWRT (an opensource light-weight distribution for Yun), you can use all functionalities of Linux system (almost).

There are multiple languages support in Linino (OpenWRT) like Python, PHP5, Bash (not a language after all).

So you can simple run Python scripts using python compiler inside Arduino, run Bash scripts, run C programs using yun-gcc package.

Use make to Makefile projects.

Then, by using Bridge you can simply use these scripts that reside inside Linino by creating Process(es) and running them on your ATmega processor in sketch file programs.

Hi five!

Monday, August 3, 2015

How to Check Your LOC?

[For Windows/cmd.exe]

So this question just popped up in mind while looking at an informational site What are the lines of code for the project in my company for a platform we've been writing.
I did some digging and created a batch file that tells line of code of all the code files inside your directory recursively.
The batch file has only one command and I redirected the output of that command in an out.txt file in the current folder.
Contents of this batch file are as follows
findstr /RN /s "^" .\\*.scala | find /c ":" 1>out.txt

What this command does?
It finds all the strings with \n inside the all the files ending with the extension .scala (you can change in your case, a simple use of commandline wildcards) and then redirects those lines into "find" that is another command. "find" program simply counts the lines and this output goes into the output stream connected to the out.txt file in the present working directory.

How I can calculate my project overall lines of code?
Simply copy the command mentioned above. Replace the .scala with your code extension (multiple extensions also can be added). Put this command inside some filename.bat and save that .bat file inside the root directory of your project. As you will run this batch file. Output will be generated at present working directory named out.txt as mentioned in the command containing your lines of code count.

Don't forget to provide your feedback. Stay tuned for more tweaks.

Saturday, July 4, 2015

Dr. Richard Teo

Below is the transcript of the talk of Dr. Richard Teo, who is a 40-year-old millionaire and cosmetic surgeon with a stage-4 lung cancer but selflessly came to share with the D1 class his life experience on 19-Jan-2012. He has just passed away few days ago on 18 October 2012.
Hi good morning to all of you. My voice is a bit hoarse, so please bear with me. I thought I'll just introduce myself. My name is Richard, I'm a medical doctor. And I thought I'll just share some thoughts of my life. It's my pleasure to be invited by Prof. hopefully, it can get you thinking about how. As you pursue this. Embarking on your training to become dental surgeons, to think about other things as well.
Since young, I am a typical product of today's society. Relatively successful product that society requires. From young, I came from a below average family. I was told by the media and people around me that happiness is about success. And that success is about being wealthy. With this mind-set, I've always be extremely competitive, since I was young.
Not only do I need to go to the top school, I need to have success in all fields. Uniform groups, track, everything. I needed to get trophies, needed to be successful, I needed to have colors award, national colors award, everything. So I was highly competitive since young. I went on to medical school, graduated as a doctor. Some of you may know that within the medical faculty, ophthalmology is one of the most highly sought after specialties. So I went after that as well. I was given a trainee-ship in ophthalmology, I was also given a research scholarship by NUS to develop lasers to treat the eye.
So in the process, I was given 2 patents, one for the medical devices, and another for the lasers. And you know what, all this academic achievements did not bring me any wealth. So once I completed my bond with MOH, I decided that this is taking too long, the training in eye surgery is just taking too long. And there's lots of money to be made in the private sector. If you're aware, in the last few years, there is this rise in aesthetic medicine. Tons of money to be made there. So I decided, well, enough of staying in institution, it's time to leave. So I quit my training halfway and I went on to set up my aesthetic clinic in town, together with a day surgery center.
You know the irony is that people do not make heroes out average GP (general practitioner), family physicians. They don't. They make heroes out of people who are rich and famous. People who are not happy to pay $20 to see a GP, the same person have no qualms paying ten thousand dollars for a liposuction, 15 thousand dollars for a breast augmentation, and so on and so forth. So it's a no-brainer isn't? Why do you want to be a GP? Become an aesthetic physician. So instead of healing the sick and ill, I decided that I'll become a glorified beautician. So, business was good, very good. It started off with waiting of one week, then became 3weeks, then one month, then 2 months, then 3 months. I was overwhelmed; there were just too many patients. Vanities are fantastic business. I employed one doctor, the second doctor, the 3rd doctor, the 4th doctor. And within the 1st year, we're already raking in millions. Just the 1st year. But never is enough because I was so obsessed with it. I started to expand into Indonesia to get all the rich Indonesian tai-tais who wouldn't blink an eye to have a procedure done. So life was really good.
So what do I do with the spare cash? How do I spend my weekends? Typically, I'll have car club gatherings. I take out my track car, with spare cash I got myself a track car. We have car club gatherings. We'll go up to Sepang in Malaysia. We'll go for car racing. And it was my life. With other spare cash, what do I do? I get myself a Ferrari. At that time, the 458 wasn't out, it's just a spider convertible, 430. This is a friend of mine, a schoolmate who is a forex trader, a banker. So he got a red one, he was wanting all along a red one, I was getting the silver one.
So what do I do after getting a car? It's time to buy a house, to build our own bungalows. So we go around looking for a land to build our own bungalows, we went around hunting. So how do i live my life? Well, we all think we have to mix around with the rich and famous. This is one of the Miss Universe. So we hang around with the beautiful, rich and famous. This by the way is an internet founder. So this is how we spend our lives, with dining and all the restaurants and Michelin Chefs you know.
So I reach a point in life that I got everything for my life. I was at the pinnacle of my career and all. That's me one year ago in the gym and I thought I was like, having everything under control and reaching the pinnacle.
Well, I was wrong. I didn't have everything under control. About last year March, I started to develop backache in the middle of nowhere. I thought maybe it was all the heavy squats I was doing. So I went to SGH, saw my classmate to do an MRI, to make sure it's not a slipped disc or anything. And that evening, he called me up and said that we found bone marrow replacement in your spine. I said, sorry what does that mean? I mean I know what it means, but I couldn't accept that. I was like “Are you serious?” I was still running around going to the gym you know. But we had more scans the next day, PET scans - positrons emission scans, they found that actually I have stage 4 terminal lung cancer. I was like "Whoa where did that come from?” It has already spread to the brain, the spine, the liver and the adrenals. And you know one moment I was there, totally thinking that I have everything under control, thinking that I've reached the pinnacle of my life. But the next moment, I have just lost it.
This is a CT scan of the lungs itself. If you look at it, every single dot there is a tumor. We call this “miliaries tumor”. And in fact, I have tens of thousands of them in the lungs. So, I was told that even with chemotherapy, that I'll have about 3-4months at most. Did my life come crushing on, of course it did, who wouldn't? I went into depression, of course, severe depression and I thought I had everything.
See the irony is that all these things that I have, the success, the trophies, my cars, my house and all. I thought that brought me happiness. But I was feeling really down, having severe depression. Having all these thoughts of my possessions, they brought me no joy. The thought of, you know, I can hug my Ferrari to sleep, no. No, it is not going to happen. It brought not a single comfort during my last ten months. And I thought they were, but they were not true happiness. But it wasn't. What really brought me joy in the last ten months was interaction with people, my loved ones, friends, people who genuinely care about me, they laugh and cry with me, and they are able to identify the pain and suffering I was going through. That brought joy to me, happiness. None of the things I have, all the possessions, and I thought those were supposed to bring me happiness. But it didn't, because if it did, I would have felt happy think about it, when I was feeling most down..
You know the classical Chinese New Year that is coming up. In the past, what do I do? Well, I will usually drive my flashy car to do my rounds, visit my relatives, to show it off to my friends. And I thought that was joy, you know. I thought that was really joy. But do you really think that my relatives and friends, whom some of them have difficulty trying to make ends meet, that will truly share the joy with me? Seeing me driving my flashy car and showing off to them? No, no way. They won’t be sharing joy with me. They were having problems trying to make ends meet, taking public transport. In fact i think, what I have done is more like you know, making them envious, jealous of all I have. In fact, sometimes even hatred.
Those are what we call objects of envy. I have them, I show them off to them and I feel it can fill my own pride and ego. That didn't bring any joy to these people, to my friends and relatives, and I thought they were real joy.
Well, let me just share another story with you. You know when I was about your age, I stayed in king Edward VII hall. I had this friend whom I thought was strange. Her name is Jennifer, we're still good friends. And as I walk along the path, she would, if she sees a snail, she would actually pick up the snail and put it along the grass patch. I was like why do you need to do that? Why dirty your hands? It’s just a snail. The truth is she could feel for the snail. The thought of being crushed to death is real to her, but to me it's just a snail. If you can't get out of the pathway of humans then you deserve to be crushed, its part of evolution isn't it? What an irony isn't it?
There I was being trained as a doctor, to be compassionate, to be able to empathize; but I couldn't. As a house officer, I graduated from medical school, posted to the oncology department at NUH. And, every day, every other day I witness death in the cancer department. When I see how they suffered, I see all the pain they went through. I see all the morphine they have to press every few minutes just to relieve their pain. I see them struggling with their oxygen breathing their last breath and all. But it was just a job. When I went to clinic every day, to the wards every day, take blood, give the medication but was the patient real to me? They weren't real to me. It was just a job, I do it, I get out of the ward, I can't wait to get home, and I do my own stuff.
Was the pain, was the suffering the patients went through real? No. Of course I know all the medical terms to describe how they feel, all the suffering they went through. But in truth, I did not know how they feel, not until I became a patient. It is until now; I truly understand how they feel. And, if you ask me, would I have been a very different doctor if I were to re-live my life now, I can tell you yes I will. Because I truly understand how the patients feel now. And sometimes, you have to learn it the hard way.
Even as you start just your first year, and you embark this journey to become dental surgeons, let me just challenge you on two fronts.
Inevitably, all of you here will start to go into private practice. You will start to accumulate wealth. I can guarantee you. Just doing an implant can bring you thousands of dollars, its fantastic money. And actually there is nothing wrong with being successful, with being rich or wealthy, absolutely nothing wrong. The only trouble is that a lot of us like myself couldn't handle it.
Why do I say that? Because when I start to accumulate, the more I have, the more I want. The more I wanted, the more obsessed I became. Like what I showed you earlier on, all I can was basically to get more possessions, to reach the pinnacle of what society did to us, of what society wants us to be. I became so obsessed that nothing else really mattered to me. Patients were just a source of income, and I tried to squeeze every single cent out of these patients.
A lot of times we forget, whom we are supposed to be serving. We become so lost that we serve nobody else but just ourselves. That was what happened to me. Whether it is in the medical, the dental fraternity, I can tell you, right now in the private practice, sometimes we just advise patients on treatment that is not indicated. Grey areas. And even though it is not necessary, we kind of advocate it. Even at this point, I know who my friends are and who genuinely cared for me and who the ones are who try to make money out of me by selling me "hope". We kind of lose our moral compass along the way. Because we just want to make money.
Worse, I can tell you, over the last few years, we bad mouth our fellow colleagues, our fellow competitors in the industry. We have no qualms about it. So if we can put them down to give ourselves an advantage, we do it. And that's what happening right now, medical, dental everywhere. My challenge to you is not to lose that moral compass. I learned it the hard way, I hope you don't ever have to do it.
Secondly, a lot of us will start to get numb to our patients as we start to practice. Whether is it government hospitals, private practice, I can tell you when I was in the hospital, with stacks of patient folders, I can't wait to get rid of those folders as soon as possible; I can't wait to get patients out of my consultation room as soon as possible because there is just so many, and that's a reality. Because it becomes a job, a very routine job. And this is just part of it. Do I truly know how the patient feels back then? No, I don't. The fears and anxiety and all, do I truly understand what they are going through? I don't, not until when this happens to me and I think that is one of the biggest flaws in our system.
We’re being trained to be healthcare providers, professional, and all and yet we don't know how exactly they feel. I'm not asking you to get involved emotionally, I don't think that is professional but do we actually make a real effort to understand their pain and all? Most of us won’t, alright, I can assure you. So don't lose it, my challenge to you is to always be able to put yourself in your patient's shoes.
Because the pain, the anxiety, the fear are very real even though it's not real to you, it's real to them. So don't lose it and you know, right now I'm in the midst of my 5th cycle of my chemotherapy. I can tell you it’s a terrible feeling. Chemotherapy is one of those things that you don't wish even your enemies to go through because it's just suffering, lousy feeling, throwing out, you don't even know if you can retain your meals or not. Terrible feeling! And even with whatever little energy now I have, I try to reach out to other cancer patients because I truly understand what pain and suffering is like. But it's kind of little too late and too little.
You guys have a bright future ahead of you with all the resource and energy, so I’m going to challenge you to go beyond your immediate patients. To understand that there are people out there who are truly in pain, truly in hardship. Don’t get the idea that only poor people suffer. It is not true. A lot of these poor people do not have much in the first place, they are easily contented. for all you know they are happier than you and me but there are out there, people who are suffering mentally, physically, hardship, emotionally, financially and so on and so forth, and they are real. We choose to ignore them or we just don't want to know that they exist.
So do think about it alright, even as you go on to become professionals and dental surgeons and all. That you can reach out to these people who are in need. Whatever you do can make a large difference to them. I'm now at the receiving end so I know how it feels, someone who genuinely care for you, encourage and all. It makes a lot of difference to me. That’s what happens after treatment. I had a treatment recently, but I’ll leave this for another day. A lot of things happened along the way, that's why I am still able to talk to you today.
I'll just end of with this quote here, it's from this book called Tuesdays with Morris, and some of you may have read it. Everyone knows that they are going to die; every one of us knows that. The truth is, none of us believe it because if we did, we will do things differently. When I faced death, when I had to, I stripped myself off all stuff totally and I focused only on what is essential. The irony is that a lot of times, only when we learn how to die then we learn how to live. I know it sounds very morbid for this morning but it's the truth, this is what I’m going through.
Don’t let society tell you how to live. Don’t let the media tell you what you're supposed to do. Those things happened to me. And I led this life thinking that these are going to bring me happiness. I hope that you will think about it and decide for yourself how you want to live your own life. Not according to what other people tell you to do, and you have to decide whether you want to serve yourself, whether you are going to make a difference in somebody else's life. Because true happiness doesn't come from serving yourself. I thought it was but it didn't turn out that way.
Also most importantly, I think true joy comes from knowing God. Not knowing about God – I mean, you can read the bible and know about God – but knowing God personally; getting a relationship with God. I think that’s the most important. That’s what I’ve learned.
So if I were to sum it up, I’d say that the earlier we sort out the priorities in our lives, the better it is. Don’t be like me – I had no other way. I had to learn it through the hard way. I had to come back to God to thank Him for this opportunity because I’ve had 3 major accidents in my past – car accidents. You know, these sports car accidents – I was always speeding, but somehow I always came out alive, even with the car almost being overturned. And I wouldn’t have had a chance. Who knows, I don’t know where else I’d be going to! Even though I was baptized it was just a show, but the fact that this has happened, it gave me a chance to come back to God.
Few things I’d learned though:
  1. Trust in the Lord your God with all your heart – this is so important.
  2. Is to love and serve others, not just ourselves.
There is nothing wrong with being rich or wealthy. I think it’s absolutely alright, because God has blessed. So many people are blessed with good wealth, but the trouble is I think a lot of us can’t handle it. The more we have, the more we want. I’ve gone through it, the deeper the hole we dig, the more we get sucked into it, so much so that we worship wealth and lose focus. Instead of worshiping God, we worship wealth. It’s just a human instinct. It’s just so difficult to get out of it.
We are all professionals, and when we go into private practice, we start to build up our wealth – inevitably. So my thought are, when you start to build up wealth and when the opportunity comes, do remember that all these things don’t belong to us. We don’t really own it nor have rights to this wealth. It’s actually God’s gift to us. Remember that it’s more important to further His Kingdom rather than to further ourselves.
Anyway I think that I’ve gone through it, and I know that wealth without God is empty. It is more important that you fill up the wealth, as you build it up subsequently, as professionals and all, you need to fill it up with the wealth of God.

Thursday, June 25, 2015

Graduated Today

This all starts from the day first in school.
I remember I used to cry for all that routine and loved to spend time in home in early days of my school life. Not because school scared me. I loved to spend all my day watching those 30 minutes Urdu dubbed episodes of cartoons I anxiously waited for whole week. PTV was the best channel and I used to follow-up schedule of each program. Regardless of quality of channel and bad pixel per inch of that old TV. I was more into stories and colours.
I used to make up stories at run time half an hour before school-time just to make sure I spend whole day watching cartoons and drinking soup to cure the disease I didn’t have. Somewhere, deep inside, I knew my mother and father know about my lies, and they ignored sometimes, sometimes not.
I grew up, went for matriculation, became more responsible and serious about my studies and isolated myself from these fragments of happiness that used to made my day.
Then I got admitted into college and became more belligerent in talks about different careers and highly paid jobs, well that is not something to worry about; life is more important than a piece of paper that wants to rule over you. Started answering myself the questions like, “What is the purpose of this studying and that will be the outcome? What I want to become? In what field I will pursue my career?” This all didn’t make sense sometimes because I didn’t fully trust my skills and I wasn’t fully guided.
God never plays dice. He knew where I had to go what I had to do so there is a thing named, a ripple effect; changing future completely into something else by the choices you take in present. We see things like they will happen and sometimes they happen exactly the same. That is a blessing of Allah not our ability to foresee.
I started studying computer sciences, though I was already doing that in intermediate. I wasn’t completely sure about my career in it that time. When I started doing CS. Every piece of puzzle happened to adjust itself in front of my eyes and I started to see the picture behind the puzzle. Days passed, weeks rushed and months went like some pages skipped when you want to reach a specific page number. The page number I wanted to reach on turned out very beautifully written. Each and every spell makes me happy. Every verse written on it makes sense now.
That’s where I stand today. Holding a bachelor’s degree (not so fast) of computer science. Having a job at a good place.
"Allah never makes you unsatisfied when you make an effort."
That is the lesson I learned from this short period of my life that changed way I used to live it.

Saturday, April 25, 2015


ابھی تو تتلیوں میں ڈھیر سارا رنگ بھرنا تھا
ابھی تو زندگی نے چند لمحے ساتھ چلنا تھا
ابھی تو دن سے پہلے دن کا اک اغاز ہونا تھا
ابھی اس زندگی کے شور کو اک ساز ہونا تھا
ابھی ان کاغذوں کی کشتیوں نے دور جانا تھا
ابھی تو بادلوں کی اِس گرج کو تھم سا جانا تھا
نا جانے کیوں مرا دن رات سے پہٖلے نہیں آیا
نا جانے کیوں مرے کانوں میں ہے اس شور کا سایہ
نا جانے کیوں یہ کاغذ اتنی جلدی بھیگ جاتے ہیں
نا جانے کیوں ہماری زندگی میں موڑ آتے ہیں
نا جانے کیوں ہم دنیا اتنی جلدی چھوڑ جاتے ہیں
(فہد صدیقی)

Monday, April 13, 2015

Days these Days

So here is my schedule these days.
What I majorly focus on these days is, of course, my courses and stuff I'm learning online. There is a but in the next sentence. But, I love to play guitar when I feel bored.
According to me playing music soothes your mind and keeps your memory intact. You use most of the cerebral capacity of your brain playing some music instrument. More than while multitasking, cooking, building sense in some problem or even programming some hardcore stuff. This is what I experienced. Music keeps me focused.
"Kehtay hain khudaa ne iss jahan..." Oh sorry I started singing. Catch you later.

Thursday, April 9, 2015

Good News

"Got a job!" - here is me declaring that I'm officially the part of Platalytics Inc. now. Just have signed an official contract regarding my position at Platalytics Inc. This is really a huge change in life since I'm one step already into professionalism, creating applications & games on my own, this would be a real challenge to solve.
Life comes up with such challenges you will always solve, you were meant to solve them. That is why they came in your path. Some challenges are solvable. Some, we think, are not solvable. But the truth is, human capacity is far more capable doing unthinkable.
This challenge, I mean managing job and life, might look very complicated. That's what I'm made up of. Complications. And I always solve the problem. That's what I am.

Tuesday, March 17, 2015

Freedom, Finally!

Finally have some time to spend on myself. Been caught in many things for a while. Working as a teacher assistant was hard and it really got some part of my life away from me. Things I had to do were in a pause state for a long time. Since I started working as a teacher assistant I had plan to finish some unfinished game projects, but I was too busy working in weekends. Now that I have left it, I'm no more bound to those things anymore.
So now, spirits high, *SNIFF SNIFF*. I'm ready to work on my Dino Run game project. Yay.
Learning to do this weekend:
  1. 2D sprite animations
  2. particle effect in Unity
  3. parallax
  4. shaders
Finishing this project and launching my first endless runner would be awesome.
Spirits high, again.

Thursday, March 5, 2015

First Game Ever Published

My first game Windows Phone 8 named "Switch'em" got published in Windows Phone store.

Unique thing about this game is that there is not second way to clear a level. A level can be cleared exactly flipping back the same number of tiles that were flipped while generating that level. Simple and elegant design with no extra fruits or fairy magic in UI makes it more attractive and appealing at first sight. Not copying anything but I recreated the theme of 2048 and #Wordament like games.

Here is the link to this game (Switch'em)

IsolatedStorage in Windows Phone

I was trying to fix the bug recently I was talking about in my last post. The problem was that I was actually using app local storage to store some game scores (and stuff). Turns out you cannot write in app local storage (you cannot open a file to write). msappx:// this storage defines the app local storage.
Solution to this problem was IsolatedStorage. As the name suggests there is an isolation in this type of storage in terms of data access (only the app using this storage can manipulate it).

This link helped me getting my problem solved. Thanks +Tuts+ Code.

Maintenance: Why So Cruel?

Last night we were coding, coding and just coding. Slept at 4:30am and repeatedly done the same for next day. After everything was totally fine, the game was running, we deployed on emulator, physical device, tested everything. Nothing was alarming that's why I uploaded the game in Windows Phone store. After the game got published and appeared in app store. I published the link everywhere in social media without first downloading in my phone and checking it first. Here is what I got. A bug. This made me swear I'll never publish an app without setting permissions from app manifest. Huh. Sick mother of debugging it was.

Friday, February 27, 2015

Stop Chasing the Wrong Things

This world is full of negativity, around you, beside you, inside you and even you're your own source of negativity.
"When you stop chasing the wrong things, you give the right things a chance to catch you."
Don't chase, stop running around the goals. Make one, and start doing something for it. Sketch a line inside your mind. Think binary. There is nothing pseudo-positive or something non-negative. Everything is either negative or positive and you got to stay away from what you categorize as negative. Although you'll feel so much attraction between these two poles. You got to chose one. You got to be choosing the positive one.

Thursday, February 26, 2015

You are the Product of Your Own Imagination

You're the best thing ever happened to "you". You are the person who can actually do something for yourself. People create so many social connections, be dependent, and rely on others that their whole life circulates around caring for others, thinking for others, making others happy and taking full responsibility of what happens to others. Others are not you. They aren't going to grieve for you when you don’t exist. They aren't going to care for you when you are down.
This is a reality you need to understand.
You are the person who can make a difference in your life. You are the only one you should use the world “awesome” for. You are your own version of superhero.
The real moment of ascertaining your courage and shouting in front of your crowd is, when you're knocked down. When you've nothing, you have every path to select. People going towards some path have difficulty in switching between paths and fear of losing both destinies. You're lucky, you've multiple ways to go. You can try again. You've nothing to fear about losing your destiny yet. Make a right selection, listen you your inner voice and shut the voices that whisper to you about your paleness. Feel yourself alone in the crowd. Make yourself isolated from the society that acts caring about you.

Imagine yourself. Dream about your goals. Daydream. Draw a roadmap. Draw brightest colors on your mind-canvas. Permanent ones. Never remove it.
"You are the product of your own imagination."
You can do it, you don't need help. It is your move now.

Wednesday, January 7, 2015

Theory - 1

What if the things you experience sometimes and think they already happened before, but actually, are never happened, are actually happened in some kind of other world of some other parallel universe out there? What if you are a part of some kind of parallel execution and you are not just you, there are many other clones doing same? There are so many galaxies and what was the point to make it practically impossible to reach from one galaxy to another galaxy. Why there isn't another earth just a moon away from our earth?

Sunday, January 4, 2015

How to Create DoubleAnimation in Windows Apps?

I was searching for a good source to read double animation in windows apps but didn't find anything easily understandable, I mean there was a lot of code overdosing the idea of "animation". What I came up with as a solution was, the lecture from a series created by +Bob Tabor.

What DoubleAnimation is?
A simple animation that animates target storyboard property in double data type. For example, take Opacity; it ranges from 0.0 (invisible) to 1.0 (visible).

Now to actually run this animation we just need to user Where MyStoryBoard_FadeOut is the x:Name property of that storyboard you wan't to animate.
What it actually does is fading out the opacity of target button `Button1` in 2 seconds.