Rubuntu is (almost) born!

Posted by ezmobius Thu, 16 Feb 2006 22:58:00 GMT


So I am working on a custom linux liveCD for all rubyists. This is basically an Ubuntu liveCD that has been pimped out for rails/ruby developers.

This is a call to arms for all of you out there. Send me your weak huddled masses of vimrc's and jedit configs yearning to be free(as in beer). Here is a list of some of what is planned so far:

ruby1.8.4
gems
rails
switchtower
mysql/ruby bindings
postgresql/ruby bindings
sqlite/ruby bindings
kirbybase/ackbar
imagemagick/rmagick
apache/fcgi/scgi
lighttpd/fcgi
mongrel
subversion
svk?
darcs?
trac
phpmyadmin(I know I know but its useful, will run on lighty on an obscure port)
vim/setup slick(can use help with this, please send configs and suggestions)
emacs/setup slick(can use help with this, please send configs and suggestions)
jedit/setup slick(can use help with this, please send configs and suggestions)
kate/kdevelop/setup slick(can use help with this, please send configs and suggestions)
gedit, scite, freeride?
RadRails
daemontools
daedalus
offline ruby and rails docs
other random good stuff

OK, lets hear your thoughts. Leave suggestions in the comments about what you would like to see included. And please send me any configs for text editors that are ruby specific or too cool not to include.

And a religious question ;-) What desktop environment. I will include a few lightweight ones for folks who prefer them but only one out of KDE or Gnome is going to make it in. What's it going to be folks?

Tags ,  | 74 comments

The Book.

Posted by ezmobius Mon, 30 Jan 2006 23:44:00 GMT

So I have been very busy with all my jobs and projects, especially the book. It is coming along well though. I am still on target to get a beta release in late March so stay tuned.

Sorry i haven’t been updating my blog much but I have been otherwise involved. Hopefully I won’t let it go so long between posts.

Tags , , , , ,  | 10 comments

New ez_where plugin.

Posted by ezmobius Mon, 30 Jan 2006 23:31:00 GMT

So me and my friend Fabien Franzen have been busy creating the new ez_where plugin. It's been totally revamped with many additions to the ease of use and the syntax.

Big thanks to Fabien for his excellent work extending my original idea and forcing me to rethink this stuf to make it better. Hope someone finds it usefull. As always, this is alpha software so let me knwo of any bugs or any questions you might have.

We have added the ability to do sub queries and nested AND's and OR's. Plus we have replaced find_with_conditions with the shorter ez_find. This method takes a block and can use the :include options to search on multiple models and return them all in one query with your associations included.

These new changes break backwards compatibility, but I think they are worth it. So if you are using the old version of this plugin be ready to refactor a bit ;-). Without further ado, here is the massive README from the distribution.

You can get this version at: opensvn.csie.org/ezra/rails/plugins/dev/ez_where/


Welcome to the new improved ez_where plugin for rails. This plugin is meant 
to be used as a nice ruby like syntax for creating the :conditions part of an 
ActiveRecord::Base.find. We also add the ActiveRecord::Base.ez_find method.
This method takes a block to simplify single and multi table queries.

articles = Article.ez_find(:all, :include => :author) do |article, author|
  article.title =~ "%Foo Title%"
  author.any do
    name == 'Ezra'
    name == 'Fab'
  end 
end

This will produce :conditions => ["article.title LIKE ? AND 
                   (authors.name = ? OR authors.name = ?)",
                   "%Foo Title%", "Ezra", "Fab"]

Basically here is the breakdown of how we map ruby operators 
to SQL operators:

foo == 'bar'           #=> ["foo = ?", 'bar']
foo =~ '%bar'          #=> ["foo LIKE ?", '%bar']
foo <=> (1..5)         #=> ["foo BETWEEN ? AND ?", 1, 5]
id === [1, 2, 3, 5, 8] #=> ["id IN(?)", [1, 2, 3, 5, 8]]
<, >, >=, <= et all will just work like you expect.

There is also the ability to create the conditions in stages so 
you can build up a query:

cond = Caboose::EZ::Condition.new do
  foo == 'bar'
  baz <=> (1..5)
  id === [1, 2, 3, 5, 8]
end
 
@result = Model.find(:all, :conditions=> cond.to_sql)
#=> ["foo = ? AND baz BETWEEN ? AND ? AND id IN (?)",
     "bar", 1, 5, [1, 2, 3, 5, 8]]

