Author Archives: Sunny Walia

PHP: Curl being slow from php call on CentOS 5.4

I ran into an issue where curl request run within few ms from command line but same url fetch was taking over 10 secs. After doing some debugging and research it turned out that call to check (getaddr ipv6 was timing out. Obviously you can do multiple things to fix this (including enabling ipv6 support) but since I did not have a need for ipv6 (it is disabled in my network configuration), I decided to recompile curl and disable ipv6. Here is the command for recompiling curl and installing into /usr/local/curl directory with ipv6 disabled.

./configure –prefix=/usr/local/curl –disable-ipv6

————————————-
DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. Use at your own risk.

Virus: What is mygener.im virus on facebook?

If you are a facebook user, please be aware that mygener.im virus is spreading quickly on facebook. From what I have seen online so far, it seems to redirect to a site which probably is stealing data from you computer and/or installing trojans. Initially it looks like this site allows to create generation tree and looks like a legit domain. This is being spread via messages to you from other friends of yours who are “infected”.

One of the things you can do to prevent getting “infected” is to not click on any links on facebook. Even if it comes from friends you trust.  It would also be a good idea to arm your self with the best virus protection software.  If you do click on a link, make sure you don’t enter any login/passwords  on any sites you end up on.

Here is an article on eHow which talks about avoiding the virus:  how to avoid mygener.im on facebook

EDIT:  some people have reported that destination url has changed at least once so you may end up on a site which looks like aother “legit” site.

Health: H1N1 Swine Flu Google Map

There has been a lot of talk on the news about the swine flu and how it is spreading fast and a lot of people are affected. Here is something worth checking out, a google map with incidents marked with information on areas affected, how many dead, infection reported, etc.

http://tinyurl.com/cosuzr

Watch where you hang out and if you are feeling any symptoms, go see a doctor.

Here is some info from  wikipedia:

Mexican officials state that since March 2009 there have been over 1600 reported cases and put the death toll at 149, with 20 confirmed to be linked to a new swine influenza strain of influenza A virus subtype H1N1.

In the US, twenty-eight cases have been confirmed among New York students, seven in California, two in Texas, two in Kansas and one in Ohio; all have recovered. Kansas state health officials confirmed two cases of swine flu in Kansas on April 25, 2009, just minutes after eight school children in New York City were believed to be infected after a school trip to Mexico. The New York case had been confirmed as influenza A virus, which met the Centers for Disease Control and Prevention (or CDC) definition of a probable case of swine flu. Tests have now confirmed that this flu virus is the new strain of H1N1, according to reports on UK BBC News. On April 25, 2009, Texas closed a high school near San Antonio indefinitely after a third student showed symptoms of swine flu.

In Canada, the virus has now been confirmed in six cases. There are also three confirmed cases outside North America. The first confirmed case in Europe has occurred in a man in Spain, the second and third in Scotland in the UK. In Scotland there are two confirmed cases being treated in a hospital in Airdrie, Lanarkshire. The results from their tests came in at 6.10pm on 27 April 2009 and were confirmed as positive. These are the first two confirmed cases in the UK and the second and third in Europe. On April 26, 2009, students from Rangitoto College and Northcote College, both on the North Shore of Auckland, New Zealand, returned from school trips to Mexico and began exhibiting signs of influenza. Like the US students, they tested positive for influenza A which means swine flu is highly likely, however definite results are pending. There have also been reports of suspected infection in Australia, Brazil, Chile, France and Israel. Airports worldwide are on alert, with passengers from Mexico entering Japan being screened for the virus.

The head of the World Health Organization will lead the agency’s efforts against a deadly swine flu outbreak. The World Health Organization warns this new swine flu has the potential to become an international influenza pandemic. On April 25, 2009, the World Health Organization issued a document called the Swine influenza frequently asked questions. On April 24, 2009, the World Health Organization agreed that the current situation constitutes a public health emergency of international concern. The EU are advising against non essential travel to Mexico and the USA. Experts warn that use of face masks does not provide adequate protection. Face masks only work when dry; after an hour or two the breath causes the fabric to become damp and then it does not provide filtration of infection. A face mask must be replaced every two hours and the one used disposed of or cleaned. The WHO have increased the level pandemic alert to phases 4 on a 6 point scale. Phase 4 indicates a “significant increase in risk of pandemic”.

Telnet: shell script to issue commands to telnet session.

This is a quick post to show how one can issue commands to telnet session from a shell script or command line with out going into interactive mode. I use this to get stats from our memcache servers or issue a flush_all via telnet from a script/cron.

So without further delay, following command will telnet to local memcached server on port 11211 and issue one of the memcached commands, stats

(sleep .5;echo stats) | telnet localhost 11211
You may have to play with the sleep timer to get it to work for your environment but in our .5 was the sweet spot. Good luck and let me know if you have another shell command. Obviously we can do this from perl, php, python, etc but the beauty of this is that you do not need any other dependencies plus its a very short command.

Since “jsled” commented about nc (thanks jsled), here is the syntax to do the same thing with nc:

echo "stats" | nc localhost 11211

RewriteRule: How to avoid passing query string when you redirect.

Today I ran into an issue which I could not figure out for quite a while. I was trying to redirect a url to another url using RewriteRule. It was supposed to be a pretty straightforward redirect which made it even more annoying than complicated ones. Hopefully somebody is able to explain what I am missing here and if my solution is a good solution or not.

I needed to redirect a url:  http://www.example.com/testpage.php?foo=bar to http://www.example.com/

So I added this to .htaccess file:

RewriteRule ^testpage\.php / [R=301,L]

This did do a 301 redirect as I wanted but query string passed so my redirected url looked like:  http://www.example.com/?foo=bar

Obviously this is not what I wanted so in order for me to fix it, I had to take a rather lame approach.  My new redirect is:

RewriteRule ^testpage\.php /? [R=301,L]

The only difference is the “?” after / for target url.  I am just curious to know why query-string was passed.  I have not used rewrites for long time but I do not remember this behavior.