Categories
Uncategorized

Gift Idea: “RailsSpace: Building a Social Networking Site with Ruby on Rails”

Cover of the book “RailsSpace”Today marks the start of my fourth week at TSOT, a Toronto-based startup that develops custom social networking software in Ruby on Rails. The company’s first two products are FraternityLive and SororityLive, which as you might imagine are targeted at fraternities and sororities, with future plans for creating similar apps for other fields.

I was hired primarily for my tech evangelism cred and broad development experience (Visual Basic, Python, PHP, Director and Java from the rough-and-tumble Java 1.2 days) rather than for experience with Rails, on which I’d done only a little spare-time noodling. This means that a good chunk of my time during this first month on the job has been split between getting familiar with Rails as well as TSOT’s apps.

Just before my first day at TSOT, I went down to Boston to join my in-laws for American Thanksgiving. While there, I decided to take advantage of the strong Canadian dollar and Thanksgiving weekend sales to do a little job-related book shopping. Although I had the PDF edition of Apress’ Practical Rails Social Networking Sites, I was pleased to stumble across another book on building social networking apps in Rails: Addison Wesley’s RailsSpace: Building a Social Networking Site with Ruby on Rails. I figured that if I find a book that covers the sort of development work that I’m about to start, I should buy it on the spot (after a quick skim of the book while in the store, of course).

Of all the books I’ve read on Rails development, this one’s my current favourite. Yes, there’ll always be a special place for Agile Web Development with Rails, but I have to say that I like the pacing, ordering of topics and the presentation of material in RailsSpace a little bit better. I like the way that authors Michael Hartl and Aurelius Prochazka take a slightly different approach to teaching Rails, from going with a social networking app rather than a “store” app to their clever visualization of Rails’ directories as a pie chart, shown below:

Rails directories, laid out in pie chart format
Graph adapted from RailsSpace
and borrowed from Weblog of Fernando Reig Matthies.

So take it from a guy who’s paying his rent by working on Rails social networking apps: if you have some development experience under your belt and are looking to pick up Rails in a hurry (or if you’re looking for a gift for someone who needs to learn Rails in a hurry) I recommend:

Here’s what other folks have to say about the book:

  • Review at Amazon.com by Charles Harvey: My favorite of the Ten Ruby and Rails Books on my desk — “The authors’ programming style(s) are easy to read while following and teaching the Ruby/Rails community practices. The book uses output examples after each snippet of code so you can follow along not wondering if what you just did worked.

    The example app you produce while working through RailsSpace is not YASNS (Yet Another Social Networking Site) rather a (LBERBPS) Learn by Example Rails Best Practices Site. It was fun for me as I was tired of shopping cart, and book/music store examples.

    I don’t know how to put it into to the right words, but this books code flows.

    I always enjoy the rare book that sets a standard of excellence, and that is what puts this book at the top of my Ruby on Rails Library.”

  • myCATs: An excellent Rails tutorial for the intermediate Rails Programmer — “This book is just plain fun. As the title implies, the focus is on building a social networking site using Ruby on Rails. The depth of knowledge of the authors, Michael Hartl and Aure Prochazka, is evident right from the first chapter. The examples are relevant and well explained, with clean, consice, well-tested and correct code.”
  • Nate Klaiber: RailsSpace review — “I may seem cynical about social networks, but this truly book pays attention to the small details. Building a social network is a great tutorial that covers many aspects of Rails and building your own application – no matter what it is. It has several callout boxes that give more explanation where it is needed. It discusses the importance of testing. It shows the importance of refactoring. All of this comes together to make a great reading experience and knowledge gained. If you are a Rails professional, there might not be a whole lot new for you, but if you are just beginning Rails this is an excellent full-blown tutorial. Even if you don’t want to create a social networking site, the foundation and principles set in this book will give you the knowledge needed to start building your own application.”
  • ComputerWorld: RailsSpace hits the Ruby on Rails learning sweet spot — “…if you’re already a proficient OOP developer — or a beginner who prefers learning by example — RailsSpace offers useful insight into what the Ruby on Rails hoopla is all about.”
  • A.P. Lawrence: RailsSpace — “I liked also that the project paid attention to both looks and ease of use without clouding up with too much detail. The design is simple, but with enough attention paid to presentation to understand how to accomplish that in ROR, and the same is true for niceties like data validation: they do enough to show the concepts without burying us in it.

    The authors also included deliberate mistakes – that is, design deficiencies which you might notice before they get around to pointing out the problem. That’s good too, because often the best way to understand why you need to do something this way is to see what happens when you don’t.”

  • WebChicanery: RailsSpace – The Book — I’m somewhat skeptical of these “build a project and learn” type of book, but this book may be one the the handiest book on Ruby that I’d had a chance to read. The authors approach it was a very pragmatic and structured standpoint, all while explaining some neat steps and additions they’ve thrown in along the way.”
