Ryan Kanno: The diary of an Enginerd in Hawaii

Everything you’ve ever thought, but never had the balls to say.

Archive for the ‘Work’ Category

OSCON: Day 3, 4, and 5!

I’m sorry.

I know I’m late with my updates, but I’m currently enrolled in the final project based MBA class at the University of Hawaii and it’s been kicking my @$$. In any case, enough excuses… here’s the quick rundown of the presentations I attended on Day 3, 4, and 5 at OSCON. Btw, all the presentation files can be found online! (Don’t you love open source). Not to mention, I’ve tried to scour the web for reviews notes for each session and linked them appropriately.

Day 3

Session 1: Subversion: Powerful New Toys with Director for The Apache Software Foundation, Justin Erenkrantz

Since we’ve implemented Subversion at work, I wanted to be forward thinking and check out all the new features and the direction of the project. It’s nice to know they’re looking at Mercurial’s revlog.

Session 2: Who Gets to Decide What Open Source Means? with a really powerful panel of people. :)

With a panel of supastahs, I wanted to hear the debate about all the confusion surrounding the word “free” software and what exactly constitutes open source. Pretty interesting to see what all the fuss is about especially once the software crosses over into the Enterprise.

Session 3: PHP: Bigger and Faster with Rasmus Lerdorf, creator of PHP.

It’s funny; I ate lunch with Rasmus and I didn’t even know it. Really interesting talk about PHP. I’m not a hugeeee PHP fan but still interesting nonetheless. First introduction to YSlow for Firebug.

Session 4: Using Trac Efficiently: Work Smarter, Not Harder with Vivek Khera

Since I just installed a VMWare image of a Trac install on Windows, I wanted to see what the community buzz was all about. The talk was really, really crowded; not to mention I heard numerous speakers over the course of the conference pimp out Trac. People mentioned having trouble installing Trac on Windows, but I followed the wiki instructions and it was fine - not sure what all the fuss is about. I’ll have to get back to the office and figure out how to setup the authentication and hooks into our repository so we can actually use the installation I configured at work.

Session 5: High Performance Web Pages with Chief Performance Yahoo!, Steve Souders

Steve introduced an internal Yahoo! tool, YSlow, that hooked into the lovely Firebug to grade the performance of a website. After having played with it for a few days, I’m loving it. Nothing like instant gratification in the form of a score. And if you develop ANYTHING on the web and you’re not using Firebug, it’s best advised that you do. :)

Day 4

Session 1: Why Observability Matters - How DTrace Helped Twitter with Adam Leventhal and Brandon Gregg.

After reading about all the scaling troubles of Twitter, I really wanted to see what tools helped determine the root cause of the problem. Sun’s DTrace is a fascinating real time, trace tool that can help debug and trace pretty much any issue that you’d encounter. Though I can’t use it at work, I still love to see the low level tools that are being developed. If you’re lost, don’t worry I was too, read more about DTrace at Wikipedia.

Session 2: Using and Writing Rails Plugins with Eric Pugh

Since I’ve slowly been delving in the Rails world, I wanted to see what the plugin system was all about. The session was pretty informative, even recommending sites that give statistics on the most frequently used plugins. (Don’t worry, I still love my Django).

Session 3: Python 3000 with Guido van Rossum

Hearing the God of Python speak about its future is pretty fascinating. I find it interesting that Py3K will break compatibility with Python 2.X. If you don’t know what that means, basically - you have to upgrade all your Python scripts to 2.6, then a source-code conversion tool will be used to convert your source files in Python 2.6 to Py3K. Scary but rest assured that these guys are super smart. To read more about Py3K, you can check out the PEP for it.

Session 4: Advanced Spring Framework with CEO of Interface21, Rod Johnson

I’ve heard Rod speak a number of times at JavaOne and since I’ve converted all my projects to use Spring in some fashion or another, I always like to see what’s going on in the community. Btw, if you’re not using a dependency injection framework, you really, really, really need to look into them. :)

Day 5

Session 1: Subversion Worst Practices with Google employees, Brian Fitzpatrickand Ben Collins-Sussman.

Since Harper and Scoot are friends of Brian’s in Chitown and we use Subversion at work, I wanted to see what the core development team thought about the worst practices. This was by far the funniest of all the sessions I attended, and it was SRO only. To read about notes from last year’s session named “Subversion Best Practices”, check them out here. Or… even better, check out Fitz’s blog about this year’s presentation.

Whew. All in all, a very awesome conference. Hopefully, I can convince management that this is the future. // KANNO

Tagged: , , , , .


OSCON: Day 2

Morning Tutorial

Technical Management of Software Development with Uber Technical Lead @ Google, Alex Martelli

