The !ncredible Blog

Adding Public Key Authentication to your Server

One thing that I think most of us neglect to do is to setup Public Key Authentication for our servers.  I’m not going to go into the details of why this is a good idea.  The topic has been covered quite well else where. Suffice it to say it’s better security. What I want to do today is simply go through the steps to gett it done. I’m assuming that you are on a system like Linux or Mac OS that has OpenSSH already installed and that you’re comfortable with the command line.  I’m also going to assume that you have a .ssh directory in your home directory. And with that, let’s begin!

Step 1: Set up your Keys

First of all you’ll need to generate a set of public and private keys.  Open a command line and type:

ssh-keygen

And follow the on screen prompts.  Pretty strait forward stuff.

Step 2: Copy them to your Server

Now you’ll use the following command to copy you’re public key to the remote server:

ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host

Conclusion

That’s it! If you’re on a mac1, you’ll find that it doesn’t have the ssh-copy-id command. In that case, check out this post to get it. Good luck!  Questions? Drop a comment!

  1. If you’re on a Windows machine… well, I left that world a long, long time ago. Does Putty have this functionality?

PHP can’t access MySQL after upgrade to Mac OS 10.6.6?

If you find that php can’t access MySQL on your local dev environment after upgrading to Mac OS 10.6.6. It’s because it’s looking for the socket file in /var/mysql/mysql.sock, except that it’s not there.  It’s in /temp/mysql.sock.

I resolved the issue by using the following commands:

$ sudo mkdir /var/mysql
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

You may have already done this, as the move to /tmp/mysql.sock was actually done in a previous version, but apparently the 10.6.6 upgrade removes the link.

Important or just Urgent

I hate being behind the power curve.  I find that whenever I get behind and feel like I’ve got to “catch up” it is too easy to “forget” to plan, to make a blue print.  It seems like these things will take “too long” and that I should “just get on with it”, since I’m already “out of time”.

Unfortunately, it’s a lie.  With out a real plan, I find I manage by “stream of consciousness”.  What ever intrudes itself upon my awareness get’s at least some of my attention.  I may still be “efficient”.  I may get a great many things done, temporarily making me feel as though I’m making progress towards getting ahead again.  However when I step back and look at what’s really been accomplished I frequently find that an inordinate amount of that efficiently performed work was urgent, but not truly important.

Conversely, I have found that whether I’m behind or ahead if I take time to plan out what is important I tend to get those things done, even when the urgencies of life and business attempt to intrude themselves upon my awareness. Do they intrude? Of course they do.  The difference is that because I have a blueprint prepared I can evaluate the urgencies intruding themselves and make an informed decision on whether or not to allow them a portion of my limited time and attention resources.

So, plan your weeks, plan your days, plan your life.  Even if there is so much to do that you feel there isn’t time to breath, make time to plan.

TextMate and the missing update

TextMate.  Image obtained from VersionTracker.com

I am frequently amazed at my own human inconsistancy.  For example, as a confirmed technologist (read geek) I find that I hunger, thirst and, yes, lust after the latest and greatest thing.  What ever that is.  I’ve got to have the latest version of it.

Yet in spite of this need I still use TextMate as my work horse text editor.  at least a quarter to half of my day is spent in there. Yet TextMate is NOT, by ANY means THE LATEST AND GREATEST anything.  I mean, I think Noah died the day after celebrating the release of the last major release1. Just some how it’s still the best in town.

I know that BBedit has it’s HUGE proponents (many of whom are among the developers I respect the most).  Coda, Espresso and many others too.  I’ve tried TONS of editors (I refer back to my technologistness), but I always come back to TextMate.  In fact It’s what brought me over the line from a strait Linux man to tread the path to full out Macophilia.  Continued…

Activating Multi-Site functionality in WordPress 3.0

One of the most anticipated new developments of WordPress 3.0 is the unified WordPress and WordPress Multi-Site (formerly MU) codebase.  Because the final implementation seems to lean more in the direction of the original MU codebase, some have described the end result as being able to use single user WordPress MU.  In spite of this, there is no readily apparent way to actually activate and use the Multi-Site functionality.  With that in mind, I decided to provide a quick rundown of how to get WordPress Multi-Site going.

  1. Deactivate all of your plugins
  2. Add this line to your wp-config.php file: define('WP_ALLOW_MULTISITE', true);. I put it just above the line that says: /* That's all, stop editing! Happy blogging. */
  3. In wp-admin, go to Tools->Network
  4. Most likely the default settings will be acceptable, but if not change them to suite your needs, then click “Install”
  5. Follow the instructions on the next page
  6. Once done, you will have to log in again and you’ll be good to go!

At this point there are plenty of things to do and decide. A new section will be added to your wp-admin navigation bar, “Super Admin” as well as a new sub-section under the dashboard section, “My Sites”. You will want to have a look at those areas and tweak the various settings to get your network set up exactly how you want/need it. Good luck with your new blog network!

Loading a non-standard version of jQuery in WordPress

Have you ever needed to load a version of jQuery in WordPress other than the one that comes standard?  I have.  It’s got to be a fairly common need as I frequently see Themes and Plugins that try to do this by including their own version after WordPress loads the standard one. They either set the priority of their add_action to a higher one, or they symply add a script tag to include it just after the call to wp_head().

Just one problem: it won’t work.  Sure it will load the new version, overwriting the old one as it does.  However, in the process there is a brief period where there is no jQuery. Kind of like the changing of the guard.  During that gap any JavaScripts that need jQuery’s functionality are going to throw errors.  It get’s even more fun if multiple plugins/themes are trying to do it at the same time. Luckaly, there is a better way!

