The Death Clock

January 16th, 2010 by junal View Comments »

Caution : I’m *not* going to write anything positive or anything that could make you smile, rather, i’m going to write something that will make your mood upset all the way…now, you decide if you want to read this article…

It’s all about death, an universe truth. right, there’s no shame on death, we all have to die one day. But this truth is always pathetic, and no one’s out there willing to accept it for their beloved. I’m going to talk about 2 death experience with my eyes and I will talk about haiti’s devastating situation. To be honest, I don’t know what i’m trying to say with all these…there is no solution for death. No one can stop it, then why i’m writing to make you upset? Not really, im trying to find a way to get out of this emotion that i’m feeling about death right now, maybe my blog will help me to do that…

First story…

Abul was my school friend at primary school, we were in grade 4 at that time and I was in our village. One day morning I got up and heard that Abul’s mom was dead. I was staring at my mom when she told me that. Mom are you sure? I asked…Mom told me to go to their house. I’m not enough brave guy to see a dead body or go to airport to see off people! But, I ran and found that Abul was crying…and his mom was just sleeping [sleep forever], he stared at me and started crying even louder. Probably, I wouldn’t understand the emptiness he was feeling at that time…i was so speechless and scared that I didn’t know what to do or what to say to Abul! You know what, I didn’t even go near to the dead body, mentally I was that much broken but mostly I was feeling bad for my childhood friend Abul, cuz he was only 9/10 yrs old boy, and I kept thinking that he would spend rest of his life without calling someone “mom”? Probably, I didn’t worry that much about someone who left this world but Abul who was there for rest of his life. So, Abul kept going near to his mom and kept looking at her, I was watching that from a distance and all I was thinking like “ishh, what is he feeling inside”. But most, pathetic thing I saw at the end, and I will NEVER forget this moment for rest of my life… at the end Abul’s father was like, “Abul come here baba, see your mom for the last time”. Abul went, and he started crying holding his mom…i couldnt hold my tears anymore! Wait..let me give a break, I will write more later…

Ok , i’m back…

Second story…

Few days ago, one of my friends mom died for cancer. So we went to see her [specially his family]. Was glad to see that our friend was really strong, like he was walking, arranging everything and talking to visitors normally. He kept telling us, how she had good death instead of having trouble for another few more months [as doctor said she would live another 6 months]. But, we saw the most pathetic thing in the corner of the room, friend’s father was sitting there on a chair, and he was trying to talk but couldn’t. We went there and stood in front of him, suddenly he started crying! Personally, I didn’t know what to do..then he started talking holding his son [our friend] and his daughter! All he was saying was like “I tried my best to save her, I couldn’t! You don’t know how much I loved your mom!”. Whoa, emotional junal would start crying, but somehow he kept himself in control, but it got me all the way when I got back home, I never saw such a true love like this before! Was kept asking myself, why people have to die?

Third story…

I can remember the last devastating situation in Tsunami, and now we all are watching another moron at the beginning of the year called Haiti! Honestly, like big loser im trying to avoid all news related to Haiti, why? Because, im such a loser who can’t do anything about it except reading/sharing and talking about it. So what’s the point? But, seems like I just can’t avoid this news or pictures from Haiti. These people are very poor, why almighty was so unkind to them? What they did so he had to take away everything from their life? I don’t know who can answer me that….

Anyways, let’s pray to God to save rest of these lives…and show this loser some ways to do something for this people instead of just praying to you!

Recall: 2009

December 25th, 2009 by junal View Comments »

Couple days ago I was reading my last blog in 2008 and became a little bit nostalgic. One year is not a long time, but lot’s of things can happen in one year. Saying it again, never had such expectation out of time but I must say 2009 was the BEST year of my life so far! Because, I got married in 2009! I got married to love of my life in July, 22nd :)

Spoke at tech seminar arranged by PhpExperts group, and that was a great day for me to be in front of lots of talents from Bangladesh. It helped me to understand this local community I know and I love from my heart. I met lot’s of people I know from twitter/friendfeed/facebook but never saw them before. Though I couldn’t meet all the guys I know…and well, it helped me to get closer with some talent speakers , whoa!