Mr. Martelli covered a gauntlet of topics pertaining to technical management including empowering your team, optimal team size, time management skills, and test-driven development. Even though his tutorial regurgitated a lot of the obvious, it’s nice to hear it being preached by important people at large corporations. What I found most useful in Mr. Martelli’s presentation was his extensive list of suggested reading material about management. I’ll post them when I get a chance to go over his slides. :)

Overall grade: A-

Afternoon Tutorial

Introduction to Rails with Glenn Vanderburg

Unlike the Ruby presentation from a day ago, the Introduction to Rails was everything I hoped the Ruby talk was going to be (and more). Even though Mr. Vanderburg only had three or so hours, he did a great job of covering quite a bit of material. Topics he covered included the model, the controller, filters, flash, caching, layouts, views, the various helpers, form handling, migration, routing, and testing (*whew*). Though he didn’t get into great detail on each subject, I felt that he covered enough to pique my interest. I actually went back to the hotel itching to code a Rails app.

Overall grade: A

Stay tuned for more updates from OSCON 2007!

Tagged: , , , , , , .


OSCON: Day 1

Morning Tutorial

Learning Ruby with Mike Fitzgerald

Even though Mike is a renowned author in the technical community, I was not at all impressed with his presentation. Don’t get me wrong - the presentation went exactly as how it was described in the program guide. My issue was the fact that the tutorial seemed overly simplified considering the background of the typical conference attendee. I really was hoping to learn something I couldn’t find in one of his books.

Overall grade: C

Afternoon Tutorial

Django Master Class with Simon Willison, Jacob Kaplan-Moss, and Jeremy Dunck

Working on a personal project (soon to be released in the wild) in Django, I had looked forward to this tutorial for several months. I had really high expectations for this tutorial - and the Django team did not disappoint. Some of the topics they covered included signals, template tag patterns, OpenID integration, and scalability. Though I’ve done work on all of the above, it was still interesting actually matching faces to names. Not to mention, many of the attendees scored a free Django shirt and a few buttons.

Overall grade: A

Stay tuned for more updates from OSCON 2007!

Tagged: , , , , , , .


Yahoo! UI Grids - footerStickAlt (w/ jQuery goodness)

My co-worker, Stephen, and I have implemented our layouts using the Yahoo! UI Grids library. One of the dilemmas we’ve been facing is the inability to use Cameron Adams’ footerStickAlt CSS solution @ The Man In Blue.

Basically, footerStickAlt is best described as

sites that require the Web page footer to be positioned either at the bottom of the browser window or at the bottom of the Web page – whichever is visually lowest.

Fast forward to the present, and using JQuery, JQuery Dimensions plugin, and a little nifty Javascript, we wrote up a solution at work for our Yahoo! layouts. One thing to remember is that this solution won’t work in browsers with Javascript disabled, i.e. it degrades to whatever Yahoo! grid layout you’re using.

It’s been tested in IE 5.5+ and Firefox 2. (I think =P).

*Note*: In this implementation, I don’t check for the margin on the ‘body’ element since we’ve set all our margins and padding on to 0. See the demos for details.

Requirements

  1. Yahoo! UI Grids [download]
  2. JQuery 1.1.2+ [uncompressed] [compressed]
  3. Dimensions plugin 1.0.0-b2 [zip]
  4. The Javascript below in a file of your choosing! Don’t forget to include it in your page!
$(document).ready(function() {
     if ($(window).height() > $(document).height()) {
          $('#bd').css({
               height: $('#bd').height() +
                         ($(window).height() -
                          $(document).height()) + 'px'
          });
     }
});

Check out the demos here: page with short content, page with long content!

Enjoy!

Tagged: , , , , , , , .


CakePHP and IIS and ISAPI Rewrite - Demystified!

Update: 11/16/2007

One of my commenters, James has provided a working production solution versus my “hacked” solution. See the comments and be sure to visit his site. :) Thank you James!


@ work, Stephen and I were tasked with fulfilling a requirement for the big boss, so we selected an up and coming Rails-like framework called CakePHP. Cake’s really fun and easy to use and like Ubuntu, “everything just works“… until you try hooking it up into IIS with ‘pretty URLs’. It took us a day of testing, hair pulling, more testing, more hair pulling, but finally - we’ve debunked the mystery.

First, let me start off by saying that we read all the wiki documentation, searched google groups, and though we found people doing similar things, we didn’t find any solution that satisifed our needs. We found partial solutions with poorly written wiki tutorials, so that’s why you’re reading a brand-new one.

The setup

Our setup consisted of the Cake framework (cake_1.1.6.3264.zip) running on Win2K w/ IIS5 and PHP5 running as an ISAPI Dll. We created a virtual directory named “tp” that’s currently mapped to the app/webroot directory in our Cake installation directory. From reading all the available tutorials, Cake’s functionality all boils down to passing index.php in the app/webroot directory the following:


?url=/controllerName/action/params

This, my friend, is how all the magic begins. So, from the web, I should always be able to reach the following URL:


