Skip to content

Exclude Records With UltraSphinx

So been using Sphinx with the UltraSphinx plugin and I came across the requirement to use filters to reject records. Unfortunately in the plugin the filters are hardwired to submit the ‘exclude’ parameter as ‘false’ i.e include. Time for a quick hack I think…….

Very easy to fix, just open up the ‘internals.rb’ file in the UltraSphinx plugin or include the gem using ‘rake gems:unpack GEM=ultrasphinx’ (need to have config.gem “ultrasphinx” set in envrinoment.rb) and then find that file.

Ok, so found the file? On line 97 is this loop:

Array(opts['filters']).each do |field, value|
  ....
 begin
     case value
     when Integer, Float, BigDecimal, NilClass, Array
       # XXX Hack to force floats to be floats
       value = value.to_f if type == 'float'
       # Just bomb the filter in there
       request.filters << Riddle::Client::Filter.new(field, Array(value), false)
     when Range
     ....
end

The ‘Riddle::Client::Filter.new(field, Array(value), false)’ call is the one we need to change (the ‘false’ is the exclude param).

(Continued)

Hop Toad

I’ve been using the Hop Toad web app for a while now to collect errors from my Rails apps and its been working out great. It drops in very simply and replaces the Exception Notifier plugin I was using.

Big advantages are the archive of errors and the ability to mark them as dealt with. Of course I could do that with email folders and the like, but I’m lazy and this appears to do it all. Oh and its free!!!

Linux – Just say no…….

More from the excellent xkcd





Mashup of the Day – Tweetlists

So, I got a great email about an hour ago:

To the creative genius[es] behind TweetLists,

We’d like to congratulate you on being selected as our MASHUP OF THE DAY at MashupAwards.com for July 30, 2008.

Mashup of the Day


So, not all that familiar with The Mashup Awards, but others clearly are as the resulting traffic killed the site (not that that would of been hard)! I would like to say thank you to them for the award and also take this opportunity to thank my manager, parents, producer, jesus, god, twitter!, Tim Berners Lee, Matz……..

Right then off to ‘enjoy basking in the glow of my well deserved recognition’ as suggested by ‘The Mashup Awards Judging Panel’

Parsing Rails log files with JSON

So I needed to parse the log files for SlimTimer this weekend to correct a data loss issue due to a small issue with implementing https for subscribers. The issue required looking for requests that had returned something other than “200 OK” collecting the parameters and entering any data that had got lost. After a bit of messing around it occured to me the the format of the parameters string in the Rail’s logs was not a million miles from the JSON format, so I came up with this to turn the string into a useable hash:

params =~ /.*: Parameters: (\{.*\})$/
str_hash = JSON.parse(params.gsub('=>',':'))

This provides a hash of the parameters used in the request. Of course the keys here are strings so to convert to symbols we can then use:

def create_symbol_hash(input)
  ret = input
  if input.is_a? Hash
    ret = {}
    input.each do |k, v|
      ret[k.to_sym] = create_symbol_hash(v)
    end
    ret
  else
    ret
  end
end

and simply pass in the output from the JSON library. Seemed quite neat to me anyway.

How not to return your hire car!!!

So just got back from a great 2 weeks in California, went to Foo camp, Social Media Camp, Mashable and a couple of other meetups – all excellent. One slight hiccup with the hire car…….. I claim it was the taxi’s fault (of course), although its a bit of a blur to be honest.

On the up side I can highly recommend Enterprise (and taking out the full coverage), they were very helpful and polite. Even offered me a new car – which would of seemed like a better idea if I could move properly!! At least no one was badly hurt.

TweetLists Comedy

So, couple of pretty funny links creeping up the popular chart over at TweetLists

1) Yahoo Resigner (by Mat Honan)

2) Instant Rim Shot (by Scott Carver)

Goosh

One of the top links that came from Tweetlists over the past couple of weeks is Goosh, an online google shell. Its great, well worth checking out. I really like the “translate” mode.

FCKeditor Plugin 0.5.1 Released

Thanks to George Chatzigeorgiou there is now a version of the FCKeditor plugin that works with Rails 2.1. I have put the packages on Ruby Forge and updated the repository. If you are interested as to what the issue was check out George’s comments on the previous post.

Wordle

My Delicious tag cloud from Wordle very cool