wandering php developer with some books about reality ..
Autostart VMWare Workstation machines automatically upon Windows restart v2 – UPDATED
Feb 18th
Browsing the VMWare docs, I’ve been able to find a better way to start VMWare machine automatically via FireDaemon ( Check the first post ).
The new and better way removes the nag screen of “Interactive Services message”, which is pretty anonying, at least to me.
To use the new built-in command-line tool, change the command lines in the Executable and Parameters fields as follows :
Executable : C:\Program files\VMWare\VMWare Workstation\vmrun.exe
Parameters : start "D:\path\to\virtual\machine\Ubuntu.vmx"
You can see that in the following screen :

Note: Change Parameters field to put the correct path to your machine’s VMX file, and perhaps you would need to change the Executable fields as well if you’ve a custom path for your VMWare Workstation installation.
dir2array : Read folder contents recursively in PHP
Nov 22nd
PHP Function to read folder contents recursively into a multidimensional array like a tree.
How to have a FREE Dynamic DNS PRO Solution for your domain
Nov 13th
I’ve always longed to have a subdomain like myhomeserver.gr80.net to point at my home server ( obviously! ) .. but there is always fees for such services, like No-IP and DynDNS Pro ..
I figured out an easy way to have your own sub domain, pointing at your home server ( assuming you have a dynamic IP connection, or you wouldn’t need this tutorial ) ..
Requirements :
1- Free DynDNS Account
2- Domain Name, ( Domain Control Panel must allow you to create sub domains as CNAME entries, which is available on NetFirms )
Steps:
A) Configure your dummy free sub domain:
1- Create a Free account on DynDNS.org
2- After logging in, Choose “Add Host Services” , Add your desired sub domain ( which doesn’t really matter, it’ll be overridden eventually ) , activate the sub domain ..
B) Configure your Domain on Netfirms ( or whatever your registrar is )
1- After Logging to your panel, Choose “Add”
2- Add the desired sub domain ex: myhomeserver.mydomain.com
3- Choose CNAME type, and add your DynDNS Free sub domain .
C) Configure your router \ software to use the created DynDNS
1- You can find a tab in your router setup called ( Dynamic DNS \ DDNS \ DynDNS ) .. where you should enter your account credentials on DynDNS.org ( the account you just created ).
Or if you do not have a DDNS-enabled router, you can always go with software like DirectUpdate , it’s the best one i’ve tried, always fulfilling my needs..
Voila! you now have a fully working FREE Dynamic DNS service on your own domain! Enjoy!
Autostart VMWare Workstation machines automatically upon Windows restart
Sep 7th
Sewing a lot of intranet applications at the NGO, i found it a must to work around electricity blackouts .. and there is a plenty down there ..
So, i managed to get the server starting-up when electricity is back .. using a BIOS setting that lies there in almost all the modern Motherboards nowadays..
But came to the bigger problem, running the machine on windows start ..
This could be easy if you’re the only user of your machine, with no password, having the automatic log-on in effect .. but if you are on a server where you have to enter a password to log-on , this would be kinda clingy ..
Googling alittle, i found a utility which can be used to run windows application as services , and set to start on windows boot rather user log-on .. It’s called FireDaemon [ Download it HERE, or Google it ] ..
I started installing Firedaemon .. opened the GUI afterwords, it looks like this :

Then i began creating a new service, specifying VMWare main executable ( vmware.exe ) as the server application, and ( -x “Drive:\Path\to\VM\machine.vmx” ) as the parameter, as you can see in the picture :