Categories
Uncategorized

On Extended Warranties

Illustration of a cellphone walking through a number of hazards
Illustration by James Kaczman for the New York Times.
Click the image to see the illustration with its original article.

In response to an article from last year titled Extended Warranties are for Suckers, a reader going by the name “any non moose” pointed out in the comments that:

Corporates often prefer to warranty their purchases, since having a fleet of consistent items is much cheaper than having a hodge-podge of all different ones. Being able to swap one item for an identical one within your own organisation without having to retrain the user(s) is very very useful.

But I agree that for a SOHO or hobbyist, warranties are as you say, for suckers.

Yes, moose, when I was writing about extended warranties, I was referring to purchases made for home, hobby or SOHO purposes.

Since we’re in the final week of shopping before the holiday that’s increasingly referred to as “Holiday”, here are some links for those of you who are purchasing electronics as gifts and wondering if the warrantly plan is worth it (generally not):

Categories
Uncategorized

“Bioshock” Meets a Shopping Cart

I love this Photoshop job in which Rapture (the setting of the game BioShock) propaganda replaces the standard “Do not leave child unattended” message on grocery shopping carts:

Grocery shopping cart plastic thingy marked “Is a man not entitled to the sweat of his brow?”

The line is derived from the philosophy of game character Andrew Ryan (whose name and backstory are rearrangements of Ayn Rand). You hear it in an in-game recording in Ryan’s own voice:

I am Andrew Ryan, and I’m here to ask you a question: Is a man not entitled to the sweat of his brow?

No, says the man in Washington. It belongs to the poor.

No, says the man in the Vatican. It belongs to God.

No, says the man in Moscow. It belongs to everyone.

I rejected those answers. Instead, I chose something different. I chose the impossible.

I chose…Rapture.

A city where the artist would not fear the censor. Where the scientist would not be bound by petty morality. Where the great would not be constrained by the small. And with the sweat of your brow, Rapture can become your city as well.

If you’re looking for a gift for someone with an XBox 360 or a PC with enough horsepower to play modern first-person shooter games, you might want to consider BioShock as a gift. It’s an excellent game that blends gaming action with a very rich backstory — quite possibly the richest since Myst. Better still, it’s can be finished in an amount of time that still lets you have a life: at the “easy” level, I finished it in a about a week, playing a couple of hours a day, and I’m a relatively casual gamer.

Links

Categories
Uncategorized

1000 Copies of “Rock Band” Taken in Truck Heist

Screen shot from “Rock Band”

I remember watching an interview with William Gibson in which he talked about the 1992 L.A. Riots and the Digital Divide. He remarked that while many stores were looted, it was notable that a store that had laptop computers in their window display went untouched; he looters simply saw no value in them, whether for themselves or as things they could “fence”.

Looking at tech devices that people are stealing is a pretty good indicator of their mainstream appeal. Had the riots taken place today, the laptops would probably be among the first things taken by the looters. Here in Toronto, GPS navigation systems have replaced car stereos as the must-steal items.