You can even do nested sub conditions. condition will use AND 
by default in the sub condition:

cond = Caboose::EZ::Condition.new :my_table do
  foo == 'bar'
  baz <=> (1..5)
  id === [1, 2, 3, 5, 8]
  condition :my_other_table do
    fiz =~ '%faz%'
  end
end

@result = Model.find(:all, :conditions=> cond.to_sql)
#=> ["my_table.foo = ? AND my_table.baz BETWEEN ? AND ? 
     AND my_table.id IN (?) AND (my_other_table.fiz LIKE ?)",
     "bar", 1, 5, [1, 2, 3, 5, 8], "%faz%"]

You can also build multiple Condition objects and join
them together for one monster find:

cond_a = Caboose::EZ::Condition.new :my_table do
  foo == 'bar'
  condition :my_other_table do
    id === [1, 3, 8]
    foo == 'other bar'
    fiz =~ '%faz%'
  end
end
#=> ["my_table.foo = ? AND (my_other_table.id IN (?) AND my_other_table.foo = ?
       AND my_other_table.fiz LIKE ?)", "bar", [1, 3, 8], "other bar", "%faz%"]

cond_b = Caboose::EZ::Condition.new :my_table do
  active == true
  archived == false
end

#=> ["my_table.active = ? AND my_table.archived = ?", true, false]

composed_cond = Caboose::EZ::Condition.new
composed_cond << cond_a
composed_cond << cond_b
composed_cond << 'fuzz IS NULL'

@result = Model.find(:all, :conditions => composed_cond.to_sql)
#=> ["(my_table.foo = ? AND (my_other_table.id IN (?) AND my_other_table.foo = ? 
      AND my_other_table.fiz LIKE ?)) AND (my_table.active = ? AND my_table.archived = ?)
      AND fuzz IS NULL", "bar", [1, 3, 8], "other bar", "%faz%", true, false]   

You can compose a new condition from different sources:

ar_instance = Author.find(1)

other_cond = Caboose::EZ::Condition.new :my_table do 
  foo == 'bar'; baz == 'buzz'
end

cond = Caboose::EZ::Condition.new
# another Condition
cond.append other_cond
# an array in AR condition format
cond.append ['baz = ? AND bar IS NOT NULL', 'fuzz'], :or
# a raw SQL string
cond.append 'biz IS NULL'
# an Active Record instance from DB or as Value Object
cond.append ar_instance

#(append is aliased to << because of syntax issues 
involving multiple args like :or)

@result = Model.find(:all, :conditions=> cond.to_sql)

#=> ["(my_table.foo = ? AND my_table.baz = ?) OR (baz = ? AND bar IS NOT NULL) 
      AND biz IS NULL AND authors.id = ?", "bar", "buzz", "fuzz", 1]

OK there is also other options for doing subconditions. OR is 
aliased to any and any creates a subcondition that uses OR to 
join the sub conditions:

cond = Caboose::EZ::Condition.new :my_table do
  foo == 'bar'
  any :my_other_table do
    baz === ['fizz', 'fuzz']
    biz == 'boz'
  end
end

@result = Model.find(:all, :conditions=> cond.to_sql)

#=> ["my_table.foo = ? AND (my_other_table.baz IN (?) 
     OR my_other_table.biz = ?)",
     "bar", ["fizz", "fuzz"], "boz"]

OK lets look a bit more at ez_find with a few more complex queries:

# all articles written by Ezra. Here you can use a normal AR object
# in the conditions
# session[:user_id] = 2
ezra = Author.find(session[:user_id])    
@articles = Article.ez_find(:all, :include => :author) do |article, author|
  author << ezra # use AR instance to add condition; uses PK value if set: author.id = ezra.id
end 
#=>["(authors.id = ?)", 2]

# all articles written by Ezra, where he himself responds in comments
@articles = Article.ez_find(:all, :include => [:author, :comments]) do |article, author, comment|
  article.author_id == ezra.id
  comment.author_id == ezra.id   
end
#=>["(articles.author_id = ?) AND (comments.author_id = ?)", 2, 2]

# any articles written by Fab or Ezra
@articles = Article.ez_find(:all, :include => :author) do |article, author|
  author.name === ['Fab', 'Ezra']   
end
#=>["(authors.name IN (?))", ["Fab", "Ezra"]]

