-
Recent Posts
Recent Comments
- petruchek on Confession of the occasional blogger
- petruchek on Confession of the occasional blogger
- Paul Synnott on Google Chrome: Use Space Bar to Confirm Form Resubmission
- Andrew Gunn on Google Chrome: Use Space Bar to Confirm Form Resubmission
- Andrei on Format file size
Archives
Categories
Meta
Monthly Archives: August 2010
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.
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