As for console games, Rock Band has now been established as the most in-demand game, if you’re using theft as your yardstick of tech popularity. A truck carrying more than 1,000 copies of the XBox 360 the game — which includes a guitar, drum and mic controller — was hijacked in Long beach, California last weekend.

According to the L.A. Times article on the theft, “Thieves are increasingly targeting the nearly $260 billion of goods that move through the Los Angeles and Long Beach ports each year, especially targeting high-priced electronics shipped from Chinese factories.”

Meanwhile, we Canadians still have to wait — Rock Band’s Canadian release date has been delayed until the 17th.

Categories
Uncategorized

Pythagorean Pick-Up [Updated]

Don’t you wish stuff like this actually happened?

Comic showing guy picking up a girl using the Pythagorean Theorem
Click the comic to see it on its original page.
Comic courtesy of Miss Fipi Lele.

You get bonus bragging rights if you spotted the missing precondition.

Categories
Uncategorized

Area Man Gives Glowing Review for His Windows Vista to XP Upgrade Experience

Windows Vista reliability monitor window showing a system’s downward reliability trend
Click the screenshot to see the article Review: Windows XP

From the blog Coding Sanity (whose subtitle is “.NET, pragmatism and geek cachet”) comes the review titled Review: Windows XP

I have finally decided to take the plunge. Last night I upgraded my Vista desktop machine to Windows XP, and this afternoon I will be doing the same to my laptop.

You can read the whole review about the experience of upgrading from Windows Vista to Windows XP here. The review concludes with this:

To be honest there is only one conclusion to be made; Microsoft have really outdone themselves in delivering a brand new operating system that really excels in all the areas where Vista was sub-optimal. From my testing, discussions with friends and colleagues, and a review of the material out there on the web there seems to be no doubt whatsoever that that upgrade to XP is well worth the money. Microsoft can really pat themselves on the back for a job well done, delivering an operating system which is much faster and far more reliable than its predecessor. Anyone who thinks there are problems in the Microsoft Windows team need only point to this fantastic release and scoff loudly.

And Now, a Word on Vista’s Behalf…

Here’s Chris Pirillo delivering a very stirring defense of Windows Vista. Enjoy!

Categories
Uncategorized

In PHP, There’s Equality, and Then There’s EQUALITY

Ka=Ping Yee’s Equality Test

Here’s a quickie PHP script based on the one that appears in Ka-Ping Yee’s LiveJournal entry titled Why PHP Should Never Be Taught:

<?php
$a = 0;
$b = "eggs";
$c = "spam";
$e = "eggs";

echo "<h1>The \"==\" Exercise</h1>";
echo "<ul>";
echo "<li>\$a is $a</li>";
echo "<li>\$b is $b</li>";
echo "<li>\$c is $c</li>";
echo "<li>\$d is undefined</li>";
echo "<li>\$e is $e</li>";
echo "</ul>";

echo ($a == $b) ? "\$a == \$b<br />" : "\$a != \$b<br />";
echo ($b == $c) ? "\$b == \$c<br />" : "\$b != \$c<br />";
echo ($a == $c) ? "\$a == \$c<br />" : "\$a != \$c<br />";
echo ($a == $d) ? "\$a == \$d<br />" : "\$a != \$d<br />";
echo ($b == $d) ? "\$b == \$d<br />" : "\$b != \$d<br />";
echo ($c == $d) ? "\$c == \$d<br />" : "\$c != \$d<br />";
echo ($b == $e) ? "\$b == \$e<br />" : "\$b != \$e<br />";
?>

If you’re not familiar with PHP’s quirks, you’ll find the output surprising:

The “==” Exercise

  • $a is 0
  • $b is eggs
  • $c is spam
  • $d is undefined
  • $e is eggs

$a == $b
$b != $c
$a == $c
$a == $d
$b != $d
$c != $d
$b == $e

