New Year, New President, New Database?!?

Posted by sam, Sat Jan 31 20:44:00 UTC 2009

Happy New Year everyone. I'm glad to see its finally 2009. Barack Obama is now our president. Even if you did not vote for him, its fantastic to see a peaceful transition of power, unlike in 2000.

Anyway, I've decided to switch databases, from MySQL to Postgres.

Why would I do that?

It's disconcerting to see Monty Widenus complain about Sun shipping MySQL 5.1 out the door with crashing bugs.

Also, I also am uneasy with Oracle owning the core database engine behind MySQL.

I know that MySQL is working on the Falcon Database engine for version 6, but i have non idea when version 6 will be released.

Lastly, MySQL keeps all database metadata in a MyISAM table. Seriously! WTF? A database should keep it's own data in a storage engine that has transactions and is ACID compliant.

A catalyst for this change is a gift I received for christmas: Enterprise Rails by Dan Chak

It is probably one of the top programming books i've read in a long time (and for those of you who know me, I read a lot of programming books). I changed over my Beerbin website to Postgres I'm in the process of doing the same for the 3 mephisto blogs I administer, including this one.

The EnterpriseDB tools for Mysql to Postgres migration are excellent. I'll try to release some of my scripts to my github account.

Finally, I've noticed that there are not any postgresql user groups in Chicago. I think it would be cool to have one

0 comments | Filed Under: | Tags: obama postgres

Back to blogging

Posted by sam, Thu Nov 20 13:36:00 UTC 2008

I'm going to try blogging again... It needs to be updated. More coming soon

0 comments | Filed Under: | Tags:

Coolest Railscast Yet: Episode 111: Advanced Search Form

Posted by sam, Thu May 29 19:47:59 UTC 2008

I've tried all sorts of stuff to get advanced searches working well. This is some excellent ruby code for extracting parameters from a search form.

Episode 111: Advanced Search Form: "If you need to create an advanced search with a lot of fields, it may not be ideal to use a GET request as I showed in episode 37. In this episode I will show you how to handle this by creating a Search resource."

(Via Railscasts.)

0 comments | Filed Under: | Tags:

Testing MarsEdit

Posted by sam, Thu May 29 19:20:57 UTC 2008

Time to see if MarsEdit Actually Works..

Updated: Damn, it does work!

0 comments | Filed Under: | Tags:

Time to do some iPhone development. But one thing is missing. Git!

Posted by sam, Fri Mar 07 19:36:35 UTC 2008

I downloaded the iPhone SDK last night (once the site wasn't swamped). It looks pretty cool so far, and it's a good excuse to actually use Objective-C after using Ruby and C# professionally for the past couple of years (Notwithstanding all the proprietary stuff I had to use at Hewitt Associates)

Xcode's gotten leaps and bounds better in the past couple of years. I definitely applaud the tools team at Apple for the hard work. However, one thing that's a little bit disappointing is the version control systems that Apple integrates with Xcode: Subversion, CVS, and Perforce.

I think it would be a huge boon if they could add in Git (and, oh what the heck, Mercurial) so that coders can use their favorite VCSs in xcode.

Ok, I think I can manage by using git with the command line at the xcode project structure, but where's the fun in that? Who really likes context switching these days?

Apple, please integrate git and mercurial into Xcode by the WWDC, at least.

1 comment | Filed Under: | Tags: Git git iphone

Obama's viral videos

Posted by sam, Tue Mar 04 14:29:00 UTC 2008

This is absolutely amazing. These videos are great

0 comments | Filed Under: | Tags: obama

Frustrations with rSpec

Posted by sam, Sun Feb 24 22:32:00 UTC 2008

I'm working on the new blog, and I'm having some trouble with rSpec testing controllers and nested routes.

Here's my routes file

ActionController::Routing::Routes.draw do |map|
  map.root :controller => "frontpage"
  map.resources :posts, :has_many => :comments 
end 

And here is some of the controller specs I'm trying to test

require File.dirname(__FILE__) + '/../spec_helper'

describe CommentsController do
  describe "handling GET /posts/1/comments" do

    before(:each) do
      @comment = mock_model(Comment)
      Comment.stub!(:find).and_return(@comment)
      @post = mock_model(Post)
      @post.stub!(:comments)
      @post.comments.stub!(:find).and_return([@comment])
      Post.stub!(:find).and_return(@post)
    end

    def do_get
      get :index, :post_id =>@post.id 
    end

    it "should be successful" do
      do_get
      response.should be_success
    end

    it "should render index template" do
      do_get
      response.should render_template('index')
    end

    it "should find all comments" do
      Comment.should_receive(:find).with(:all).and_return([@comment])
      do_get
    end

    it "should assign the found comments for the view" do
      do_get
      assigns[:comments].should == [@comment]
    end
  end

Here's the controller

class CommentsController < ApplicationController
  # GET /comments
  # GET /comments.xml
  before_filter :load_post

  def index
    @comments = @post.comments.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @comments }
    end
  end
  protected 
  def load_post
    @post = Post.find(params[:post_id])
  end
end

Everything works, except for one spec:

When I try to run the spec on "it should find all comments" I get this error

Mock 'Class' expected :find with (:all) once, but received it 0 times

I don't know what to do. I'm trying to understand what I'm doing. Mocks and Stubs are a big leap of faith for someone who grew up using full blown fixtures. I hope my other specs aren't passing due to dumb luck or something like that.

Should I wait and try to do this in the Stories? Is it useful to to rSpec mocks and stubs for a nested resource?

Any ideas? Fire away in the comments.

BTW, I'm using the great article Rolling on Rails with Rails2.0 from Akita on Rails as a starting point for my new blog.

Thanks for the great article!

1 comment | Filed Under: | Tags: bdd newblog rspec ruby

Welcome Back Saturday Night Live!

Posted by sam, Sun Feb 24 22:05:14 UTC 2008

It's about time that Saturday Night Live came back on the air.

They've missed a lot of good comedy with the 2008 Presidential Race.

Here's where they left off last fall.

And here's the return of former cast member Tina Fey, with her emphatic endorsement of Hillary Clinton.

Earlier, they made fun of the debate that was recently held in Texas. Here's a clip

I'm really not sure what I think of having Fred Armisen playing Barack Obama

I think i'll have to start DVRing SNL.

Till Later,

Sam

0 comments | Filed Under: | Tags: entertainment politics

Planned Features on the new blog

Posted by sam, Thu Feb 21 23:05:55 UTC 2008

The most important thing for me on my new blog is composing articles. I like doing quick posts from the iPhone, and also posting from Textmate.

I have to rejigger/reinvent/fork/whatever the Textmate blogging bundle to accommodate ActiveResource based posting. Shouldn't be too terribly hard.

Also, if I have an inspiration to write, I'd like to be able to post on it from my iPhone. I'm going to come up with a separate interface so that it's lean, mean, and fast.

The textmate bundle for blogging is the most interesting feature so far. I'm getting back into my concepts of programming languages class at DePaul by learning how to write grammars and mini-languages. For those of you who dont know what I'm talking about, think back to grade school when you had to dialog sentences.

Now think of the different things you have to do on a part of a sentence. It's complicated, but fun.

More progress to come on this later.

Till next time,

Sam

0 comments | Filed Under: | Tags: newblog