# any articles written by Fab or Ezra, using subcondition
@articles = Article.ez_find(:all, :include => :author) do |article, author|
  author.any do
    name == 'Ezra'
    name == 'Fab'
  end  
end
#=>["(authors.name = ? OR authors.name = ?)", "Ezra", "Fab"]

# any articles written by or commented on by Fab, using subcondition
@articles = Article.ez_find(:all, :include => [:author, :comments]) do |article, author, comment|
  article.sub { author_id == 1 }
  comment.outer = :or # set :outer for the comment condition, since it defaults to :and
  comment.sub { author_id == 1 }       
end
#=>["(articles.author_id = ?) OR (comments.author_id = ?)", 1, 1]

@articles = Article.ez_find(:all, :include => [:author, :comments],
                           :outer => { :comments => :or }, 
                           :inner => { :article => :or}) do |article, author, comment|
  article.sub { author_id == 1; author_id == 2 }
  comment.sub { author_id == 1 } 
end
["(articles.author_id = ? OR articles.author_id = ?) OR (comments.author_id = ?)", 1, 2, 1]

And finally you can use any and all with ez_condition like this:

cond = Article.ez_condition { active == true; archived == false }
cond.all { body =~ '%intro%'; body =~ '%demo%' }
cond.any { title =~ '%article%'; title =~ '%first%' }

#=>  ["articles.active = ? AND articles.archived = ? 
      AND (articles.body LIKE ? AND articles.body LIKE ?) 
      AND (articles.title LIKE ? OR articles.title LIKE ?)",
      true, false, "%intro%", "%demo%", "%article%", "%first%"]


As you can see we can get quite detailed in the queries this can create. Just use your imagination ;-) Also the test cases in the plugin source have many more examples to choose from.

Get it here: ez_where

Tags , , , ,  | 45 comments

More Where Clause goodness.

Posted by ezmobius Wed, 04 Jan 2006 23:44:00 GMT


I have been working on the where plugin some more trying to make the syntax a bit more natural ruby. Here is what the latest version looks like to use:

Model.find_with_conditons( :all, :limit => ..., :order => ... ) do 
  foo == 'bar'       # ["foo = ?", 'bar]
  baz <=> (1..100)   # ["baz BETWEEN ?AND ?", 1,100]
  woo =~ 'substri%'  # ["woo LIKE ?", 'substri%']
  id === (1..4)      # ["id IN (?)", [1,2,3,4]]
  fiz < 10           # lt, gt, leq, geq, etc., should all "just work" 
end

I like this because now it really just looks like ruby. Gotta love using the spaceship operator <=> to sugnify a [BETWEEN ? and ?, 1, 10]! The =~ or regex match operatpr in ruby gets converted into a LIKE query in the db. Also just added IN (?) support using the === operator. And you can still use :limit, :order and :joins plus :all or :first and it just works. I still need to convert the tests to use the new syntax so that will be done this weekend.

You can get the development version here if you want to play now. Or wait until the weekend when I add a few more features like the ability to use OR instead of AND for arbitrary items in the :conditions clause.

http://OpenSVN.csie.org/ezra/rails/plugins/ez_where

Posted in ,  | 6 comments

Ryan Davis movies from RubyConf

Posted by ezmobius Wed, 04 Jan 2006 18:04:51 GMT

Bil Kleb has been kind enough to re-upload the movies of Ryan Davis’s talk on ruby2c, meta-ruby, ruby-inline and zen-hacks. There is some great stuff in these movies. Thanks Bil.

RyanDavis160.mov
RyanDavis240S.mov
RyanDavis320.mov

Posted in  | 5 comments

A symbol is an object with a name.

Posted by ezmobius Wed, 28 Dec 2005 06:24:32 GMT

Jim Weirich has a great post here about symbols and how they are not just immutable strings. This question comes up for most newbies to rails because of the heavy use of symbols for option hash constructs.

Posted in ,  | 5 comments

A community effort book

Posted by ezmobius Tue, 20 Dec 2005 23:07:00 GMT


So i am busy writing my book over here. It’s a ton of work let me tell you. But it is going to be very rewarding.

The book is turning out to be a community effort of sorts. I have a few of my favorite and most respected rails developers writing parts of the book(topfunky & technoweenie) and the author of the great lighttpd webserver is going to personally cover the configuration of lighty in detail.

So if you don’t see me on the rails list or on #rubyonrails as much anymore you know where I went ;-)

Posted in , , , ,  | Tags , , , ,  | 5 comments

