Google your name. Right now. I’ll wait.
Good. What came up?
Look at the first page of results and ask yourself these questions about each one:
You need to be able to say “yes” to all of these for at least the top two or three results. (As I write this, the RSSmeme page repeating my Google Reader shared items has crawled above my blog, and I’m upset about it.)
I’m lucky. My last name is very rare, so even if you Google just “Socol” I come in second—only to my father, and ahead of Wikipedia. You may not be so lucky, saddled with a name like Jones or Smith or, even worse, you might have the same name as a celebrity. You may have an uphill battle.
People with common names need to get creative. It can be as simple as adding an initial—my friend became Alec R. Johnston to distinguish himself. Something a little more creative—Lisa Bettany named her blog Mostly Lisa. Or you can geek out, like Ben Lew, who uses the name n0s0ap. (Those are zeros.)
Ben uses the name n0s0ap on del.icio.us, flickr, Last.fm, Digg, Twitter, etc. Lisa uses a combination of “MostlyLisa” and “LisaBettany.” I use a combination of an old name, “UrbaneExistance” (I know it’s spelled wrong) and “JamesSocol” for all new registrations.
But all of us, Alec, Ben, Lisa, and I, make sure our real names are linked to our identities. It’s no Clark Kent: n0s0ap is Ben Lew, with the glasses on or off.
Do you own your own domain name? Why not? Go buy it. Now. Go!
I have this conversation with friends all the time. Would you want someone signing your name on paper documents? Of course not, so why would you let them do the same thing online? I own jamessocol.com, jamessocol.net, and jamessocol.org, just so no one else does. Even if you do nothing but have it redirect to your social network of choice, you should own your name.
If your name is taken, reread the last section and get creative.
Now, about those social networks. You don’t need to be on every one, but get on a few, build a profile, and put your name on it. You can create and control your own Facebook and MySpace pages without knowing a single HTML tag. Once you’ve got a name, whether it’s your real name or something else, use it. last.fm/user/you. twitter.com/you.
The best way I’ve found to control what the web knows about you is to start your own propaganda campaign. Put your name on a lot of things, preferably with links back to your own site.
An easy way to start is by commenting. Blog comments help the most, since you spread that influence around the whole internet, but within MySpace or Facebook posting real, meaningful, interesting comments on profiles and walls will make sure people think of you when they hear your name.
If you have the time, try blogging. There are a lot of blogs with great advice, but you can always just “write what you know.” Once you find your voice, the writing flows.
What else? It depends what you like. If you take pictures, get a Flickr stream. Last.fm is a great way to share and find music you like. GoodReads is a similar site for books. Twitter is great for finding people with similar interests and building connections. LinkedIn is a professional social network, particularly good for people in marketing or new media. Blogger, while not the best blogging platform, has some good community features. There is a lot out there.
Don’t let someone else be you! Own your own identity and be proud of it. It will help you build authority and when a potential employer or client googles you, they’ll get a good idea about you from the first page of results.
What else, 2.0-savvy readers? What did I forget?
I wanted to put something specific in the title, like “Speed up your service” or “Reduce server load” or “Limit database calls” or… You see why I chose “Better Living.”
Memcached is a memory caching system with an obvious name. It allows you to store basically any data that can be serialized into a giant, memory-resident hash, then retrieve it with its unique key.
Imagine not querying your database on every request, and you only begin to get a sense of how useful this is.
Let’s go through a simple, single-server setup. Read the rest of this article »
Upgrading PHP on RHEL 5 is difficult. Having done it on several servers, I’ve gotten it down to a 15 to 20 step process. It takes a while, but it’s straightforward. I thought I’d share, because help was sparse and noncontiguous at best.
![]()
RedHat Enterprise Linux 5 comes with PHP 5.1.6 and, as of this writing, this is the highest version available on yum. If you want to upgrade to 5.2.4, or even recompile 5.1.6 with a custom configuration, you’ll need to resolve several dependencies, first.
Unless otherwise specified, whenever I run ./configure, I always include --enable-shared and --enable-static.
The first step is to make sure you have a working APXS script installed. None of the servers on which I’ve done this had it. I installed Apache 2.2.4 over the default install, since it was the latest version. Be sure to enable APXS with --enable-so. Be careful configuring Apache, as it likes to install itself in /usr/local/apache2/ instead of /etc/httpd/, which you may prefer.
Now we start resolving the dependencies. I’d start with libtool and libiconv. The former you should be able to install via yum. The latter you may have to download, and after you configure it, from the source directory copy m4/iconv.m4 to /usr/local/share/aclocal/iconv.m4.
Use yum to make sure mysql-devel is installed, you’ll need it to link to mysql.
Then I’d do the image manipulation software, since it’s fairly easy. Use yum to install libjpeg, libpng and freetype. You can then use yum to make sure both gd and gd-devel are installed.
I installed libmcrypt, libmhash, and ming at this point. I’d say it’s a good time to get any of these more particular dependencies out of the way. I also installed Tidy, which you need to check out from their CVS repository. You can run build/gnuauto/setup.sh from the Tidy source directory to create the autoconf files.
Now we get to the crux of the matter: configuring PHP. All the major dependencies should have been taken care of. If you have other PHP options you’ll need, make sure those prerequisites are installed, as well. Run the configure script in the PHP source directory with everything you need enabled. I find it helpful to create a script like php.config with the following format:
'./configure' \ '--with-cgi' \ '--with-fastcgi' \ '--with-gd' \ ... '--with-xml' \ "$@"
You need to include the slashes \ at the end of every line. The last line, "$@" makes the script output the output of configure.
If you get an error running make, you may need to edit your Makefile. Find the EXTRA_LIBS section (in vi/vim, type <ctrl-c> /EXTRA_LIBS <return>) and add -liconv to the end of the line. Then try make clean && make and it should work.
You may or may not have to edit your httpd.conf, after running make install from the PHP source directory, to add the AddType or AddHandler directive for PHP.
That should be it. You can install extensions via PECL or Pear and everything should run. Save the source directory and your php.config (or config.nice) file, and you’ll be able to recompile at any time, in case you forgot something. (I, for example, forgot to add --with-mysql the first time!)
Let me know if you run into other problems. Most can be solved by typing yum install ###-devel to resolve a dependency, but if not, I’ve done this enough to be of some help.
I often find it difficult to find tips and advice for doing relatively simple things in things like MySQL, Ruby, Python, etc. So, starting with this post, I will help fill that niche. Today’s topic is Using Subqueries to Simplify your SQL Queries.
For this article, I’m using PHP and MySQL for examples. There are slightly different implementations of SQL in the various database engines, but this is one thing they all have in common.
SQL is called “structured query language” because it allows subqueries to make complex queries easier and faster. The idea of a subquery is simple: have the database perform one query and insert it into another.
There are dozens of useful ways of using subqueries, but I will concentrate on two: subqueries in the select expression and subqueries in the where clause.
In most web programming languages, the interface between the script and the database only allows one query per access for security reasons: an injection attack could input something like '; DELETE * FROM users; and do some serious damage to a website. Imagine your SQL query to login looked something like:
SELECT * FROM users WHERE user_name = '$username' AND password = '$password';
If you are not checking and cleaning the input appropriately, someone could type the snippet above into your login form and, if multiple queries were allowed, MySQL would execute the following:
SELECT * FROM users WHERE user_name = ''; DELETE * FROM users; AND password='';
Since the empty string wouldn’t match any rows (hopefully), the first query would be discarded. The second query, the DELETE statement, would run, terminating at the second semicolon. Since the third piece of code is nonsense, MySQL would throw it out with an error.
To solve this problem, languages like PHP cause MySQL to issue an error any time there is more text (except comments) after the line terminator, usually the semicolon. The downside is that situations arise where you need to run multiple queries. The result is either often either a godawfully complicated statement with multiple JOINs, or running several queries, each of which requires communication with your database server and can slow down your applications.
In the examples below, I’ll pretend we’re building a forum that has four tables:
users with primary key user_idforums, a list of all the boards, with primary key forum_idthreads which links each thread to a forum with forum_id and has primary key thread_idposts which links each post to a thread with thread_id and has primary key post_idOne way to speed up your queries again is to use subqueries. Subqueries are full SQL queries nested within another query. For example:
SELECT (SELECT * FROM t1);
Obviously it’s a pretty simple example. Notice the parentheses. Subqueries must always be in parentheses, even if they are inside a function, like:
SELECT MAX((SELECT salary FROM employees));
Let’s get to work on our forum. Say that while reading all the threads of a forum you’d like to have both the number of threads and the number of posts in the forum. One way is to run two separate queries:
SELECT COUNT(*) AS threads FROM threads WHERE forum_id='1';
SELECT COUNT(*) AS posts FROM posts LEFT JOIN threads USING(thread_id) WHERE forum_id='1';
That might not be so bad if your SQL server is localhost, but more and more hosts are running dedicated SQL servers, meaning that every query has to run across the internet, be processed, and run back, slowing down your application. But we can run this in one query with two subqueries:
SELECT
(SELECT COUNT(*) FROM threads WHERE forum_id='1') AS threads,
(SELECT COUNT(*) FROM posts LEFT JOIN threads USING(thread_id) WHERE forum_id='1') AS posts;
We can add the above to our query to get the name of the forum and its description, so we can further decrease the number of trips to the database:
SELECT
(SELECT COUNT(*) FROM threads WHERE threads.forum_id=forums.forum_id) AS threads,
(SELECT COUNT(*) FROM posts LEFT JOIN threads USING(thread_id) WHERE threads.forum_id=forums.forum_id) AS posts,
forum_name,
forum_description
FROM forums WHERE forum_id='1';
Notice that we also changed the WHERE clauses to match whatever forum ID we put into the “outer query“.
Another simple and useful way to use a subquery is in a WHERE clause. Here you must be careful to match the WHERE syntax and the type of data returned by the subquery. For example, in WHERE user_name = (...), the subquery ((...)) must return a single value, while in WHERE post_date IN (...), the subquery can return a list.
In our forum, we might want to search for all posts by a specific user, but we don’t want our visitors to need to know the user ID—or perhaps we want a more descriptive URL, like search.php?user=USER_NAME instead of search.php?user=#ID#. But in our forum, to be efficient, we link posts to their author by the user_id column.
One way to do this is to run a query to find the ID then run another query to find the posts. Another way in this particular case is to use a JOIN statement. But yet another way is to do this:
SELECT * FROM posts WHERE user_id = (SELECT user_id FROM users WHERE user_name = 'foo');
In the case above, a JOIN would also get us the information we want, but in some cases this isn’t true, for example:
SELECT column1 FROM t1
WHERE column1 = (SELECT MAX(column2) FROM t2);
When you need to COUNT or otherwise aggregate one column, you’ll need to use a subquery instead of a JOIN, as well.
This article only scratched the surface of subqueries. Subqueries can be nested, they can appear in other places and do other things, and they can make your SQL more readable, among others. I don’t claim that the SQL statements above are the world’s most efficient or best way to do things—if you know a better way, let me know! I just want to give an introduction to subqueries, a very basic part of SQL that few people I’ve met seem to understand.
Images, flash, frames. These are the “traditional” methods for making a web site “more interesting” or “better looking.” But these hold-overs from the AOL era are the bane of bandwidth, text-only browsers, and non-visual users.
HTML, of course, was originally written to define the structure of a web page, never it’s design. In essence, HTML was intended to be much like XML today. But, when HTML was created, there were no style-sheets, so HTML was forced to include some design information, like <font> tags and the bgcolor attribute. Developers quickly turned to images, JavaScript, frames, and Flash to make their lives easier, but in the process made everyone else’s life harder.
Images and Flash will both suck bandwidth, so why would you use them to display text or a navigation bar? Save images and Flash for what they’re supposed to be: pictures and animations. Frames reek havoc on text-only browsers and screen-readers (hence the rarely-used <noframes> tag) and have been considered blase web-design for years.
So how can you save bandwidth, insure accessibility, and still get all the effects you want? CSS. Let’s go over a few of the quick-and-easy ways to use CSS to replace the bandwidth-heavy, inaccessible design you’re using now:
1) Frames: Fixed Sidebars
Perhaps the most common use of frames was the sidebar, a window on the left (or right) that contained anything from helpful information to your site’s navigation, appeared on every page, and didn’t scroll with the rest of the site.
If you want to do the same thing, use the CSS “position: fixed” definition. For instance:
#sidebar {
position: fixed;
top: 0;
left: 0;
width: 160px;
height: 100%;
background: #00f;
}
This will make a non-scrolling, 160-pixel wide sidebar on the left of the screen. (You could always use “right” and “bottom,” too.) Now, in your HTML file, create a <div> with the id=”sidebar” attribute:
<div id="sidebar"> ...all your links go here... </div>
You can put this anywhere in the HTML source, and it will appear in the correct place. In a good screen-reader, if you put this toward the bottom of the HTML source (for instance, after all the content of the page) then the user would hear the content before having to hear the list of links again.
2) Images: Positioning Text
This is really just poor web-design. Unless it’s desperately important that you use a particular, rare font, you should never use images to display text. If it’s important that the text appear a certain way or in a certain position, make use of the box-model and nested <div>s. For example, let’s say you wanted a 480-pixel wide layout, regardless of the users’ screen resolution, with a right gutter and a title and slogan in the top-left. You might do something like:
#main {
width: 480px;
height: 100%;
margin: 0 auto;
padding: 0;
position: relative;
top:0;
left:0;
}
#gutter {
width: 120px;
height: 100%;
margin: 0;
padding: 0;
border-left: 1px solid #000;
position: absolute;
top: 0;
right: 0;
background: #2c2;
color: #fff;
}
#header {
width: 360px;
margin: 0;
padding: 6px;
position: relative;
top: 0;
left: 0;
font-family: Tahoma, Arial, san-serif;
font-size: 140%;
text-align: center;
}
With the corresponding HTML:
<div id="main"> <div id="gutter"> ...gutter code here... </div> <div id="header"> <p>Page Title</p> <p>Page Slogan</p> </div> </div>
Which gives something like (borders added to show box model):

