Local Dev on Mac with MAMP

If you are doing lots of local PHP development and you hate moving stuff back and forth from your htdocs/ folder (where your default web root is located), then you should set your Mac to use virtual hosts. For example, let’s say you have a site called “sitename.com”. You could set it up so “local.sitename.com” would bring up your local development site through your web browser. Below are the necessary steps to accomplish this feat. Note: you should have admin access to edit your hosts file. First, make sure that your MAMP environment is using port 80 by click “Preferences…” in your MAMP panel and clicking the “Ports” tab. Click “OK”. Then, Edit your hosts file by typing the following command in your Terminal application. It should prompt you to enter the admin password. You should see the following contents. And you should add your own “127.0.0.1” line with your desired name, i.e. sitename.com (Highlighted in white) and save the file. Next, navigate to “Applications > MAMP > apache” and open the “httpd.conf” file in a text editor app like TextEdit. And find the text in the file denoted by “# Virtual Hosts” (Noted as line 524 in the image). Uncomment the next line by removing the hash (#) character (Denoted in yellow in the image). Afterwards, open up another file located in “Applications > MAMP > apache > extra” and open “httpd-vhosts.conf”. Add lines similiar to lines 45-48 in the image below. Then you should modify the contents in yellow to your desired values. Restart MAMP by clicking “Stop Servers” then “Start Servers”. Finally, open your browser and...

Gzip Your CSS and JavaScript

When I finished implementing my site, I decided to check it’s YSlow grade. And lo and behold, it got a “C”. So, as I was knocking each markdown off my report card list, I came across an item “Compress components with gzip”. I’ve read about it and kinda understand it, but i had never actually performed this type of compression. Since I’m on a Mac, I decided to locally compress my files thru the Terminal app. The process I used can be found here. I went with his Option 1 (Compress locally and upload).  The command I used in Terminal is the following (where yourcssfile is the name of your css file. Ha!): gzip -c --best yourcssfile.css > yourcssfile.css.gz After gzipping the css file, I then did the same thing with my JavaScript files. Then, I uploaded these two new gzipped versions of my files to my webhost and changed my references in my HTML files. I modified my .htaccess file again based on the link above and used the following: <files *.js.gz> AddType "text/javascript" .gz AddEncoding gzip .gz </files> <files *.css.gz> AddType "text/css" .gz AddEncoding gzip .gz </files> RewriteEngine on #Check to see if browser can accept gzip files. ReWriteCond %{HTTP:accept-encoding} gzip RewriteCond %{HTTP_USER_AGENT} !Safari #make sure there's no trailing .gz on the url ReWriteCond %{REQUEST_FILENAME} !^.+\.gz$ #check to see if a .gz version of the file exists. RewriteCond %{REQUEST_FILENAME}.gz -f #All conditions met so add .gz to URL filename (invisibly) RewriteRule ^(.+) $1.gz [QSA,L] I refreshed and my page came up quicker and my YSlow score improved. Yay! Success! Update: The above worked in all browsers except...

Using wget on Lion

wget does not exist in Leopard, you should use “curl” set up an alias for wget to curl -O which does exactly the same thing: echo 'alias wget="curl -O"' >> ~/.bash_profile Note: if the command doesn’t work after creating the alias, it’s probably the .bash_profile loaded in your current terminal session didn’t make the alias effective. So, just create a new Terminal window and the alias should be there....

Preventing Pinterest Pins

If you are a site owner and have your own copyrighted images embedded throughout your site, and you do not want anyone to pin your image(s) onto their interest board directly, then you can add the following meta tag to your HTML code in the header. <meta name=”pinterest” content=”nopin” /> Note: Users can still get around this by downloading your image(s) and pinning the images directly thru...

Photoshop CS5 Scan Issues

After upgrading my Mac OS to Lion, I realized I just shot myself in the foot when I tried to open Photoshop CS2… and it failed to open. I had tried to figure a way to get my CS2 working on Lion, but finally I just gave in and decided to upgrade to CS5. Once I upgraded and Photoshop was working again, I wanted to scan something in. But when I went to Import from my scanner, the option to Import wasn’t listed in the menu. I couldn’t believe it! I figured I just needed to update my drivers for my Canon MP470 and it would return. But after upgrading the software, it still didn’t show up. Soon, I saw a reference in a forum posting mentioning that Photoshop may be running in x64-bit mode. To make Photoshop run in 32-bit mode: Highlight the application in Finder (located in your Applications/ folder) Get Info (Command-I) Check the box “Open in 32-bit mode” Then re-start Photoshop. That did the trick for me… Now, back in...

To Print a Secure PDF

Download Gimp or another GNU PDF viewer-type of application. Open the PDF document. (I usually like to import as layers) Then Print. (You have to hide each layer to display the next so you can print each...