Working at Trippertlabs is always fun, what a year it has been for this company! Working on some exciting iPhone projects and after a couple days you see them in the top list at iPhone app store, how does it feel? I can remember the weekend we worked on some iPhone quiz applications and one of them went to #1 position in the free app category. This excitement continued through out the year dude but out of all these biggest news from my company was acquisitions by Playdom!

“Amra Positive” idea came from some frustrations and interest to learn python. This is a personal project I developed for local community to share all good news within 150 chars. I was glad to receive some positive response from all kinds of users. I hope to upgrade this app soon on spare time but I will love to get more feedback and advices from you guys :)

What else? There are lots of things to recall from 2009. What an eventful year! But let’s not be more geek on this…let me remind my promise that I wanted to have Eid-ul-adha with my village people. This is one of the place I truly love to be. This year wasn’t any exception. As usual I had my Eid with my village people with some different moments….

What’s gonna happen in 2010? There’s gonna be lots of changes in my life, Uhm, but no guess…as I always say, wake up every morning and do what you enjoy the most…i will be keep following this theory by keeping very less expectations….

Regular Expression to Find All Mentioned Names by ‘@’

December 12th, 2009 by junal View Comments »

Most of the time we use ‘@’ to mention someone’s name in email thread, forum, etc. How about to find those mentioned names using PHP regular expression? Let’s consider the following text.

“Hey @Junal how about going for a vacation to @Srimangal? @Jewel said it’s an awesome place”
We will find all names that is mentioned by @ here. So let’s write the pattern first.

$pattern = “/^(?:[a-zA-Z0-9?. ]?)+@([a-zA-Z0-9]+)(.+)?$/”;

See, first portion of the pattern is optional, some one can start your name @junal or hey @junal right. And then we are matching with ‘@’ separating them from @ sign. Rest portion of the patter is quite easy, as we can keep text after the name (I.e @junal you suck)

Ok, now let’s use the php preg_match() function to find the matches. If we find the matched it will return 1 else 0.

$pattern = "/^(?:[a-zA-Z0-9?. ]?)+@([a-zA-Z0-9]+)(.+)?$/";
$str = "Hey @Junal hey how are you?";
preg_match($pattern, $str, $matches);
print_r($matches);
//Output : 
Array
(
    [0] => Hey @Junal hey how are you?
    [1] => Junal
    [2] => hey how are you?
)

So, if we want to find first matched name then it’s pretty straight forward to get it from $matches[1]
but what if we want to find multiple name from a text? Well, then we have to search $matches[2] if there is anymore mentioned name wit @ right?… let’s do it this way…

do {
   preg_match($pattern, $matches[2], $more_matches);
   $name_list[$counter++]  = $more_matches[1];
   $count = count($more_matches);
   $matches[2]=$more_matches[($count-1)];
   $more_matches = "";
   } while($count>=3);

this above code might be confusing. So let’s see the complete function that returns us an array of names that are mentioned by ‘@’ and well, we will also remove the duplicate names.

< ?php
/*
 * isn't the name self explanatory ?
 */
function giveme_names_from_at($str) {
    $pattern = "/^(?:[a-zA-Z0-9?. ]?)+@([a-zA-Z0-9]+)(.+)?$/";
    $str = trim($str);
    preg_match($pattern, $str, $matches);;
    if($matches) {
        $counter = 0;
        $name_list = array();
        $name_list[$counter++] = $matches[1];
 
        do {
            preg_match($pattern, $matches[2], $more_matches);
            $name_list[$counter++]  = $more_matches[1];
            $count = count($more_matches);
            $matches[2]=$more_matches[($count-1)];
            $more_matches = "";
        } while($count>=3);
 
        if(!empty($name_list)) {
            $all_names = array();
            $i = 0;
            foreach ($name_list as $key => $value) {
                if (!is_null($value) && (!in_array($value, $all_names))) {
                    $all_names[$i] = $value;
                    $i++;
                }
            }
        }
        return $all_names;
    }
}
 
//Example 
 
$str = "Hey @Junal how about going for a vacation to @Srimangal? @Jewel said it's an awesome place";
$names = giveme_names_from_at($str)
print_r($names);
 
