Category Archives: Uncategorized

Get number of days in month with PHP

Problem: get number of days in certain month with PHP, if $m – is a month and $y – is an year. First solution, hacker-style (source): (31 - (($m - 1) % 7 % 2) - ((($m == 2) << !!($y % 4)))) ?> This solution doesn’t work properly for years divisible by 100, and non-divisible by … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

Test before you send

This summer was really hot for my hosting provider. Here is summary of emails I’ve received from them: Jun 11: On June 27, 2010, between 06:00am and 10:00am CST, our Development and Database teams will be performing several upgrades of … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

What is mod_rewrite

I love these mod_rewrite epigraphs: The great thing about mod_rewrite is it gives you all the configurability and flexibility of Sendmail. The downside to mod_rewrite is that it gives you all the configurability and flexibility of Sendmail. Despite the tons … Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

Invalid markup

Valid markups are all alike; every invalid markup is invalid in its own way. (Leo Tolstoy, Anna Karenina) Speaking about impossibility to repair invalid markup automatically for any given markup.

Posted in Uncategorized | Tagged | Leave a comment

Format file size

Code snippet to output number of bytes with unknown capacity: function format_filesize($bytes)  {     if ($bytes == 0)         return ’0.00 B’;     $s = array(‘B’, ’Kb’, ’MB’, ’GB’, ’TB’, ’PB’);     $e = floor(log($bytes)/log(1024));     return sprintf(‘%.2f ’.$s[$e], ($bytes/pow(1024, floor($e)))); } I don’t know the author of this code.

Posted in Uncategorized | Tagged , , , | 1 Comment

Curl — change your IP address

If you have multiple IP addresses and you want to make curl request using non-default IP, you can do it by setting CURLOPT_INTERFACE option: curl_setopt ($ch, CURLOPT_INTERFACE, ’11.22.33.44′); This will work only if you really have that another IP. If you do … Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

Slow FTP Login

Angry users sent me a link to discussion of what can cause Proftpd delay during authorization. So I’ve decided to fix it. Added UseReverseDNS off to config file — didn’t help. Added GoogleDNS (8.8.8.8) to resolv.conf — didn’t help. Added … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

Easter Egg from Last.fm

What a lovely easter egg from Last.fm developers in their robots.txt file: Disallow: /harming/humans Disallow: /ignoring/human/orders Disallow: /harm/to/self Hint.

Posted in Uncategorized | Tagged , , | Leave a comment

OK, let’s try

It looks like I was able to make WordPress work from single installation on two different domains in different languages without touching its core files. I do not want to touch its core files because I want to be able to upgrade … Continue reading

Posted in Uncategorized | Tagged , | Leave a comment