http://domain.com/tp/index.php?url=/controllerName/action/params

The get-go

Here are the following results from our tests:

Test 1: Do nothing

Stephen and I both hypothesized that by doing nothing, we’d just manually echo out all linking URL’s, i.e. we wouldn’t use the $html->link helper function. This works, period. However, if we do nothing to the configuration, and we do employ the $html->link helper, $html->link(”/controllerName/action”) writes out the following URL:


http://domain.com/controllerName/action

First off, since we have a virtual directory named “tp”, this obviously won’t work. Second, if I define (’WEBROOT_DIR’, ‘tp’) within app/webroot/index.php and then use $html->link(’/controllerName/action’), I get the following URL instead:


http://domain.com/tp/controllerName/action

Closer, but this still doesn’t work because ISAPI Rewrite isn’t enabled. So… that leaves us wondering, how do we use $html->link without modifying the configuration? In any case, we revert the variable WEBROOT_DIR back to its original setting for our next test.

Test 2: Enable Cake Short URLs

With Cake Short URLs enabled, a user will be able to access particular actions via the following URL:


http://domain.com/tp/index.php/controllerName/action

To enable the short URLs, I followed the wiki tutorial. Basically, this involves uncommenting the BASE_URL environment variable and defining (’SERVER_IIS’, true) in core.php in the app/config directory. Now, when I use the $html->link helper, these configurations enabled inserting /tp/index.php/ into the url and everything works! For example, $html->link(’/controllerName/action’) now prints the following:


http://domain.com/tp/index.php/controllerName/action


(And it works too!)

This solves the problem but still doesn’t give us the ideal solution. After all, who wants that index.php within the URL? Not to mention, enabling this configuration setting made it impossible to access the following (original) URL:


http://domain.com/tp/index.php?url=/controllerName/action/params

Is this the expected behavior? As a side note, I can now access URLS as such:


http://domain.com/tp/index.php?/controllerName/action/params

Notice the ‘?’ without the ‘url=’. Is this expected behavior as well? In any case, on to enable ISAPI Rewrite.

Test 3: Enable ISAPI Rewrite

To enable ISAPI Rewrite, we know we had to disable Cake Short URLs by disabling the BASE_URL variable, but at the same time, we decided to leave the IIS_SERVER variable to true. Next, we decided to follow this tutorial on the Cake wiki. No offense to the author, but this entry is incomplete and leaves no explanation as to how the author came to those Rewrite rules. Also, the tutorial doesn’t explain how to enable the pretty URLs for a site running in a virtual directory.

So, we downloaded the ISAPI Rewrite Dll from http://www.isapirewrite.com/. Note, download the free version, but realize that there are limitations on what it can do. Enable the ISAPI Dll @ the Site level since you need the full version for granularity at the virtual directory level. The httpd.ini file that’s listed in the wiki only works if you’re running Cake from the IIS Site level and not from a virtual directory.

Our configuration

Here’s what we did to enable the ISAPI Rewrite from a virtual directory. Our httpd.ini file looks like the following:

[ISAPI_Rewrite] 

// This rule catches the Short URL settings
RewriteRule (.*?\\.php)(\\?[^/]*)?/([^/]*)/(.*) $1(?2$2&:\\?url=/$3/$4) 

//This rule performs the ISAPI Rewrite rules
RewriteRule ^/VIRTUAL_DIRECTORY_NAME_HERE/(.*)/ /VIRTUAL_DIRECTORY_NAME_HERE/index.php?url=/$1

Note, replace virtual_directory_name_here with the name of your virtual directory. As you can see, RewriteRule ^/VIRTUAL_DIRECTORY_NAME_HERE/(.*)/ /VIRTUAL_DIRECTORY_NAME_HERE/index.php?url=/$1 is taking the following URL:

/virtual_directory/controllerName/action/ and rewriting it to /virtual_directory/index.php?url=/controllerName/action.

This is exactly how we want it!

Wait, as you can see though, the RewriteRule matches URLs that have a slash at the end. We figured that the original wiki poster left the slash so that this rule wouldn’t match any of the files being served out of app/webroot such as the css/img files.

Wait… what implications does this have?

Well, this just means that when you use the $html->link helper, you’ll need to end all your actions with a “/”. For example, if you want to link to /controllerName/action, you must now type $html->link(”/controllerName/action/”). Now, this will match the second RewriteRule and everything will work!

However, there’s just one tiny piece we’re forgetting. If you did try this out on your site, you’ll find that the URLs generated from $html->link still don’t have the virtual directory name in it. You’ll see that the links generated will be http://www.domain.com/controllerName/action/. Well, from our experience in past tests, this means you have to define(’WEBROOT_DIR’, ‘virtual_directory_name’) in the app/webroot/index.php file and voila…

Everything now works!

Tagged: , , , , .


Powered by Wordpress. Stalk me.