Lost in translation…

Posted by Montu on November 21, 2008

I have lost my middle name in Chennai. Now I am either Kumar or Sharma not Kumar Chetan Sharma or Chetan or Chetan Sharma. For some one who is very very very fussy about his name, its a…don’t have words. :-|

Forcing browser to show file download prompt for html file - The Content-Disposition Header Field

Posted by Montu on November 20, 2008

I came across an interesting post title how to use PHP/Perl to display JavaScript. Interesting in the sense that author have displayed a nice way to dump JavaScript. I have another way of doing the same. I will simply save a JS file as a PHP file and will add some header statements on top of it and will use this PHP file as a JS source file wherever I want. This way I can take advantage of environment variable or some other setting. Its not rocket science. But header can do a lot. Look at the following example.

<?php
$examplFiles = array(
array('name'=>'an-html-doc.html', 'mimeType'=>'text/html', 'disposition'=>'inline'),
array('name'=>'an-html-doc.html', 'mimeType'=>'text/html', 'disposition'=>'attachment'),
);
$id = $_GET['id'];
if(isset($examplFiles[$id]) && file_exists($examplFiles[$id]['name'])){
header('Content-Type: '.$examplFiles[$id]['mimeType']);
header('Content-Disposition: '.$examplFiles[$id]['disposition'].'; filename='.$examplFiles[$id]['name']);
ob_clean();
flush();
readfile($examplFiles[$id]['name']);
exit;
}else{
echo 'Error 404, file not found!';
}

Save this file on your LAMP stack with a name, say “a-cool-php-script.php” and access it through your browser with some id passed to it. Of course you also need to create an html file and named “an-html-doc.html” to run this script or all you will get is 404 error. For id=0 the html file will be displayed in browser and for 1 you will be presented with a file download dialog box or prompt.

Isn’t this interesting. You an use this simple code snippet to check any kind of file. All you need to know is MIME type of the file. A list of MIME types can be found here.

The example is in PHP but same will work for any web scripting language. For more read RFC 2183.

The world economy…

Posted by Montu on November 18, 2008

The world economy depends on Love. Love for parents, siblings, kids, spouse & for country…that’s the reason we buy anything from toy gun to real guns.

Astonishing fact. :-)

A psycho!

Posted by Montu on November 18, 2008

Recently I have been labeled a “psycho” on a blog. To be more precise a guy commenting over a girl’s blog labeled me a psycho. This is an old school technic of wooing girls. You try to be a protector savior superhero of the girl by echoing her words and bad mouthing other guys. Normal. But then its really cheap technic and normally and as usual, girls fall for this. Simple.

Oh am deviating from the title of this post. I am a psycho. The psychic act I have done was I laughed on a girlie blog. My mistake. Why did I, at firs place, commented on that stupid personal rant. Then, as per my assumption, that girl was/is not mature enough to handle comments and I thought she will delete my comments. Such female bloggers normally do. But she approved and this led me saying that she was supposed to approve my comment and then I talked about my girl (:-X ) and some interview call and called her by her name which she mentioned on her blog. Here you go, she not only deleted my comment but also bounced back. As that wasn’t enough, a savior came along labeling me Psycho. I took it lightly and kind of complained directly to that guy. He in turn labeled me

  • bitch boy
  • cheesy

Where is the world going? The girl in question is an important figure and if she was not that important I would have replied with some thing offending and insulting to both the savior and the girl. Anyway. Now I am psycho >:) muahahahahaha

18 Rules between Men and Women

Posted by Montu on November 17, 2008

I copied this from a blog but I will not link that blog back coz the blog owner tried to offend me and another blogger called me a “Psycho”. >:) But I liked these rules and I am going to mail these to everyone too! ;-)

1. The Female always makes THE RULES.

2. THE RULES are subject to change without notice.

3. No Male can possibly know all THE RULES.

4. If the Female suspects the Male knows all THE RULES, she must immediately change some or all of THE RULES.

5. The Female is never wrong.

6. If it appears the Female is wrong, it is because of a flagrant misunderstanding caused by something the Male did or said wrong.

7. If Rule #6 applies, the Male must apologize immediately for causing the misunderstanding.

8. The Female can change her mind at any given time.

9. The Male must never change his mind without the express, written consent of The Female.

10. The Female has every right to be angry or upset at any time.

11. The Male must remain calm at all times, unless the Female wants him to be angry or upset.

12. The Female must, under no circumstances, let the Male know whether she wants him to be angry or upset.

13. The Male is expected to read the mind of the Female at all times.

14. At all times, what is important is what the Female meant, not what she said.

15. If the Male doesn’t abide by THE RULES, it is because he can’t take the heat, lacks ackbone, and is a wimp.

16. If the Female has PMS, all THE RULES are null and void and the Male must cater to her every whim.

17. Any attempt to document THE RULES could result in bodily harm.

18. If the Male, at any time, believes he is right, he must refer to Rule #5


Fine Print: In very short I own my views & if you don't like something on my blog, I am sorry, I can't help you. In fact I am not even sorry. Ch33r5.