- Our Mutual Friend – The Scholarly Pages —
Tagged as: dickens literature publishing serial - Dickens and the Classic Serial – Giddings — Specifically, the classic _television/radio serial_ – but a cracking piece of writing nontheless
Tagged as: drama mediastudies radio serial tv victorian - Caching Tutorial for Web Authors and Webmasters — No time to read this now, so into delicious it goes…
Tagged as: cacheing hosting howto tutorial webdev
- The Morning News – David Mitchell, by Robert Birnbaum — Lovely, in-depth interview full of cracking quotations. Definitely worth a read.
Tagged as: davidmitchell fiction interview stories
- Getting Started With ActiveRecord Migrations — Because, you know, at some point I’m going to have to dive into using them quite hard…
Tagged as: database deployment development rails rubyonrails versioncontrol - TextDrive Gem question — Locking the core Rails gems’ versions. Useful, if it’s still valid syntax (Rails moves a lot in a year)
Tagged as: deployment hosting rails rubyonrails - Fiction networks : the emergence of proprietary, persistent, large-scale popular fictions by Jason Todd Craft. — Ooh. Ooh, ooh, ooh. Large scale persistent fictions? Distributed serial narrative? Awesome
Tagged as: fiction narrative networks publishing thesis
Ken Levine on BioShock
12 May 2006
Ken Levine, creator of System Shock 2, talks to IGN about his forthcoming RPG Bioshock. Two choice quotations:
I’ve always said that, when we were working on Thief, I’d rather have a story element about the moss arrow then about some cult you never get involved with in the game or some god or something. That’s because I play with the moss arrow, it’s part of my game experience; I want to tie that into the story.
and
I think it’s all about making a world that’s believable. One that has an aesthetic point of view in which the player isn’t constantly bumping into the edge of thus pulls him out of the experience. It’s not about physics puzzles, it’s about having things behave the way I expect them to. Half-Life 2 uses physics puzzles really well; that’s not an issue. My response is not to create my own gravity gun. Our goal is to make this world in Rapture a real place.
Yes. Yes, yes, yes. More sharp, incisive, intelligent discussion in the full interview.
Sometimes, when you’re building a Rails application, you want to generate different relationships to the same model – or, rather, multiple relationships to multiple perspectives on a model. You can tell ActiveRecord to override the expected class name, but you can also use this technique to create “subsets” of classes for relationships, too. It’s worth remembering that ActiveRecord can generate these for you. By doing the query in the database, rather than filtering afterwards, your application will run faster.
As you can see from that explanation, I’m not exactly the greatest developer, so this is probably best explained with an example from life.
I’m currently working on a CMS – yawn yawn, I know. Anyhow, in this CMS, we have articles, and an Article has_many :comments
. Obvious one-to-many relationship, fine. However, comments may or may not be spam, marked by the attribute is_spam
. So whilst article.comments
will return all the comments on a particular article, it’d be nice to have a class method that returns all the clean comments; article.clean_comments
, for instance.
My first stab at this was to add the following method to the Article class:
def clean_comments output = [] self.comments.each do |c| output << c unless c.is_spam end output end
which is, I suppose, passable idiomatic Ruby, and which does the job; we build an output hash of objects unless the comment is spam. The problem is that if you have, say, an article with a thousand comments - of which 990 are spam, we end up having to generate 1000 objects from the database, and then filter them with Ruby. It'd be faster to select only 10 from the database in the first place, right?
We can do that by defining a new relationship. In our Article model, under has_many :comments
, we can add this:
has_many :clean_comments, :class_name => 'Comment', :conditions => 'is_spam is null', :order => 'created_at'
Bingo. That extra has_many
allows us to refer to article.clean_comments
, and it'll do so directly from the database via SQL. This is a fairly simple example, and I do recommend looking up has_many
and has_one
(which has similar capabilities) in the Rails API documentation. There always seems to be more depth with Rails than you initially expect, so it's worth digging a little deeper - and you'll make your code leaner, quicker, and better as a result.
- Hivelogic: Articles: Preventing SVN Exposure — I’ll need this some day in the next month or so, now I’ve got SVN up and working (hurrah!)
Tagged as: capistrano howto rails reference subversion
- Why Content Publishers shouldn’t host weblogs… (plasticbag.org) — I’ve always maintained that publishing/broadcast companies shouldn’t host user weblogs; I’d forgotten that I may/may not have read it here first. Tom, on the money, as ever.
Tagged as: blogs media publishing
- Guest: Mike Harris looks at "Remind" | 43 Folders — The good stuff is in the comments.
Tagged as: mac osx productivity remind tool tutorial unix - Remind: The Ultimate Personal Calendar | Linux Journal — Comprehensive article on Remind
Tagged as: article mac opensource osx productivity remind unix - MacDevCenter.com — Unix Gems for Mac OS X — Featuring, of course, Remind.
Tagged as: article cli mac opensource osx tools unix