Enter wp_deregister_script. It “deregisters” the “handle” WordPress associates with a particular script so that you can “re-register” that handle with wp_enqueue_script. So, to change what get’s loaded when WordPress loads “jquery”, you would do something like this:

function replace_jquery() {
wp_deregister_script('jquery');
wp_enqueue_script("jquery", "path/to/jquery/",array(), 1.4.2);
}
add_action("init", "replace_jquery");

You could even use the ajax.googleapis.com link for your favorite jQuery version for the “path”. Simple as that! WordPress loads your version instead of it’s default. No conflicts or gaps in coverage.

Warning: date() [function.date] error after upgrading to php 5.3.0

If you’re getting an error similar to the above after upgrading to php 5.3.0, pop open your php.ini file (perhaps in ‘/etc/php.ini’, or ‘/usr/local/php5/lib/php.ini’. Then uncomment the “date.timezone” line, and change it to date.timezone = “American/Denver” CORRECTION: should be:

date.timezone = American/Denver.

Note the lack of quotation marks. See this website for a complete list of time zone options.

Giving CodeIgniter A Second Shot

As any one who has worked with or for me , I’m a Ruby on Rails and CakePHP guy.  I’ve used both for years and I’m very comfortable with them.  I tried CodeIgniter briefly about 3 years ago and didn’t like it at all.  At the time I felt that it wasn’t as polished or as complete as CakePHP as a frame work, and didn’t pursue it further.  Before any one decides to flame me, read on :D

A recent professional development caused me to give CodeIgniter a second glance and I think I’m beginning to see what I missed the first time around.  As I began to go through the documentation and play around with the code I realized that because I had already been very deeply involved in RoR and CakePHP their paradigms had colored my vision.  Both have a very ridged, “My way or the High way” feel.  People tend to phrase it something like, “convention over configuration”. I felt comfortable with that.  It meant a lot of things I just plain and simple didn’t have to worry about!

CodeIgniter doesn’t do that.  The first time I tried CodeIgniter I felt this was indicative of incompleteness or lack of power.  Wow, what a mistake!  It is true that CodeIgnitor does not FORCE you to do things in one particular way.  It’s also true that it will allow you to do things just about any way you want.  ANY WAY YOU WANT.  That’s pretty cool.  If you want to do strict mvc (like RoR or CakePHP) you can.  Or you could drop the model entirely if you wanted. No sweat.  As I really looked at what that meant it hit me suddenly.  That’s freedom!  That’s flexibility.  And it comes at a very small cost in terms of aditional configuration (read nearly non existant.).  Some things (like setting up a form to insert data) are a tad more complicated, but nothing to speak of.  And you gain so much!

And when I say “so much” I’m looking beyond just flexibility and freedom.  The way CodeIgniter handles loading things like helpers, models and views allows you to load as much or as little as you need very, very easily.  Beyond the flexibility that opens up some serious performance gains, since it’s as easy to load as not to load, so you might as well leave it out till you need it!

One final point worth mentioning is documentation.  While both RoR and Cake have made serious gains in documentation and both have a really strong community surrounding them, I can’t stand the official documentation.  CodeIgniter has AMAZING docs that are both thorough and easy to read.  It’s been a while since I experienced that!

Now, I’m just getting my feet wet, and I’m by no means saying I’m ditching my old friends RoR and Cake, but I have some revelatory experiences with CodeIgniter. You can bet I’ll be throwing it at a couple of projects in the near future.

VZW to extend 4G Network to Rural America?

Check this out: Verizon promises 4G wireless for rural America.  Talk about interesting!  It appears that Verizon is planning to use a frequency normally used for things like TV transmissions to enable them to use fewer towers to broadcast their service.  That means that they can actually extend coverage into the boondocks and still be profitable.  No small feat!

If this works, and this could be a real boon not only to those living in broadband chalenged areas, but also to you’re typical business traveler.  Or any one who regularly has issues getting coverage on their mobile broadband devices.  Here’s why:  lower frequencies.  That’s right, lower frequencies.  Since the frequency they are planning to use has a lower frequency, it can not only cover longer distances, but it can also pass through obsticles (like buildings, mountains, etc) with greater ease then the current frequencies used by cell phone carriers.  This means that the issues I raised in my last post about vzw and the lack of wi-fi on their phones could potentially be greatly eased or even eliminated.

We’ll have to wait and see of course.  Theoretically they are going to start in 2010 with major population centers, then push out to less populated ones, so it could be several years before people way out there see a difference, but it will be interesting to see the effect the lower frequency has on city dwellers.

One click Git install for Tiger

If any one out there is having trouble installing Git on Mac OS 10.4 (Tiger), I feel your pain!  I recently reformated my hard drive and started reinstalling everything and found that Git wold not install on Tiger.  I tried compiling from source and just was not getting anywhere.  I even tried using the Leopard Git installer (I know, I know, but still…), to no avail.

Just when I was about to give up and go back to svn, I discovered that some saint had made a Tiger Git Installer!  Just down load and run it and your are all set.  Just the way a Mac App should work.

By the way, if you haven’t already, you’ll have to add “/usr/local/bin” to your $PATH variable to make it work.  That’s not too hard, of course.  If you use bash (as most Mac OS users do) open terminal, and enter:

vi ~/.bash_login

Hit the “i” key on your keyboard to enter editing mode, then, at the very end, add:

export PATH="/usr/local/bin:$PATH"

Then save and exit (i.e. hit “esc”, then type “:qw” without the quotes). Finaly, in terminal do this:

. ~/.bash_login

That’s it!  You should now be able to type git --version in terminal and have it spit some thing like git version 1.5.3.1. Happy Source Controlling!