//Output: 
Array
(
    [0] => Junal
    [1] => Srimangal
    [2] => Jewel
)
?>

Ok well, output shows what we needed. But using regular expression is not always a good idea as it’s slower than standard string manipulation functions. How would you like to find these answers without using RE? Or can we improve this pattern to make It smarter?

Dear Brac Bank Internet Service, You Suck!

December 6th, 2009 by junal View Comments »

Really pissed off at Brac Bank internet banking service. I have been using it for last 1 year to see my transaction, debit, credit etc. Link that they gave me to log in, wasn’t even with a domain name. But anyways, that’s not my headache. I’m happy as long as I get the proper information that I registered for.

Few days back, I tried to log in to see my transaction and stuff and it said site is down or moved to a new address.

Site was moved in a new address

Site was moved in a new address

I tried it after 2 days again, but no information regarding the change. Shouldn’t have the informed me that they moved to a new location? Don’t I deserve it as their customer? So I sent an email to their IT dep and asked about it, they replied saying …

“….This requires a higher level of security for our systems and processes. Therefore, we are asking all previous I-banking subscribers to register once again to ensure that the new security standards are maintained.

after reading this, first thing came in my mind was like “WTF”, why the hell I have to register or fill up a form again? Don’t you already have my all information. I have never seen this kind of service before from any site!

But what could I do, I went to Brack Bank and registered for it again. And today they sent me a new link and log in information to use the internet banking service. I was happy yay! But hey, when I went to log in from the actual link it says “This site only supports Internet Explorer”! What?!? I don’t use IE and when I have to use I use it in VB XP. Do you think I should login to XP just to use your service dear BB?

Sorry i dont use IE for browsing...

Sorry i dont use IE for browsing...

I’m sorry, but this is complete bullshit. Don’t Firefox and Chrome have Anti-fishing capability? Or .NET framework (site is developed on .NET) always asks you to restrict users with IE?

I don’t know what option I should choose now. But Brac Bank should be careful about their customer serive. Till now it sucks!

Javascript: Object Detection or Browser Detection?

November 21st, 2009 by junal View Comments »

This question can be answered easily with “object detection” – why? Because some obscure browsers won’t be treated correctly and browsers that appear after you’ve written the page may not be adequately covered either as a result you will end up with some error in some browsers. Object detection works fairly in all browsers.

But, certain features of Javascript don’t work in all browsers. As an example “innerText” property doesn’t work in Firefox but in IE, Chrome Etc…this problem could be solved easily like the following ..

var text = x.innerText || x.textContent
//innerText for IE or other browsers and textContent for Firefox that works well.

Now, consider the following statement

Google Chrome doesn’t read encoding information that’s declared with document.write(). If you’re using this method to declare encoding in iframes, for example, you may see garbled characters when the iframe is rendered. Instead of:

document.write("<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">");
    ... other JavaScript code ...
</meta>

and when it might arrived? Let’s say you are using a Rich Text Editor where you will have onload events with document.write() and you will notice that iframe attribute (e.g name) value is not getting in the browser. Rather Chrome is setting name attrribute value from itself.

There is a tricky way to get it solved, in my case I used Firebug extension to get the attribute value and then detect the browser. Well in that case object detection doesn’t work for me. I must use browser detection right.

Let’s have a look at the following codes to get some idea about what I have been talking…

function notEmpty(){
 
        var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
        var textvalue = '';
        var framename = '';
        var elementValue = ''; 
 
        if(is_chrome) {
            elementValue = window.frames['Rich text editor'].document.body.innerText;
        }
        else if(navigator.appName =="Microsoft Internet Explorer") {
            elementValue = window.frames['myIframe'].document.body.innterText;
        }
        else {
            elementValue = window.frames['myIframe'].document.body.textContent;
        }
 
        if(elementValue =='')
        {
            //do what you want
            return false;
        }    
        return true;
    }

Conclution: It depends, generally it’s always good to use object detection no doubt. But when you have no option? Well then don’t wait to use browser detection eh… ;)

Get Adobe Flash playerPlugin by wpburn.com wordpress themes