Posts

Showing posts from July, 2007

Rails and Nested Singular Resources

One of the reasons I love Rails is the built in support for REST. If you're not yet writing your Rails applications RESTfully, then you're not really writing web applications. I'll detail an example that I just created which I thought illustrated REST support quite nicely. In Rails, you can model singular or plural Resources. A plural Resource might be Users, which means you'll have lots of Users in your system. In contrast, you can create singular Resources when there is only one instance of that Resource in the system. A good example of a singular resource is an User's avatar icon. For instance, most Web 2.0 applications let you upload a tiny picture that represents you. In Rails speak, we say a User has one Avatar Icon. An Avatar Icon belongs to a User. When creating the URI space for these models (User, AvatarIcon) you use map.resources and map.resource inside of your routes.rb file. We want to enforce that an AvatarIcon belongs to an User in the U...

Fixing Rails Pagination for SQL Server

MS SQL Server certainly feels like the red headed step child of the Rails connection adapters. The core developers aren't interested in it, and I'd have to guess that most Rails developers deploy to MySQL or PostgreSQL . A good example of why the SQL Server support needs more love from the Rails community. The pagination code in the connection adapter is horribly ugly. SQL Server 2000 doesn't support a limit or offset, which makes pagination extremely difficult. For kicks, check out the SQL that the Rails connection adapter generates for a limit and offset query in SQL Server. There's enough sub queries and reverse sorts to make your head spin. Not to mention the awful performance killing select count(*) before every query. SQL Server 2005 makes our life a little easier in that it added row_number() support. With this, it's possible, however not straight forward, to perform pagination that doesn't make you want to puke so much. Unfortunately, Rails h...

QOTD

From Bill de hÓra: Wag the dog : As strange as might sound, businesses might get more value from computer systems once those systems stop being optimized around transient business requirements or features. You can customize things, but only above the infrastructure. That seems to be part of the pitch for something like EC2. Bill is talking about the systems level architecture, but can this observation be applied to software level services? Is this the pitch for SOA, in that business systems can be composed from existing smaller discreet services in the cloud?

OSCON Hadoop Presentation Downloads

Yahoo Developer Network blog has links to their recent OSCON Hadoop Presentation with downloads of PDFs and a video of the presentation. Hadoop is an open source implementation of a framework for processing large sets of data. Yahoo is currently using it to process log files, among other things.

Scaling Web Applications

Sam Ruby, via Tim Bray, has collected a list of scaling web applications presentations and documents . As Tim said, this is "everything anybody knows" on the subject. I'm interested in large scale data crunching as we build out our data warehouse. It's tricky for us, as we have one machine to do all of our data crunching, so we are definitely constrained by I/O. To really solve this issue on a single machine, we need to be smart with our disks and spread the data out to ensure parallel reads. As I read through these presentations and reports, I'm always trying to map it back down to one machine with maybe four discs and two dual core processors. Of course, I can just rent a Hadoop cluster . Note to Amazon EC2: Install a EC2 instance on the DoD .mil network so we can use it, too!

Calculating Combinations The Cool Way

I recently had to calculate all possible combinations of a set. I needed to calculate combinations of 1..N size, where N is the size of the original set of things. Order inside of the resulting combinations did not matter to me, as I am treating the combinations as true sets. For example, given the set [A,B,C] , I needed to calculate the following combinations: [] [A] [B] [C] [AB] [AC] [BC] [ABC] It dawned on me that a cool way to generate the combinations was to treat the sets (the original set and the resulting combination sets) as bit strings. If the bit corresponding to the member is on, I include the member in the combination. To explain, I start with the set [A,B,C] . I create a number that has three bits, all on, one for each member of the set. I therefore have the binary number 111 matching [A,B,C] . 111 happens to be 7 in decimal, which is one less than the total number of combinations I require. Starting with zero, I loop up and including seven (for a total of eight i...

Restful Account Activation

Nearly every web application has the concept of users or accounts. While the concept of a user or account is quite universal, when you get to implementing, you find out that the business rules and implementation details vary widely from application to application. Luckily for your Ruby on Rails applications, there's an excellent starting point for creating the basics of accounts and logins. The restful_authentication plugin for Rails provides generators for Users and the basic framework required, such as email activations, logins, passwords, controllers, and database migrations. The extra bonus is that the plugin uses REST to model the authentication. In the REST web application world, all you see are objects, or nouns. The verbs in the system are limited to the HTTP methods such as GET, PUT, POST, and DELETE. REST advocates that you interact with the world (your nouns) with these four methods. It forces you to think, "How would I convert an Action into a Thing?"...

links for 2007-07-15

[Fresh Moods "Rhythmbreeze"] - Groovera: Web radio. Chilled grooves. True. (downtempo. future lounge. nu-jazz. trip-hop. ambient pop. neo soul. deep house. chill out. music.) streaming tunes. hope it lasts. (tags: music )

links for 2007-07-09

Seattle Conference on Scalability: Abstractions for Handling Large Datasets (tags: google video database )

links for 2007-07-03

OpenOLAP for MySQL Open source storage engine for MySQL supporting ROLAP and MOLAP. (tags: datawarehouse olap )