October 2007


Well, just as everyone else has done, I have upgraded to Ubuntu 6.10 64 bit, Gutsy Gibbon. Boy oh Boy was it a great move! The graphics are wonderful, pidgin is groovy, and adding and removing Firefox plugins are a piece of cake. I couldn’t ask for an easier Ubuntu.. or could I? While I have to say Ubuntu keeps getting better and better every time, certain proprietary software still lacks for linux, more so for 64 bit linux. Sure most application can be installed by using the 32bit libraries and forcing the architecture, but isn’t that sort of uncalled for? And it completely defeats the purpose of Add/Remove Programs when I have to do such hacks to install things.

Be aware before you install the 64bit version that you will not be able to install Flash, Opera, Wine, Komodo Edit, or any of the new cool Adobe Air products. Boy this is got me where it hurts being a web developer. Now none the less, most of these can be installed by following the tutorials for installing on a 64bit machine, but what I would really love to see in future versions is by default, Ubuntu have the capability of installing and running 32 and 64 bit versions of software. Now I’ve got no clue how one would begin creating such a work of art, but Apple did it, and I have full faith in the Ubuntu community.

Would I trade the Ubuntu experience? No. In fact I went out and purchased a new machine just for Ubuntu and I am still loving every minute of it. My only regret is not installing the 32bit for my everyday usage. I can’t wait to see the power and versatility of the 64bit Ubuntu in a few more releases, but I need the 32bit linux desktop right now.

Many of the questions for Impromptu are concerning how exactly to use Impromptu as a confirm to remove an element from a list(database or just the dom). Its actually pretty easy, and so I whipped up an example of removing users from a database. Each user has a userid which I pass to the php file, the php file passes back true/false if it was successful. Then we remove the user from the html dom or either throw an error message. The examples can be found here, just view the source for the code:

Delete users from a list

http://www.trentrichardson.com/Impromptu/demos/demo1.html

Edit users from a list

http://www.trentrichardson.com/Impromptu/demos/demo2.html

So I stumbled into a problem where I didn’t want to actually use server side code to actually write javascript. I have an accordian menu, and according to which subpage I am on I want to show that part of the accordian menu automatically on page load. My task became to retrieve just the name of the file name. This isn’t a solution for clean url’s, as that could get a good bit more tricky( http://www.abc.com/first/second/third/forth/, which one is the actual file???). Luckily for me I’m upgrading some slightly older code and mine uses regular old url’s.

Basically the easiest solution I came up with is to use a regular expression to pull out all occurances of a /file.ext and then return the first occurance. So my solution looked like this:

function getFileName(path){

var fn = path.match(/\/([a-z0-9_-]+\.\w+)/i);
return (fn == null)? “” : fn[1];

}

Pretty simple solution right? Where path is the full url, we perform a match to get all matches. If it found no matches we return “”. This means the file may not be within the url in the case that it is index.html or home.html, etc where it is the default. Hope this helps someone!

Just this past week I stumbled upon a new problem. I have a website which will be soon changing domain names. The hosting will stay the same, only switching domain names. One of the first problems I want to watch out for is page rank on various search engines and do a 301 redirect. Secondly, I want to make sure if anyone has a page on this site bookmarked, it still works properly while redirecting to the new domain. Finally I want minimal downtime during this transfer. My question to myself was how do I do this, and the answer was quite simple since I was using Apache and mod_rewrite. So to get started I gathered the possible domain names I’m dealing with:

  • www.olddomain.com
  • olddomain.com
  • www.newdomain.com
  • newdomain.com

Ok, so you are saying this is pretty obvious, but I want to keep this in mind while creating my mod_rewrite. The current set up has both domains pointing to the same directory on the server, so they currently work, but we want to get completely away from that olddomain.com, but until then we want to keep it up. Our solution lies within an .htaccess file within the root of our directory. We simply want to process a redirect from anything access on olddomain.com(or www.olddomain.com) to www.newdomain.com. To keep it simple I simply redirect to www.newdomain.com, in my opinion it just feels more proper. So this massive rewrite looks as follows:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com [NC]
RewriteRule (.*) http://www.newdomain.com$1 [R=301,L]

The RewriteCond uses a regular expression to distinguish which domain is initially being used. ^ means we start our matching from the beginning of the string. (www\.)? means their may or may not be a “www.” at the beginning (? means may or may not exist). Finally we just state our domain name and stating [NC] for not case sensitive.

Considering this Rewrite Condition is met we apply the RewriteRule. If not escaped with a “\”, the “.” is a wildcard, and “*” means 0 or more; so .* implies 0 or more characters. Now the tricky part is to pay close attention to all sets of parenthesis in that regular expression, and the $1 in our redirect url. Each set of parentasis create a “capture”, which can be accessed by a $. That being said if I had three sets of parentasis the first captured element could be accessed by $1, the second capture by $2, etc. This is how we capture any url from the old domain and append it to our new domain. Hope this helps someone else out, or if you have any other possibilities don’t be shy, please share!

Does anyone out there think they have a cool Impromptu design?  I’ll be the first to admit the design in the doc’s isn’t exactly eye-catching.  That being said I would like to make an Impromptu Design Repository.  Within there we could share images of other’s Impromptus or even CSS.  If you have a design you would like to share let me know, reply on this post with your CSS, a link to your image, or send me an email with your image.  Also if you are requiring other plugins to achieve your look, please include information on the plugin’s name/location(or if you had to do any other js to make it work).  Don’t forget to include a link to your site or name if you want to be referenced!
It should be exciting to see what others have come up with!