Programming


Nearly every website these days have columns. Since we have grown out of the old table days and into this new era of CSS we tend to over think certain things like how to create two columns side by side which can vary in height, but still appear to be the same height. The solution is so simple its rediculous. We start out with a left column and a right column(could be three columns.. this will work just as easily, but I’ll keep it simple), two div’s floating side by side via float:right; or float:left;. Next we add a left border to the right column, which is the same width and color as the left:

border-left: solid 150px #aaaaaa;

This will shove your right column out of line, but no worries, step three we slide it right back into place. With a negative left margin on the right column we can literally slide the right column back up under the left column:

margin-left: -150px;

So basically we added two lines of code to the independent columns, now it never matters which one is taller, they fill in for each other. A simple Example.

It almost time.  I will be releasing the next version of jQuery Impromptu soon!  (Probably Sunday or Monday)  Among the next additions will be the following:

  • “Smart” iframe to cover elements that bleed through the fade(ie6, flash, applets)
  • “loadComplete” as a function to execute when the prompt has finished loading(after entrance effects)
  • A few CSS fixes for a few bugs.  This will go into the documentation for the CSS templates
  • Possibly using a form within the prompt to make it more “proper” and submitting easier
  • An option to focus a button by default

Thanks to everyone who has helped out so far on making Impromptu so great!  Please don’t hesitate to suggest something.  Keep in mind though, I want to do my best not to require any extra plugins and to keep everything as backwards compatible as possible so everyone has little trouble upgrading.  I look forward to hearing ideas!

I guess all the big wheels these days are into the new RIA desktop deal with Adobe Air, JavaFX, and Mozilla’s Prism. I definitely see the perspective they’re trying to achieve, but it seems to me none of them are there yet. The concept is to bring the web to the desktop more or less, and all three have a different approach to it. Air is allowing flex or regular html, css, js, where javascript acts more like a server side language. JavaFX is more or less still Java. Prism appears to be just an embedded browser.

My personal opinion Prism has the best chance right now of successfully accomplishing this. However I have to say, if you really want to do any of the things these technologies do you could consider just creating an empty application with an embedded web browser. In the install just give it the url you want to link to. I’ve seen VB does this very nicely and flash is supported. (why shouldn’t it be, its just an IE browser embedded). Flash embedded in HTML is something Prism and Adobe Air have struggled with thus far. I’m not sure about other platforms and languages, but it works nicely on Windows with a very small VB application and install with nothing but an embedded browser.

Moral of the story: Much of the functionality you are trying to achieve with these products can be quickly and easily achieved by other means. Especially if you need to embed flash into html, consider doing this. I’m also interested to know if this will work in any other languages so that it can port nicely to other operating systems(Can Java or C?).

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!

Through the past I’ve never been a big fan of frameworks, but lately I feel I’ve been waisting time programming certain tasks which most frameworks claim to cure.  I’ve looked and played around for a while looking for something to fulfill my need.  Being I’m not very bias towards one language I browsed ColdFusion, PHP, and Python frameworks.

ColdFusion’s frameworks Model Glue and Fusebox(Fusebox is  also  for PHP) seem to be ok but reports show they lack functionality on some  ColdFusion servers.  PHP has the CakePHP framework.  It seems to be one of the better choices out there.  From the Python family there is Django.  From the little research and testing I’ve done this seems to be a great tool.  I do have to say I admire creating a database model and django creates a complete admin interface from that.

What other frameworks are out there that deserve a look? If you were given a job to create a site in any language you choose and any framework, what framework would you choose and why?  Then, to throw a curve ball, qualifying frameworks must be compatible with atleast three of the major databases(MySQL, Postgre, MSSQL, [Oracle, SQLite]?)

Well I gave it a go at the jQuery plugin deal, and well.. I dont think version 0.1 turned out too darn bad.  jQuery Impromptu as I’m calling it is a nice little plugin to simulate a nice css/js alert or prompt You may also add forms custom forms and elements to your prompts as well.   A few of the options allows you to narrow the allert down to an html element on the page(given it is relative or absolutely positioned) and create as many buttons on your prompt as you wish! A callback function lets you process your forms.   Please give it a shot on my examples page and please let me know if you have suggestions or constructive criticism or any other comments.

I’ve spent a little extra time lately playing with Opera.  Turns out its a very underrated browser,.. its got some very nice features.  Developer tools are pretty good(better than IE I must say, although not quite to par with FireBug).  Installing is a piece of cake  by just dragging an icon onto your toolbar from the website!  Some of the other features I’ve found useful is Opera’s built in BitTorent, the mini view(Shift F11) for testing on small screens like phones, “speed dial” on new tabs, IRC, and even the real-time page search to name a few of my favorites(theres a Lot more).   I’ll definitely spend a lot more time  developing in Opera from now on!

I’ve spent a little time off the development path and found a little time todo some reading lately. My good friends over at IsThatWhatYouThink.com They are doing a podcasts on topics such as ColdFusion and video gaming(I of course am loving the ColdFusion chat). As far as other interest reading and debating on various topics I suggest Indirect Jargon. The debates I have found to be rather furious so if you can’t handle that part I would suggest not visiting ;). As for Vista I still have not grown any more fond of it. Ubuntu is slowly winning me over(if they could only improve the resolution prediction I would be completely sold). Which Fiesty is still doing better than Vista.. The score so far(larger score is bad)
Vista: 1 Blue Screen

Ubuntu: .25 screen resolution problems

Finally many of the features we have been working towards made it in the aedCFC. Our long time debated XML config file finally made it in as an option(mainly for backwards compatibility). The biggest downfall to the config before was the function calls with many parameters. I’ve read a few other postings on the great XML config debate and I come to the conclusion that the aed wasnt in the situation where XML would kill it. The XML may slow it down a little,.. but is it enough to really matter?

« Previous Page