Good Music: The Who - Who’s Next
Here is today's album, Who's Next by The Who. For those of you that have never heard of it before, it's pretty good. This is another album where you'll recognize a number of songs that are in current use as theme songs for popular television shows, commercials, et cetera.
The Who - Who's Next |
|
Good Music: The Beach Boys - Pet Sounds
This is the first post I'm going to do that is music based. It's of an album most people know, but many, especially the newest generations, may not know as a whole. I'm talking about The Beach Boys, and their breakthrough album Pet Sounds. Using GrooveShark, I'm able to post up streaming files of all the songs from the album. So rather than read about, take a listed yourself and see if you like it:
The Beach Boys - Pet Sounds |
|
Firefox vs. IE - I Propose a Fight to the Death!
If you're a web developer like me, you know how annoying it is to make websites look and function the same in different browsers. Often, I spend as much time trying to make a chunk of JavaScript or CSS work the same on the two browsers as I do writing the code itself. It's absolutely ridiculous. And don't even get me started on freaking Safari, I have no idea what those folks are thinking.
So here is what I propose: John Lilly, CEO of Mozilla Corporation, in a cage fight to the death with Steve Ballmer, CEO of Microsoft.
The winner gets the right to choose exactly, to the pixel how CSS will be rendered, and JavaScript implemented.
I personally think Balmer will win. He looks like a tough old sonofabitch.
Free website thumbnail generator - abilitron
This is a website thumbnail. I was interested in the process, so I decided to make a website thumbnail generator of my own. So I spent yesterday afternoon doing just that. I call it Abilitron.
Visit abilitron to generate your own free website thumbnails.
MySQL PHP Geolocation - Zip codes: latitude, longitude, distance
This is one of my first really complex SQL query entries. The premise goes like this: you have a user database with a bunch of people who signed up for your service, which includes the user's zip code. Now you want to write a query so you can show user A all the other users in your database that are within, say, 10 miles of her zip code.
It's called Geolocation.
In order to do this, you need two things: 1. a database of all US zip codes, and their corresponding semi-exact latitudes/longitudes; 2. someone like me to teach you spherical geometry.
Lucky for you, you've come here, because not only do I have a nice 7-zipped archive of a US zip codes to latitude / longitude database for you to download, this also happens to be my website, so I can teach you geometry as well!
Now here's a little PHP/SQL for the actual mathematical processing (nearly all done in the database!):
-
-
// connect to the database
-
-
// we need the userid of the person who is doing the searching:
-
$userid = 1;
-
// and the max distance (in miles) you want to show results from:
-
$max_distance = 10; // in this case, 10 miles
-
-
// now we go out to the database and get that user's latitude and longitude based on the user's zipcode
-
$user_query = mysql_query("SELECT z.latitude, z.longitude FROM users u, zipcodes z WHERE u.id='$userid' AND u.zipcode=z.zipcode");
-
$latitude = $user_data['latitude'];
-
$longitude = $user_data['longitude'];
-
// then we use that latitude and longitude to write our complex SQL query:
-
$complex_query = mysql_query("SELECT u.id, truncate((degrees(acos(sin(radians(z.latitude)) * sin(radians(".$latitude.")) + cos(radians(z.latitude)) * cos(radians(".$latitude.")) * cos(radians(z.longitude - ".$longitude.")))) * 69.09),1) as distance FROM users u, zipcodes z WHERE u.id != '$userid' HAVING distance < $max_distance");
-
$i = 0;
-
// this is a nice array of userids that are within 10 miles:
-
$found_user_ids[$i] = $row['id'];
-
$i++;
-
}
-
} else {
-
// no results!
-
}
-
} else {
-
// that user's zipcode is not in the database
-
echo 'Sorry, that zipcode is not found in the database!';
-
}
-
There is one little chunk in the $complex_query that was new to me the first time I used this code, and that was the HAVING portion. In the past, I've always tried to use a WHERE statement to limit results based on a calculated column (in this case, the distance column that is the result of the complicated mathematical formula) but I would get an error since the WHERE portion of a SQL statement is actually required to gather the SELECT data, so data from the SELECT cannot be used to limit itself (take a breath and think about it, it does make sense). Enter HAVING.

