Ferreting Full Text Search

Posted by John
on Monday, 01 December 2008

Got the full-text searching working with the blogging engine, plus it's really fast using the Ferret gem and Will Paginate.

First grab the necessary gems,

sudo gem install ferret acts_as_ferret will_paginate

Then,

require 'will_paginate'
require 'acts_as_ferret'

Next up I defined the elements to search against in the target model (here app/model/article.rb)

acts_as_ferret :fields => [:title, :body, :cached_tag_list]

And then altered the search method to...

@articles = Article.paginate_search params[:search], :page => params[:page], :per_page => $blog.article_count

...you will need to add this class method to handle the pagination with Will Paginate

module ActsAsFerret
  module ClassMethods
    def paginate_search(query, options = {})
      page, per_page, total = wp_parse_options(options)
      pager = WillPaginate::Collection.new(page, per_page, total)
      options.merge!(:offset => pager.offset, :limit => per_page)
      result = find_by_contents(query, options)
      returning WillPaginate::Collection.new(page, per_page, result.total_hits) do |pager|
        pager.replace result
      end
    end
  end
end

...thanks to opensoul.org for this solution.

Works like a charm ;-)

Apple Mac Keys

Posted by John
on Wednesday, 26 November 2008

apple mac keys

  • use ALT+3 to get # (mac)
  • use Command+F12 to access FireBug in Firefox (mac)

64-bit Flash Player for Linux

Posted by John
on Thursday, 20 November 2008

A long time coming Adobe have finally released a 64-bit version of their Flash Player and it's for Linux.

It's in Alpha but reports suggest it's actually quite stable, so good news all around for us with 64-bit Ibex machines ;-)

You'll need to uninstall you're current Flash Player via either...

sudo aptitude remove flashplugin-nonfree

Or going into your ~/.mozilla/plugins directory and removing the old version.

To install simply download the tar file relevant to your distro, extract the plugin and drop it into your Firefox Plugins directory ~/.mozilla/plugins

Restart Firefox and you should be good to go,

Firefox Config

Posted by John
on Thursday, 20 November 2008

to access the Firefox Configuration area, type this into your address box and hit enter...

about:config

If you completely screw things up you can reset to the defaults by...

  • Start Firefox in Safe Mode
  • Check the Reset to Defaults box
  • Click the Make Changes and Restart button

RubyMine Public Preview

Posted by John
on Wednesday, 19 November 2008

RubyMine

From the makers of Resharper, a brand new Ruby IDE for Windows / Mac / Linux.

...might finally be a reason to switch off TextMate ;-)

Installing on Linux is a little difficult but do-able, first off download the Linux build and extract it.

Next up you'll need to add an environment variable into your .bashrc file,

gedit .bashrc

Then add this to the end of the file, with the path of your JAVA JDK location.

export JDK_HOME=/usr/lib/jvm/java-6-openjdk/

Save it and reload Terminal so it's got the new variable, then in Terminal navigate into the bin directory of RubyMine you just downloaded,

cd ~/Desktop/rubymine472/bin

Then remove the last line of rubymine.vmoptions

gedit rubymine.vmoptions

  remove this line => -agentlib:yjpagent=disablej2ee,sessionname=rubymine

Once done you should be able to start up RubyMine;

~/Desktop/rubymine472/bin/rubymine.sh

Then you can add it to your .bashrc file so you can fire it up any time you want with an alias,

alias rubymine="~/Desktop/rubymine472/bin/rubymine.sh"

And then

rubymine