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).
Read the rest of this entry
Posted by Scott
Filed in Rails
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!!!
Posted by Scott
Filed in Rails
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.
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'
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.
Posted by Scott
Filed in Rails
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.
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)
Posted by Scott
Filed in Links
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.
Posted by Scott
Filed in Links
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.
My Delicious tag cloud from
Wordle very cool
I created a new release for the fckeditor plugin today. It upgrades the version of the editor to the lastest 2.6 and also fixes the SanitizeHelper include issue which was causing problems with the spell check.
Other than that, little has changed. I think it is all still working ok, although I have only had time to complete a cursory check on the editor’s functionality.
The plugin is available from Ruby Forge or by doing this:
ruby script/plugin install svn://rubyforge.org//var/svn/fckeditorp/trunk/fckeditor
So, next lesson from TweetLists: the user id given in the xml from the public timeline is not a unique identifier. The screen name is the only way to identify a user. I ended up with 17 different ids for one user!!! Hence, gave up fixed it and dropped the database – too much effort to fix when its only been running for 12 hours.
Posted by Scott
Filed in Rails

I released TweetLists last night, well actually this morning (about 3am), the idea being to try and capture a little of the zeitgeist on Twitter by aggregating the links people are talking about. At the moment there are 3 lists, the live feed, a popular feed (the links ordered by the number of times they appeared) and one I have chosen to call Twitterati (quite proud of that!) which is the links ordered by the number of followers people have.
At the moment there is no time aspect to the Twitterati or Popular lists (not relevant on the live one) but I guess I will make them for the last 7 days?
Lesson one form this has been: don’t try and be clever with your scheduling – cron just works. I tried to use the Rufus Scheduler and it had stopped running by the time I got up again this morning.
Anyhoo, I’ve found it to be fun and interesting so far, any ideas for other lists?
Posted by Scott
Filed in Rails
So this plugin by Dr Nik Williams (no link available) does this:
Link or freeze RubyGems into your rails apps, instead of just plugins. This allows you to ‘vendor everything’ – pushing all dependent gems into your rails app thus ensuring your application will be guaranteed to work when deployed. Your application is no longer dependent on the gems that are/aren’t available on your target deployment environment.
I found this very useful, mainly because for some gems I want to see and maybe play with the code, usual I just copy the gem to lib. This provides a simple way of bringing in only one gem. I know there are features in 2.1 that deal with gem dependencies and do some cool stuff, but from what I know (from Ryan Bates) I don’t think they provide this particular functionality.
Its available on RubyForge. Or just by using the “sudo gem install gemsonrails” command.
Just been flicking through the cartoons at xkcd.com again and came across this one which made me chuckle:

Also found the GeoHashing, Spontaneous Adventure Generator to be very interesting idea. Check it out.
Posted by Scott
Filed in Stuff