Email Problems…

Just wanted to let everyone know that I’m pretty much missing every single email from last night to tonight (Friday), gmail must be backed up or something. Usually when things come late, they arrive with a day so if nothing has come through by tomorrow then I will provide another address. I apologize if you’ve been waiting for a reply all day.

I will leave AIM open all night/day for those who need to send a message. AIM user: botskonet

Six Months of Freelance

I’ve been doing various forms of web design and development for ten years, although it was mostly just a hobby or a business on the side. In 2005 I began working hard to set myself up for an eventual transition into doing this full-time. Ironically, I began doing this full-time when I was least expecting to, despite all of my work. It’s been six months since I made the transition, so I figured it would be a good time to share some of the things I’ve learned.

1. Always Follow Up

I always try to keep in constant communication with clients – it helps me keep the project fresh in my mind as well as theirs. Sometimes I follow up and they’re reminded that they still need to do something – like pay. It works well with clients, but even better with leads. When I follow up with leads it has that “reminder” aspect, but it also shows that I provide everyone the same level of consideration and communication.

2. Know Yourself

When I began working at home I would become focused on watching TV, stepping outside, eating, cleaning, going through old magazines, playing games, etc. I’m a person who really needs to separate work and home life, so I moved myself into an office. There is absolutely nothing to do in the office except work. I keep an ever-changing list of tasks for each project on a giant white board, and I really don’t have any standard way to track projects as they’re all so different.

This situation works well for me because I’ve learned that’s what my brain handles best. You may be more efficient and more productive working at home without anything written down. The key is to learn what works best for you and to adapt your life to accommodate those needs. Once you’ve found the best method to make yourself productive, you’ll really start seeing the work get done.

3. Play

You need to force yourself to stop working. Around 11:30 or noon I wrap up whatever I was working on and shut everything down and I play a game or surf the internet. It gets my mind off of work, gives me some time to have fun, and it really helps break up the day. Having something in the middle of the day to look forward to also helps me get to work in the morning.

If I convince myself that I can play for a half hour if I do several hours of work, I’m pretty eager to get started knowing I have a “reward” coming. Even to this day I feel guilty taking time to play because I know how much work there is. Now that it’s my business I’m much more concerned about how much money is coming in, and time is money. You just have to learn that a bit of a break is required.

4. Don’t Assume

I’ve always loved the saying ‘when you assume you make an ass out of ‘u’ and ‘me’”. Never assume that you know what your client wants, because you’ll waste time doing the wrong thing. Never assume that a quick and extremely easy change works fine and doesn’t require testing, because something that’s connected will fail and cause problems. Never assume that you don’t need a file, a document, or an email, because right after you delete it you’ll realize why you need it. This last point is the basis for the final tip…

5. Keep Everything

Keep every email, every attachment, and every document. Keep any password you ever have (securely of course), keep all of the materials sent to you for a project. Keep all of your files, and if possible, keep as many revisions as possible. Keeping this much information is a waste of time if you’re not backing it up.

For example, my data is backed up once a day to two machines – one machine at work and one at home. No matter what I need I have access to it, whether it’s a logo graphic someone sent me six years ago or an ftp username/password for a current client. Keeping everything just saves you a lot of time and energy if anything is lost, in question, or needs fixing.

Plus, it’s embarrassing to go back to a client asking for something a second time.

Anyway, it’s been a great six months! Here’s to another six!

Tech-Tidbit: Altering Primary Keys in MySQL

I’ve come to design every database table with an auto-increment id field that is a primary key. However, sometimes I work on projects where tables have no such column and may have duplicate rows. In order to drop the existing primary key definitions I run:

[mysql]
ALTER TABLE mytable DROP PRIMARY KEY;
[/mysql]

Then, I add a new one:

