Listing posts

Now running mod_rails

Just switched MatHarvard.ca to mod_rails in place of nginx and mongrel. I have a few PHP applications, and running them on nginx was a slight hassle. Of course once setup they could be left unattended. But as I plan to add a couple more and start prepping my slice for a second live Rails app, I went the easy road and picked up Apache.

Another Mongrel restart

Here's the third consecutive version of MatHarvard.ca. Being almost another complete re-write (bad idea I know), it warranted a new design as well. The publishing app is now at the point where it can be worked on, instead of re-written, for future iterations. I took all the good from the previous attempts, and poured it all into this one version. It's by no means complete, some of the admin views need to be touched up, and there's always work to be done making everything more RESTful.

For now I'm contempt, it feels good to finally push this out live. The RSS feed hasn't changed, so there's no need to update.

Linking to the previous page in Rails

This came in handy with a little app I was working on, :back. Drop that into your controller in a redirect_to or view in a link_to and it will redirect, or link back to the previous page, as long as the referrer header is set (the user came to this page from another page). However, and I've only tried this in the view, if the referrer header is not set in the browser, it will fallback to the JavaScript history.back().

Example 1. Redirecting back from the controller.

def create
  @post = Post.new(params[:post])

  if @post.save
    redirect_to :back
  else
    render :action => "new"
  end
end

Example 2. Linking to the previous page from the view.

<%= link_to "Back", :back %>

Simple, and useful.

Populating a database with rake tasks

A little snag I ran into while writing this blog was the ability to create a user from outside the admin panel. Initially I thought to just leave the user signup actions available, create a user, then delete them after. That can get rather annoying, as I plan to (hopefully) open source this little app, something better needed to be done. The easiest solution I found was to use a rake task, so here it is.

namespace :blog do
  desc "Creates the default user account."
  task(:create_default_user => :environment) do
    User.new(:id => 1,
             :name => "Administrator",
             :login => "admin",
             :email => "admin@changeme.com",
             :password => "default",
             :password_confirmation => "default",
             :created_at => Time.now,
             :updated_at => Time.now
             ).save
    puts "# ============================================================"
    puts "# You can now login at http://yourdomain.com/admin with:"
    puts
    puts "#         Login: admin"
    puts "#      Password: default"
    puts
    puts "# Please change your password and email address as soon"
    puts "# as you login."
    puts "# ============================================================"
  end
end

After dropping that into RAILS_APP_DIR/lib/tasks/blog.rake, I can simply run rake blog:create_default_user; it creates a new user model object, and saves it to the database. If you're looking for a more in-depth explanation, check out the Ruby on Rails Rake Tutorial at Rails Envy.

RSS Feed

Just added the RSS feed of the latest posts. If your browser did not notice it, you can
view or subscribe here.

Rambo64

Code name "Isaac" and I built this game for our final project in IT class. The theme was to recreate a Commodore-64 game, which we did, but with a few extra features... The original C64 version of Rambo just wasn't quite good enough in our opinion. Months of planning later, this popped out of our fingertips.

The main highlight of our game was the first boss fight. Probably the most challenging, as it entails a head on head fight with none other then David Heinemeier Hansson. He's not to be underestimated, his killer Ruby blast waves are not to be taken lightly. Check out the screenshots, or download the game to play (requires Java).

Installing Subversion on a shared host

Please note: This guide is old, I'm posting it as a courtesy to anyone trying to install Subversion on their shared hosting account. At the time of this writing, I had a number of shared hosting accounts to test and base this guide from. However, since then I've moved away from shared hosting to a VPS. That being said, I cannot offer support for any issues that arise. This is a "follow at your own risk" guide.

Stop, start, reload

Here it is, the next iteration of what I hope to be a successful little publishing app. Almost everything has changed, most notably is the control panel; there actually is a control panel now. Before, one had to type in a URL and hope it was the "write a new post" page. It's now sporting a full interface. I made the decision to push this out sooner rather than later. Consequently, it's missing a few features that were originally planned on. For that, I'm sorry, mainly to Richard, I didn't get your beautiful control panel in.

This now sets the base to all other versions. The first was more of a proof of concept. It worked well, but I wasn't nearly satisfied with it. I've spent the last week sculpting this from freshly cut ruby. Pure red isn't all it's cut out to be, so there's some blue(cloth) gems socketed in as well. Some AJAX made it into the control panel, and I threw some at the comments as well. Thanks to respond_to, the JavaScript is fully degradable. The new design is based off of a previous one, but comparatively, is totally different. The same theme carries into the control panel as well, at least until I imbue Richard's into it.

A request

I had a request from before, which didn't make it through the explosion, to post up my tutorial on installing Subversion on a shared host. I've moved away from shared hosting and Subversion quite a long time ago. I've tried to keep it up to date, but as I don't have a shared host to test it on, it has become impossible to do so. I plan on re-posting it, but for that reason I won't be able to offer any support whatsoever. Zero, zilch, nada, nothing, as-is, at your own risk, good luck, don't blame me, I told ya' so. Look for that in the next couple days.

What's to come

An RSS feed would be useful eh? I'll smash a quick one together, and put it on FeedBurner, so any other changes made will not affect subscribers. If you're desperate (for me? Haha, what a joke!), you can use this raw XML feed.