Rails named_scope and fragment caching

December 4, 2008 Link to post  Permalink

The typical way I’d write code that used fragment caching looked like this.

The fragment caching adds extra work to the controller code to avoid doing the work that didn’t need to be done due to the data being cached. This is kind of messy.

I’ve also written code like this to avoid the above cruftiness

From my previous post about when the named_scope queries actually run it occurred to me that the following code now works correctly.

YouTube Developer APIs: New vs Old

December 1, 2008 Link to post  Permalink

Some time ago, I wrote an application that used the old YouTube API to extract information for specific videos. Recently, I wrote a similar application, and based on the warnings about the old API being deprecated, I used the new API.

The new YouTube API is based on some Google technologies, which is great for making it scale, but may not be the best thing for some applications. It certainly isn’t the best for my application.

I want users of my application to see a video on YouTube and then add that video to my app, and for the video to show up. This sounds reasonable, except the New API for YouTube can be 2, 3, 4+ hours behind the website. This delay is Ok for Google search, but for my application, not being able to get info about a video that the user can clearly see is available kills the experience.

Food Fling makes the top 10 Facebook gifting apps

December 1, 2008 Link to post  Permalink

Food Fling was listed in the Inside Social Games Top Ten gifting apps on Facebook today!

W00t!

Real money in online game economies

November 29, 2008 Link to post  Permalink

I recently read “Play Money”, a book about how Julian Dibbell spent a year trading virtual goods in Ultima Online with real money. This is an interesting read for anyone building any sort of online system that has virtual goods of any kind. Even if you don’t want people to trade items in your world, people will find a way to do it, and some may make money from the process, and others will be ripped off (and blame you for it too!)

The cool thing is that if you have any success at all, there will be a demand for this type of trading that you can take advantage of – you just need to plan it out to make it transparent to users and not allow holes that cheaters can take advantage of.

Using Phusion Passenger for this blog

November 28, 2008 Link to post  Permalink

I’ve just moved this blog onto an installation of Phusion Passenger. If you can’t see this post, then the DNS hasn’t caught up yet.

The installation instructions at the ModRails site are pretty good for setting the thing up, but there are some tricks.

On Ubuntu, the Apache configuration goes in a file in the /etc/apache/sites-enabled directory. The entire contents of that file for this blog is here. I needed the Directory section to allow access to the static files.

Rails named_scope output in log files

November 8, 2008 Link to post  Permalink

I’ve been using the new Rails feature of named_scope for my current project. One thing I do for all new pages is to check the Rails development.log file to make sure that the SQL queries I’m expecting are actually the ones that are executed.

Typically, my controller will run the queries to get all the data, and the views will use the results to display the data. This pattern is clear in the log file. The Controller runs the query and retrieves the data before the View code is executed.

However, named_scope queries don’t actually perform the database query until the data is actually requested in the code, so the SQL text in the log file will show up when the views are rendering, not when the controller code runs. And if the view never uses the results, the query is never executed.

All of this is transparent to your code, but it caused me a few minutes of confusion trying to find the query that I was expecting to see.

My company is looking for a programmer

November 8, 2008 Link to post  Permalink

Check out our Craigslist posting

We’ve had a lot of response from Microsoft stack people, some Java, a few PHP people and a few people with no programming experience at all.

We got really lucky with our first attempt a few months ago – we ended up hiring the first person to respond to the listing (which is kind of scary). Perhaps now we’re hitting the reality of hiring people this way.

We’re looking for people to build social networking games in Rails, so any combination of some of these skills would be a great start. So far, no-one with Rails or Social Networking experience has responded.

jPod, the TV Show!

I recently read “jPod” the book by Douglas Coupland. Its a pretty good book, kind of weird – perhaps Quirky is a good description.

As a programmer in the video game industry, its kind of required reading

It turns our that CBC in Canada turned this into a TV Show

High Performance MySQL - now with more Kick Ass!

I have the first version of this book, and have just used parts of this, the second version, to help setup a new MySQL server in a production environment.

This book has saved me hours already. Worth the price, right there.

If you do stuff with MySQL, you must have this book.

ATOP is my favorite Linux tool

I’m diagnosing a load problem with a server, and ATOP has helped me a lot.

For Ubuntu – ‘apt-get install atop’ works fine.

Here is the ATOP home page