Web Development Posts

To move the contents of a directory to a parent directory, first navigate to the child directory and then run the command snippet below.

For example, the parent directory is called "mum" and the child directory is called "baby", navigate to "baby" and run the command. Everything will be moved to the "mum" directory.

This should also work in Linux without any problems.

See FreeBSD move contents of directory to parent directory Snippet

Setting the display property to inline is an alternative to setting the float property to left.

See Horizontal list using display inline Snippet

Using float left is a popular way to make a list horizontal. It tends to have less problems then the alternative, which is using display: inline.

See Horizontal list using float Snippet

This snippet will add jQuery that is hosted by Google.

See Google hosted jQuery Snippet

This snippet will get the filename from the url. The filename is the last part of the URL from the last trailing slash. For example, if the URL is http://www.example.com/dir/file.html then
file.html is the file name.

See Get filename from URL using Javascript Snippet

Chrome Experiments is a website which show cases Javascript experiences from a range of different developers. Many are cutting edge, some are just plain cool and a bundle of fun. They certainly show what can be achieved with the wonders of Javascript. Chrome Experiments is a Google website and anyone can submit an experiment.

Get Cool Javascript Tricks at Chrome Experiments Link

It even has a watermark is an online gallery of interesting business cards. If you are stuck for inspiration for your next business card, check it out. If you have an amazing business card yourself, you can submit it to inspire others.

Get Business card inspiration Link

Smashing Magazine's excellent competition for creating a resume (CV) for a fictional web designer. The result is a collection of beautifully presented CV's. Great inspiration for the next time you need to update your CV!

Get Create a webdesign CV Link

It is a good idea to block access to .svn directories if you are using Subversion. Otherwise, anyone can read the files. Add the following snippet to your .htaccess file (in root directory of the website).

See Block access to .svn directories using htaccess Snippet

Example usage - if a field is a varchar and you need to sort by a number. It will sort it alpabetically, instead of numerically. Type casting will convert it to an altenative data type.

See MySQL Type Casting Snippet

Here is an example of how to select some data from a table on one database and insert into a table of a different database. I assumes that you are using the same mysql connection.

The MySQL USE command is used to select the appropriate database at the appropriate time. database1 is where the data is being selected from and database2 is where it is inserted to.

See Select from a database and insert into a different database Snippet

Simple command to gzip a file.

See GZip a file Snippet

Backup a database from cron. Add the following to the cron tab.

See Backup MySQL Database from Cron Snippet

Basic while loop. It selects everything from a table called "table1" and then loops through each row. On each iteration, you can do something with the value for a specficied field. In this case, we echo out the values of the id and "anotherfield" fields.

See PHP While Loop Snippet

This is for the basic snippet to connect to a MySQL database.

See MySQL connect to database Snippet

Add new user to MySQL database. First, log into the MySQL console, and then run the following command, replacing databasename, username and password.

See Add new user to MySQL database Snippet

Simple command to backup a MySQL database. Run from Linux command line.

See MySQL Dump (backup) Snippet

This is the command to restore a MySQL database.

To restore it on a local computer, follow this process:
1) Open the command line (Windows, Linux or Mac)
2) cd (change directory) to the directory where the mysql.exe is located. This is likely to be in a bin directory. For example, with WAMPserver, mysql.exe is located here:
c:\wamp\bin\mysql\mysql5.0.45\bin

See Restore local MySQL database Snippet

WAMP and Skype Conflict

Blog Post

I have just discovered a conflict between Skype and WampServer that I thought I would share. They both use port 80 which causes the conflict. If you run Skype before running Wamp, then Apache will not run. If you go to a site on localhost, you will probably get a blank screen.

Read WAMP and Skype Conflict