Now, of course, with just a little editing of the CSS file (and none of the HTML) you can move the gutter, change the background, change the page width, change the font, and it’s all in text-format, that will display correctly to text-only or visually-impaired browsers, and save huge percentages of bandwidth.
3) Flash: Cool Navigation Bars
This gets a little more complicated. In general, it’s hard to define the box around <a> tags, so you’ll probably want to do something like this:
#nav
{ margin: 4px auto 0 auto;
position: relative;
top: 0;
left: 0;
}
#nav ul
{ display: inline;
list-style-type: none;
}
#nav li
{ display: inline;
border: 1px solid #000;
padding: 2px 4px 0 4px;
margin: auto 4px 0 4px;
}
#nav li.here
{ border-bottom: 1px solid #FFF;
}
#nav li:HOVER
{ border-bottom: 1px solid #FFF;
font-weight: bold;
}
Now in each <li> tag you’ll make a link to the page you want. This particular set of code gives you a horizontal list. I use a version of this on my projects page, so you can see it in action. If you remove the display: inline parts, you’ll get the vertical list you need for a column. Of course, the margin, padding, and all the colors can be customized however you want, to make it look right. (I got this from the AListApart article “Taming Lists“, which you should read for more information.)
So there you go…
It’s not all the info you’ll ever need, but it solves three of the most heinous wastes of bandwidth I’ve seen on the web, as well as all the problems people have with accessibility. These methods can both look great, and be completely usable by everyone, something Flash, frames, and images can’t.
Follow Me