Nov 9 2010

Required Reading for Creating and Deploying a WCF REST Service on IIS7

Deploying a REST service with Windows Communication Foundation (WCF) is great, because it’s very powerful, but it can also be enormously frustrating.

First of all, start by reading the whitepaper.

This will give you a great overview on how to construct your methods, and how to label them in order to have them exposed correctly by REST.

Next, you need to create your web.config file. Use webhttpbinding for REST.

Lastly, deployment:

How to use https for WCF services in IIS7

How to rewrite your URLs to get rid of the lame .svc extension

I am posting a small demo project, hopefully it’s useful to someone. Simply implement the API interface as you see fit, and the rest basically does itself. You’ll notice the web.config includes a SOAP binding for legacy Microsoft clients to use if they wish.

Link: API_Template

Mar 24 2010

New Favourite Terminal Command

Best command ever:

sudo !!

Tells the terminal to run the last command again, but to throw sudo in front of it.

obligatory XKCD link:

Jan 20 2010

mysql command doesn’t work in OS X snow leopard

So you install mySql on your mac, and it’s working great, but then you go into terminal to run a mysqldump or something, and it doesn’t work!

you get a message something like:

-bash: mysqldump: command not found

so how do you fix this? well, copy and paste the following into your terminal window and press enter:

echo export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH" >> ~/.profile

source ~/.profile

whoa, whoa, you say. what is this doing? It makes it so that when you type any command into the terminal, it does a check of these folders before giving you the “command not found” error.

If you want to undo it, you can always edit your .profile, or just delete it.

Jan 12 2010

WordPress on Snow Leopard: Unable to Connect to Database

If an “unable to connect to database” comes up while installing WordPress on a Snow Leopard machine, try adding :3306 to the end of the DB_HOST in wp-config.php

Assuming everything else works, this should solve your problem!

Aug 13 2009

VirtualHostX and mod_rewrite

To enable mod_rewrite manually, see: OS X server tips but if you are using VirtualHostX it changes your default config file. Add the following code to the Directives box:

Options FollowSymLinks
AllowOverride All AuthConfig
Order deny,allow
Deny from all

if you’re using the new version of VirtualHostX, make sure that you select Directory from the dropdown, then use:

Options FollowSymLinks
AllowOverride All AuthConfig

Mar 16 2009

How to do multiple virtual hosts on OS X

  1. Download and install VirtualHostX (don’t forget to back up your existing config!!)
  2. Download and install Gas Mask (manages multiple hosts files, dumb name though)
  3. If you want to do this with WordPress and you have a database locally and another one on a dev server somewhere, you can do the following code:

if(eregi(“^$”, $_SERVER[HTTP_HOST]))


define(‘DB_NAME’, ‘dbremotename’);

/** MySQL database username */

define(‘DB_USER’, ‘dbremoteuser’);

/** MySQL database password */

define(‘DB_PASSWORD’, ‘dbremotepassword’);

/** MySQL hostname */

define(‘DB_HOST’, ‘dbremotehost’);

define(‘WP_SITEURL’, ‘’);

define(‘WP_HOME’, ‘’);



define(‘DB_NAME’, ‘dbremotename’);

/** MySQL database username */

define(‘DB_USER’, ‘dblocaluser’);

/** MySQL database password */

define(‘DB_PASSWORD’, ‘dblocalpassword’);

/** MySQL hostname */

define(‘DB_HOST’, ‘dblocalhost’);

define(‘WP_SITEURL’, ‘’);

define(‘WP_HOME’, ‘’);


Mar 16 2009

HTML Special Characters

Any good web designer knows certain characters have to be encoded in HTML.

Here’s a list of pretty much every character and it’s encoding:

Bonus: Need to use some encoded characters in your PHP script? Use html_entity_decode() to turn them into regular text.

Mar 16 2009

OS X Server Tips

To enable PHP:

  • nano /etc/apache2/httpd.conf
  • uncomment LoadModule php5_module…

To enable mod_rewrite

  • In the primary site configuration, change AllowOverride to AllowOverride All AuthConfig
  • Restart apache with sudo apachectl restart

Feb 24 2009

Recursive FTP

Fun thing I found today: how to copy a whole pile of files/folders over from one place to another using ftp. Especially useful on two remote computers in terminal when security isn’t a concern!
wget -r ftp://username: password@domainname