MySQL Best Practices

MySQL Best Practices

Coding, Guide
Database operations often tend to be the main bottleneck for most web applications today. As programmers need to do our part by structuring tables properly, writing optimized queries and better code. Table Names By convention, the "snake case" in lowercase (no PascalCase - we're not using Microsoft SQL Server here!), plural name of the class will be used as the table name unless another name is explicitly specified. Tables should also be named based on their respective contents. Try to avoid naming tables based on a single use case and think more about how that table will be expanded in the future. If you're not sure how to name the table ask your manager before creating it. eg: To find an order product we would look in the order_products table  Primary Keys The…
Read More
Useful Command Line Scripts

Useful Command Line Scripts

Coding
Below is a list of very common linux commands that any linux person should know by heart. From gzipping files, to running backups this is my personal cheat sheet Compressing Files and Folders Unzip 7z Archive 7za x myfiles.7z gzip File gzip -9 file gzip Folder tar -zcvf archive-name.tar.gz directory-name Uncompress Gzip File gzip -d file.gz Remove Files and Folders Removing a large number of files If you're getting this error: /bin/rm: Argument list too long. Use this command: find . -type f -delete Remove folder from SVN rm -rf `find . -type d -name .svn` Remove ._ files find . -name "._*" -exec rm '{}' \; -print Remove Dreamweaver Notes rm -rf `find . -type d -name _notes` Renaming Multiple Files find . -name "*.jpg" -exec sh -c 'mv…
Read More
Determining Distance With Latitude and Longitude in MySQL

Determining Distance With Latitude and Longitude in MySQL

Coding
When I was programming an application for a marketing company trying to determine where the greatest concentration of registrars where, it made sense to compare the distance from our home base, and with, at the time, release of the Google Maps API, we where able to plot those locations on the map and at the same time sort them by distance (from closest to farthest). System Requirements To get things started, here is what we need: A server with PHP (5 or newer, but not necessary) and MySQL (again newer the better). A zip code database with both latitude and longitude attached to the zip codes Optional: A Google Maps key. We have the server. The zip code database we purchased from http://www.zipcodedownload.com/ with the premium or better having the…
Read More
Installing a Virtual LAMPP Server with VirtualBox and Ubuntu

Installing a Virtual LAMPP Server with VirtualBox and Ubuntu

Guide
Part 1 Install Virtual Box Download it free from virtualbox.org and run through the installer. Part 2 Download the latest Ubuntu software. I like the desktop version as I can do other things besides just run a server. Download the ISO here: http://www.ubuntu.com/getubuntu/download Part 3 Install Ubuntu on VirtualBox Launch VirtualBox and create an new virtual machine. When creating the machine, Virtual box will ask what type. Name your machine: Ubuntu Server Operating System: Linux Version: Ubuntu All the other settings are fine as they are setup by default. Once you are back at the Virtual Box select a machine screen, double click on your new Ubuntu Server. The first run Wizard appears. Follow the questions and when prompted to select the installation media, browse to the newly downloaded ISO you downloaded…
Read More