Rails One Point Oh Yeah!

Posted by ezmobius Wed, 14 Dec 2005 18:21:00 GMT


Well Rails 1.0 was released yesterday to much fanfare. Three cheers for the whole core team and everyone else involved!

It has been a great ride for me to see rails grow into such a thriving community. I have been ‘on’ rails for 14 months now and let me tell you, it’s come a long way baby! The quality of coding that goes on in this circle has brought the life and fun back into web development for me and many other refugees from other P & J languages.

And to top it off, my biggest raisl project to date, The YakimaHerald.com Website made it onto the new Raisl 1.0 web page in the featured applications area. Sweet!

Once again I tip my hat to you DHH and to everyone else working on or with rails for a better future.

Posted in ,  | no comments

The book is a go!

Posted by ezmobius Wed, 14 Dec 2005 18:12:00 GMT


So I have great news! I am going to be writing a book for the Pragmatic Programmers. This is such a great chance for me that there was no way I could pass on it.

Thank you for all the support and people who commented that they would like to have this book written. Its definitely one area where the rails docs are not sufficient as well as being very fragmented and hard to decipher which way is the way to go.

Now I must buckle down and write the thing! But I am totally looking forward to this book and I have some great people working on it with me. It looks like there will be 3 people writing a chapter on two on things they know a lot about. I can’t say just yet who they are but when the time comes I will let on.

I am so honored that the Pragmatic Programmers are giving me this opportunity. And I will be working on the book with some of the rails devs that I most respect.

So check back often and i will give updates as things get closer to beta. Thanks for all the support. I hope that this book will be an valuable asset to rails programmers that are ready to step things up to the next level.

Posted in , , , ,  | Tags , , , ,  | 17 comments

Rails Deployment Configuration Book

Posted by ezmobius Fri, 09 Dec 2005 18:31:00 GMT


EDIT: This book has been picked up by the pragmatic programmers. It will be available as a beta book pdf for download in March. Then the final printed version should be available in early summer. Thanks for all the interest and stay tuned for more announcements.


I’m thinking about writing a small sized book on rails development and production environment configuration. Sometimes it seems like every other question on the rails mailing list and on #rubyonrails is about fcgi or server setup or some issue with deploying or installing rails and friends.

I have spent a great deal of my time with rails on getting the configuration of the server and underlying architecture running just right. And it seems that most information about this stuff is spread out over the rails wiki and hundreds of other blogs out there.

I already have quite a bit of this stuff written in my notes and I have written a few detailed tutorials here on my blog as well. But I have started organizing this stuff in a high level overview and have written the first few chapters of this book already.

My question is this: Would you be interested in purchasing a book like this? It will most likely be released as a DRM Free PDF only at first unless I get a publisher interested. I have sent a proposal to the wonderful PragmaticProgrammers.com for me to write one of their Pragmatic Friday PDF’s. I hope they will take me up on it ;-)

I think this is one area of rails development that gets swept to the wayside and doesn’t get nearly enough attention. And the info that is available is fragmented and contradictory at best.

Here is a very preliminary table of contents:

  • Intro to rails environments and overview of what we will cover in the book.
  • Installation of your development environment on all the major platforms(OSX, Linux, BSD, Windows)
  • Practical techniques for development on your own or working with other developers remotely.
  • Migrations
  • Production Environment Theory
  • Apache/FastCGI or SCGI
  • Lighttpd/FastCGI or SCGI
  • Daedalus/Daemon Tools and friends for keeping your servers running no matter what.
  • Switchtower
  • Other Helpful Tools for Your Arsenal.
  • Shared Hosting.
  • VPS or Dedicated Hosting.
  • Stories of Successful Rails Applications Already Running in the Real World.
  • The Impact of Ajax Techniques on Your Server Load
  • Code Snippets and Samples for Accomplishing Things the “Rails Way” and Making Sure You Make Sane Decisions that Will Scale Later.
  • But Can Rails Scale? ;-)
  • Wrapup and Discussion of High Level System Overviews.

    So please leave comments about anything I might be missing that you would like to see in a book like this. And if anyone want to help out and thinks they could write a chapter or two on something they know a lot about I am all ears. And do you folks think this would be a good idea and worth spending a significant amount of my time on?

    Thank you for any suggestions or comments.

Posted in , , , ,  | Tags , , , , , , , , ,  | 107 comments

Older posts: 1 ... 12 13 14 15