I know I told you I'd teach you geometry, but I don't actually completely understand what the math above does on a figure-to-figure basis. I do know that is calculates the mean distances between every user in the database. And I know it does so taking the curvature of the Earth into consideration. Think of it like this: if you go near the North Pole, you can walk over every line of longitude (the vertical lines on the globe) in a few seconds by simply walking all the way around the North Pole. But as you get closer to the equator, the distance becomes greater between lines of longitude. So you need SINs and COSINs and Radians and stuff.
At the top, the lines are close together. In the middle, they are further apart. You can I are somewhere in the middle, unless you live in the tropics, or you're Santa Claus, which would be cool, I mean, how many websites does Santa actually visit?
Gmail Notifier
Like many people, I use Gmail as my primary email program. It follows me wherever I go so I don't have to worry about keeping the email on my computer at my office and the computer at my house syncronized. I have several POP3 accounts that I also have linked to my Gmail account, which allows me to receive the mail from each address, and also send mail as each of those addresses as well.
I can check my email easily wherever I can find an Internet connection, which has come in handy more than once. But one thing that has always bothered me a little was the fact that I had to remember to continually browse to Gmail to see if I had received any email.
But then my pal Jason told me about this:
http://mail.google.com/support/bin/answer.py?hl=en&answer=9429
It's called the Gmail Notifier. It's a small program that installs a small icon in the status bar locally on your workstation. When you get a new email message, it pops up a notification along with a snippet. And the best part is that it allows you to use Gmail as your "default mail program" so when you click on a "mailto:" link to send an email, it will automatically open a browser and load Gmail.
Ultimate GoDaddy Promo Code
Good for $7.50 .com's and .net's (and for renewals!)
Enter the promo code:
gdbb776
at checkout.
Disable SELINUX in Red Hat ES 5 (CentOS 5)
To check and see if SELINUX (secure linux) is installed and running on your Red Hat ES 5 (CentOS 5, etc) server, use a text editor to open /etc/selinux/config:
vi /etc/selinux/config
Inside you should see a line that says
SELINUX=*some value*
Where *some value* is either enforcing, permissive or disabled. To shut SELINUX off, set the variable to disabled. To receive a set of errors to see what services would be affected if SELINUX was running, set it to perimissive. If you are sure all your services, daemons and everything else is set up with correct SELINUX permissions, you can set it to enforcing.
If you're getting an error after compiling and installing an Oracle OCI8 module for PHP you might want to set SELINUX to permissive or disabled until you are able to resolve the permission problem.
If you have to change the setting you should reboot the server to make sure the change takes effect system wide.
Sync Server Folders Using rsync in Red Hat Enterprise 5
WARNING!!!
The instructions I'm giving below will open the receiving server to access from literally any source available on it's network to write any files to the particular folders you allow access to. THESE INSTRUCTIONS SHOULD ONLY BE USED ON SERVERS THAT ARE COMMUNICATING ON A SECURE LOCAL AREA NETWORK BEHIND A STRONG FIREWALL, NOT DIRECTLY OVER THE INTERNET! AGAIN, THESE INSTRUCTIONS SHOULD NOT BE USED ON A SERVER THAT IS CONNECTED DIRECTLY TO THE INTERNET! If you want to use these instruction to sync web servers, by all means do, it's what I use them for, just make sure your firewall only allows external (Internet) communication over ports 80 and 443 (if you need https) and specifically not TCP 873, since that is the port used by
rsync. If you're running production-grade servers you should be using a strong NAT firewall anyway. If you aren't, I am available at a very decent rate to help secure your setup![]()
If you're like me and you work for a rather large website, at some point you're probably going to have to come up with a nifty way of syncronizing two or more servers in some sort of pool, whether it be for load balancing or some other high availability technique, or simply to keep an active archive on a backup server. The great part about using rsync is that even if you have a huge amount of data in the folder you want to syncronize, rsync is smart and knows only to sync that information which is new, so it can run often and quickly, and literally be able to keep a server syncronized to within about a minute using a cron script. This is not a perfect solution for all situations, but it works well in the situation I use it in, which is archiving flat content from a live, online server to an offline backup machine.
Required Packages:
- rsync
If you need help installing a package, please read how to install packages using YUM.
Required Hardware:
- at least two servers
Log in to each of the servers as root and install rsync. We have to set up one machine to run rsync in daemon mode (as a service) so it can listen for requests from the other machine. Once rsync is installed on both servers, decide which you want the server daemon running on, switch into the /etc/ directory and create a file called rsyncd.conf:
cd /etc/
vi rsyncd.conf
Inside the file enter the following information. The settings below are for a standard installation of Red Hat ES 5 (CentOS 5, etc) running Apache 2 for syncing the default web root directory (/var/www/html/). You can change the path to suit your own needs.
[sync_web]
uid = apache
gid = apache
comment = Sync path for web servers
path = /var/www/
read only = false
Then add an entry at the end of the /etc/bashrc file to initialize rsync in daemon mode when the machine boots:
cd /etc/
vi bashrc
And add this line at the end of the file:
rsync --daemon
To initialize the syncronization, from the non-daemon machine run the command:
rsync -a /var/www/html *rsync_server*::sync_web
where *rsync_server* is the IP or hostname of the machine you just set rsync up on as a daemon. I suggest creating a shell script called by /etc/crontab every few minutes to run that command, that way the servers will stay syncronized by themselves to within minutes.
Set The Runlevel of a Service (Daemon) from the Command Line in Red Hat ES 5
To set the runlevel of a daemon (service) on the command line in Red Hat ES 5 (or CentOS 5, etc) you can use a simple command called chkconfig
To set a daemon to start on runlevels 2-5, which would be a "normal" start, you would use a command like this:
chkconfig --level 2345 *daemonname* on
And replace *daemonname* with the name of the daemon you want to have start, like httpd (Apache) or sendmail or any other daemon.