Voila! Close FireDaemon, and restart your computer to make sure everything is OK.
UPDATE on 18/02/2010 : Use the internal built-in tool vmrun.exe to achieve better results, and to remove the nagging screen of Interactive Services message. Check out the updated post.
Center Elements Vertically and Horizontally using Javascript
Sep 6th
Long I’ve searched for a method to center elements vertically using CSS or even deprecated HTML codes.. but never found a proper way to do it ..
Now i figured an incredibly easy way to do it using Javascript, with my beloved jQuery..
You only have to assign one CSS value to the box you want to center:
.centeredBox{ position: absolute }
After including jQuery from Google Code ( or from your own local folder if you like ) :
Use the following function to center the elements:
function setPosition(){
var tasks=$('#tasks');
var h=$(document).height(), th= tasks.height();
tasks.css("top", (h-th>0?((h/2)-(th/2))+'px':0) );
var w=$(document).width(), tw= tasks.width();
tasks.css("left", (w-tw>0?((w/2)-(tw/2))+'px':0) );
};
As a final step, you would need to add the following lines in your js file , so it applies the center hack each time you resize your window :
window.onload=function(){setPosition()};
window.onresize=function(){setPosition()};
And you’re now set to enjoy the final.
Final HTML markup:
Here I am - this is me There's no where else on earth I'd rather be Here I am - it's just me and you And tonight we make our dreams come true
See the demo here : Centered Box
Easily manipulate \ compare different dates in Javascript, PHP-’time()’ friendly!
Aug 23rd
I’m about to finish my redesign of sumaisma website for ramadan theme, got stuck with some gadget where i should put a count down till the time of the next prayer..
I’m used to play and tweak around with php’s time() format, manipulate it just like i need.. i even created “jPrayer” which is a jQuery plugin to display custom alerts on prayer times ( soon out to the market, lol )
But that’s not the same with javascript, haven’t yet played with it’s Date() methods and functions.. so when i got stuck with JS in that issue, i’m was so bored to configure the whole procedure, going back and forth from php’s function to js’ functions .. cuz the original prayer timings is brought from my php’s xml parser ..
Anyway, i googled the issue, and found a great way to manipulate JS’s Date() object just like i do in PHP.. using the great setTime() and getTime() ..
And i got my code much shorter ( 6 lines of code instead of 17 high load calculations ).
Here is how i did it :
// next event time , gotten from php's time() function
// multiplied by 1000 because php's time() uses seconds, where js's setTime and getTime uses milliseconds
prLeft=1251016680*1000;
// initiate a date object 'event'
event= new Date();
// use setTime to put my next event's UTC-formatted timestamp in 'event' object
event.setTime(prLeft);
// initiate another date object 'now' to hold our current time
now= new Date();
// remove the timezone effect
// because this script was meant to have persistent timezone of my client's country
now.setTime(now.getTime() + (now.getTimezoneOffset()*60000) );
// then set timezone setting of qatar +3, by adding 3 hours * 60 min * 60 sec * 1000 milliseconds = 10800000
now.setTime(now.getTime() + (10800000) );
// now we have our two variables ready for manipulation
// same timezone, same format .. time to process some dates lol
// use getTime to calculate difference between the two dates in milliseconds
diff= event.getTime() - now.getTime();
// to save myself a 4 or more lines of math calculations to extract hours and minutes and such
// i initialized a Date() object to store the info then extracted the information i want very easily
diffTime = new Date(diff);
// Voila!
prLeft['hours']=diffTime.getHours();
prLeft['minutes']=diffTime.getMinutes();
prLeft['seconds']=diffTime.getSeconds();
I think there might be better trick for the timezone manipulation .. but it’s not hard like that anyway..
Then i easily made timer to tick every second till it gets to the event’s time .. and it’s working beautifully ATM ..
BTW: Firebug was a great help finishing this script, world is just so dark without it in my foxy installation. LOL
[Islamic] How to pray, by Sheikh Muhammed Hussain Yakoub
Aug 22nd
Sheikh Muhammed explains the correct prayers as learned from our prophet ( peace be upon him ). Excellent to learn on the first days of ramadan so we can all pray the right way.
May allah accept our prayers.
Download Link ( 138 MB ) | Play
*UPDATE : Link to download the session was updated, link is provided by IslamWay.com.