What Happened?

In PHP, as with many other programming languages, the == operator is the equality operator, which returns true if the operands on either side are equal in value. It works as expected when used on operands of the same type, as evidenced by the program above, which states that $b is equal in value to $e, both of which are set to the string eggs.

We get into strange territory when the == operator is used to compare operands of different types. The program above evaluates the boolean $a == $b as true even though $a is set to the integer value 0 and $b is set to the value eggs. How can eggs be equivalent to 0? They’re so tasty and versatile! Damned anti-ovites!

In PHP, the == operator is what I like to call the “Slack Equality Operator”. When used to compare a string and a number, it attempts to convert the string to a numeric type and then performs the comparison. The following example code, taken from the PHP documentation, shows how PHP’s string-to-number coercion works:

<?php
$foo = 1 + "10.5";                // $foo is float (11.5)
$foo = 1 + "-1.3e3";              // $foo is float (-1299)
$foo = 1 + "bob-1.3e3";           // $foo is integer (1)
$foo = 1 + "bob3";                // $foo is integer (1)
$foo = 1 + "10 Small Pigs";       // $foo is integer (11)
$foo = 4 + "10.2 Little Piggies"; // $foo is float (14.2)
$foo = "10.0 pigs " + 1;          // $foo is float (11)
$foo = "10.0 pigs " + 1.0;        // $foo is float (11)
?>

Hence the eggs/zero equivalence: the string eggs is coerced to 0.

Enter the === Operator

I like to call the === the “Strict Equality Operator”. It returns true if and only if:

  • Both operands are the same type
  • Both operands have the same value

Here’s the code I showed at the start of the article, but with all instances of == replaced with ===:

<?php
$a = 0;
$b = "eggs";
$c = "spam";
$e = "eggs";

echo "<h1>The \"===\" Exercise</h1>";
echo "<ul>";
echo "<li>\$a is $a</li>";
echo "<li>\$b is $b</li>";
echo "<li>\$c is $c</li>";
echo "<li>\$d is undefined</li>";
echo "<li>\$e is $e</li>";
echo "</ul>";

echo ($a === $b) ? "\$a === \$b<br />" : "\$a != \$b<br />";
echo ($b === $c) ? "\$b === \$c<br />" : "\$b != \$c<br />";
echo ($a === $c) ? "\$a === \$c<br />" : "\$a != \$c<br />";
echo ($a === $d) ? "\$a === \$d<br />" : "\$a != \$d<br />";
echo ($b === $d) ? "\$b === \$d<br />" : "\$b != \$d<br />";
echo ($c === $d) ? "\$c === \$d<br />" : "\$c != \$d<br />";
echo ($b === $e) ? "\$b === \$e<br />" : "\$b != \$e<br />";
?>

Here’s the output, which behaves as expected:

The “===” Exercise

  • $a is 0
  • $b is eggs
  • $c is spam
  • $d is undefined
  • $e is eggs

$a != $b
$b != $c
$a != $c
$a != $d
$b != $d
$c != $d
$b === $e

Once More, in Ruby

Just for kicks, I thought I’d translate the original code into Ruby just to see what would happen. Here’s the code:

a = 0
b = "eggs"
c = "spam"
e = "eggs"

puts "a is 0"
puts "b is 'eggs'"
puts "c is 'spam'"
puts "e is 'eggs'"

puts a == b ? "a == b" : "a != b"
puts b == c ? "b == c" : "b != c"
puts a == c ? "a == c" : "a != c"
puts a == d ? "a == d" : "a != d"
puts b == d ? "b == d" : "b != d"
puts c == d ? "c == d" : "c != d"
puts b == e ? "b == e" : "b != e"

…and here’s the output:

a is 0
b is 'eggs'
c is 'spam'
e is 'eggs'
a != b
b != c
a != c
double-equals.rb:14: undefined local variable or method `d' for main:Object (NameError)

Links