On a message forum I regularily visit a member was having issues with code being placed in multiple files that he wanted to remove or change without having to edit each and every file manually. For this I created a search and replace function which will recursively search the directory and every file Continue reading
Category Archives: Notes
GoDaddy mod_rewrite Hell
Whilst trying to install a piece of software on a GoDaddy hosted account I noticed that mod_rewrite variables were simply not being passed to the correct pages. When digging a bit deeper I found that it was effectively ignoring extensions in URLs and just displaying the file with the extension. i.e. instead of having to enter: Continue reading
Case of the missing/hidden IE8 Developer Tools window
Whilst working on a current project I was trying to get cross-browser compatability working nicely. However when I came to load up IE’s Developer Tools I found it was loading up the window but nothing was there! I’m running Windows 7 and this seems to be the only Continue reading
[PHP] Get current time in milliseconds
I recently needed to get the current time in milliseconds, of course this can easily be retrieved using microtime() however I needed the entire number in digits, not in decimals with seconds seperately etc. Heres how:
1 2 3 | $timeparts = explode(" ",microtime()); $currenttime = bcadd(($timeparts[0]*1000),bcmul($timeparts[1],1000)); echo $currenttime; |
NOTE: PHP5 is required for this function due to the improvements with microtime() and the bc math module is also required (as we’re dealing with large numbers, you can check if you have the module in phpinfo).
Bash, Bad Interpreter
I recently came across:
/bin/bash^M: bad interpreter: No such file or directory
When trying to run a bash script that someone else had edited. This most commonly happens on UNIX systems if the file has been edited on MS-DOS or Mac. The cure for this is to run a simple perl script:
1 2 | #!/usr/bin/perl -pi s/\n/\r\n/; |
Save as unix2dos.pl, chmod +x unix2dos.pl and then run like:
./unix2dos.pl filetoconvert.txt
Simples!