How to enable some web developer tools for safari mac

If your like me and sometimes need to debug js in different browsers for web development. Sometimes its helpful to use debugging tools available with different browsers. Mozilla has the really useful firebug tool, which I use all the time and which is easily installed via mozillas browser plug in environment.

Safari on the other hand is a little trickier, I stumbled accross this today which certainly helped me.

Open up a terminal window on your mac and run this command

defaults write com.apple.Safari IncludeDebugMenu 1

Quit Safari and reopen, you should now see a ‘Develop’ tab along the top of your mac toolbar (where preferences is).

You can use this to do all sorts of useful profiling of your scripts on safari, which I have found most useful.
Enjoy.

Game Design With Flash (Cs4)

I have started learning the basics of game design using adobes cool flash cs4 suite. Actionscript seems to basically be php objects with a little syntax variation, so the programming side seems easy enough for me since I program with php objects often. Wondered if anyone could point me in the direction of any good forums / tutorials that flash developers get together en mass to help each other out with development problems?

Also maybe if anyone had any hints or tips then you could also put them as a comment for me to check out under here.

How to add a new vhost with mamp on mac osx

Adding a new vhost is something I have to do on a regular basis when working on new projects locally.
Its a fairly straight forward task as well.

Download and install:- MAMP

Once you have done this navigate either with a finder window or via terminal to /Applications/MAMP/htdocs/

Once here create a folder again either with finder or terminal e.g mkdir myfirstsite

cd myfirstsite – to enter that folder and create another folder: mkdir http

Lets also add a test landing page so add a file called index.html into your http directory either in finder window or just by the following command in terminal.

Cd /Applications/MAMP/htdocs/myfirstsite/http/
vim index.html
hit ‘i’ to insert
type “Hello this is my first site”
hit escape-key + type ‘:wq’

Now we want to do 2 things, firstly add the virtual host to the httpd.conf file:

Navigate to: cd /Applications/MAMP/conf/apache/httpd.conf

Once here either open the text file in a text editor or simply enter it with: vim httpd.conf in terminal if your familiar with this method.

Scroll the very bottom and add the following:


DocumentRoot /Applications/MAMP/htdocs/myfirstsite/http
ServerName myfirstsite

Then secondly you need to add the site to the your local OS X machines host file with the following command via terminal window only.

printf “127.0.0.1tmyfirstsiten” | sudo tee -a /etc/hosts

After that restart MAMP by ‘stop servers’ and then start servers option.

Then open up your browser pop into the address bar:- http://myfirstsite:8888/ and with any luck you’ll be on your way.

Compound interest php function

Something that will crop up at some point in your programming lifespan is a little bit of compound interest.

Well its very easy to work it out. The below example does so over a 7 day period at 1.8% interest per day.


function compound($amount,$time,$rate){
for($i=0;$i<$time;$i++){
$amount = $amount + round($amount*$rate);
}
return $amount;
}
$compound = compound(1000000,7,0.018);
echo number_format($compound);

Facebook Style Alternating Page Title – With jQuery / Javascript

This afternoon i’ve been trying to work out how facebook detects whether or not your focused on its interface or not. Ie focused on the browser tab.
Triggering a $(window).focus(function(){}); event in jquery will in most browsers solve coming back to the browser tab if your away from it, but in respect of how it detects on success of an ajax call whether or not to change the page title based upon if you are focused on the tab or not is still a mystery to me.

Can anyone shed any light on this?

I am now beginning to think, facebook uses a sly dog in the mix in which it detects if you have a mouse move over the body of the page, and when you do initiating all required requests.