[mysql]
ALTER TABLE `mytable` ADD `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ;
[/mysql]

Tech-Tidbit: HTML Entity to Decimal Translation

It became necessary this week for me to find a way to convert html entities into their decimal equivalents. I’m not very fond of dealing with character encoding and entity issues but I was finally able to get things working. In the end we modified data within the database which meant I wouldn’t get to use this script, but it was a very nice find.

The nice thing about this is that it leaves any existing decimal-format characters alone, and properly translates html entities to the decimal format.

After searching the net for a while I found a piece of code that seemed like a good solution. The original needed a bit of cleanup and tweaking, but here it is:

function htmlentities2unicodeentities ($input) {
  $htmlEntities = array_values (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES));
  $entitiesDecoded = array_keys  (get_html_translation_table (HTML_ENTITIES, ENT_QUOTES));
  $num = count ($entitiesDecoded);
  for ($u = 0; $u < $num; $u++) {
   $utf8Entities[$u] = '&#'.ord($entitiesDecoded[$u]).';';
  }
  return str_replace ($htmlEntities, $utf8Entities, $input);
}

You can test the translation with this:

$test_strs = array('K&#363;lob', 'K&oacute;pavogur');

foreach($test_strs as $test_str){

  print 'ORIGINAL: ' . $test_str . '<br />'."\n";
  print 'TRANSLATED: ' . entities_to_unicode($test_str) . '<p>'."\n";

}

If you’re interested in converting things the other way around, good luck. I’ve been searching around for a while and I just can’t seem to find anything that works well enough without using some long array to translate things. Let me know if you find one!

Tech-Tidbit: MultipleIE

I’ve been using VMWare so that I can test IE6 as well as IE7 (which is the default on my actual machine). VMWare takes a lot of system resources, and with the laptop I use at the moment, it requires a few items to be closed so that it will work properly. I’ve read about several manual hack-ish methods of getting both versions of IE to work on a single machine but I just didn’t want to bother with all of that.

Enter MultipleIE.

An excellent system that allows me to install multiple versions of IE at the click of a button. I no longer support IE5.5 or it’s predecessors, so I just installed IE6. It works very well! I’ve noticed that it shares it’s location bar history with IE7, but they render things as you would expect each to.

Thanks to one of my development partners for pointing me to that.

The Someday List

Every project spawns new ideas, whether additions or changes, that just aren’t possible with the current (workload, budget, time-frame, all of the above). When a project creates a nice and clean foundation, the possibilities often become infinite. Sometimes they’re just small changes, but most often they’re large changes that seem much more exciting than the current project ever did.

Changes that are large are almost always out of scope, and often become their own project. I always spend some time talking with clients about the ideas that they’ve had, as well as some possibilities that they’re not aware of yet. We begin keeping a list of each idea and as time goes by we re-evaluate the potential benefit and cost values for each idea. Months later when they’ve had time to think about which ideas are worth the investment we proceed with a project that we’re both excited for.

It’s very important to keep a ‘someday’ list no matter who you are – I keep a someday list for my own projects. Some of the ideas are just for fun and wouldn’t be of much use, and some might really increase the usability of an application. As time passes I get an idea of which items on the list I would like the most, and when the time comes, they’re the items I tackle first.

I’ve always focused on creating an application using a very clean and clear framework of code. Other developers, designers, and hopefully even the weekend web warrior should be able to go in and figure out what’s going on. By utilizing a myriad of classes and functions that work well together I allow for an excellent amount of scalability and expandability. This saves time not only in the beginning of a project, but makes future additions easier and cheaper for the client.

It’s also a list that let’s you have fun with projects. If you’re intentionally trying to add items to the list you often think outside the box, which is what it takes to be successful on the web today.

It’s just a place for the “wouldn’t it be cool if…”.

Installing Subversion on CentOS

I’ve been using subversion a lot recently – from using repositories with client development companies to installing it for clients – it seems to be the SVN month.

Anywhere, here’s how I did it. Using CentOS 4.2. For anyone learning or using Subversion I highly recommend that you read the book.

First you need to get the package and install it.

# wget http://subversion.tigris.org/downloads/subversion-1.3.2.tar.gz
# gunzip subversion-1.3.2.tar.gz
# tar -xvf subversion-1.3.2.tar
# cd subversion-1.3.2
# ./configure
# make
# make install

Then you’ll need to setup at least one repository. I’m going to need multiple repositories that I can use for different clients so I have a bit of extra admin work ahead of me. You can setup as many repositories as you need, but no matter what you’ll need at least one. Here create the folders…

# mkdir /svn
# mkdir /svn/repo

Then we need to tell subversion to make our first repository.

# svnadmin create /svn/repo/myproject

For the time being, I’ll use the default svn server called svnserve. You can use apache to get a ton of extra features and better security. Click here for more information on using Apache with subversion. I need do some additional research for my multiple-repository setup before switching to apache though.

First, I need to setup a config file for svnserve.

# vi /svn/repo/myproject/conf/svnserve.conf

Then, look for variations of the following code and edit it as necessary. By default any anonymous user can access the code so to disable that you must include anon-access = none, just commenting the value out will not prevent anonymous access.

anon-access = none
password-db = passwd
realm = My SVN Repository
auth-access = write

The password-db is just a path to a file containing usernames and passwords. This is automatically created by svn inside the repository conf directory. So, save your changes and then we’ll edit said user file.

# vi passwd

Enter in something like:

[users]
username = password

Yes, pretty basic. See what I meant about svnserve and security? The password is in plain text so if someone ever got your system or that file, they’ll have the passwords inside. That’s one more reason to move to apache.

Anyway, you’ll need to start the svn server.

# svnserve -d

One side note – svnserve just runs and doesn’t have a way to stop besides killing the process. If you make changes to the svnserve.conf or user file you’ll need to restart svnserve.

# killall svnserve

Then, go ahead and test (best to do so on a different machine).

# svn co --username=myusername svn://<hostname>/svn/repo/myproject

The system should then ask you for your password and off you go!

Update 6/25/09: Minor clarifications thanks to Andy Hunt.

Tech-Tidbit: MySQL Weighting

I’m still rather disappointed with my options for weighting random results in MySQL, but I’ve done the best I can do with it. It’s more about figuring out what numbers you use for the weighting rather than the calculation itself. The query itself ends with:

[mysql]
ORDER BY RAND() * weight_fieldname
[/mysql]

Now, my possible weights from weight_fieldname are 5, 20, 100. 5 is the default weight for every record – 20 increases the chances of the record a bit and 100 pretty much sets the record as an exclusive result. Now, if you only have a single weight applied then setting it to 0 will reduce the weight of an item, however this is very difficult when you start having multiple weights.

One additional problem is that if you have a serious amount of records, using ORDER BY RAND() is going to be a performance hit.

Tech-Tidbit: Smarty Variables

One of my recent projects was using Smarty – I found myself in a position where I needed to access a variable assigned to a Smarty template directly – I could not access it before/while it was being assigned and Smarty doesn’t provide enough resources to interact with it directly before it’s actually transferred to the template. Smarty does allow you to edit other variables by using the global command in php, but not those that have already been assigned.

What did I end up doing? I just accessed the Smarty template object itself.

$this->_tpl_vars['name_of_template_var_here'];

I had to perform some fairly fancy tests on that data. Then, if you want modify that data you can just save it back to the above variable or re-assign it:

$this->Assign("name_of_template_var_here", $new_value_here);

Tech-Tidbit: Subversion Post-Commit Email

I was setting up an installation of subversion for a client (and I will be for myself soon here – it’s about time to move from CVS) and I needed to enable it to send an email to folks each time a commit was made. This tidbit assumes that you’ve already installed SVN on a linux machine.

First, you need to visit your hooks dir (created when you create a new repository (which is done using svnadmin)).

# cd /path/to/repo/hooks

You need to download a copy of the commit email perl script, which you can get from here.

# wget http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/commit-email.pl.in

Then, rename it to .pl. You’ll need to rename the special file that SVN uses to activate the email. This file is post-commit.tmpl and you’ll need to rename it to post-commit.

# mv commit-email.pl.in commit-email.pl
# cp post-commit.tmpl post-commit

Next you need to edit the post-commit file so that it sends your email out. At the bottom of the file, add the following:

/path/to/repo/hooks/commit-email.pl "$REPOS" "$REV" --from svn@example.com "me@example.com" "you@example.com"

Then just save the file. Now you’re ready to test. You can either make a commit or run the below command. First call the post-commit, then provide the path to a repository to watch, then provide the revision number you want to run a test on. If you’ve just imported code and don’t have any other revisions, just provide the number 1 – but beware the possibility of a really long email.

# ./post-commit /path/to/repo 40

Things should be working fine by this point, but I ran into a problem. I saw the error message Global symbol "@SVN_BINDIR" requires explicit package. In that case, just go into the commit-email and change the @SVN_BINDIR variable on line 46 to the full path of svnlook.