Double Shot #630 »
Created at: 20.01.2010 14:56, source: A Fresh Cup, tagged: Double Shot jquery kumofs ruby solr sphinx
- jQuery Lint - Script to report incorrect usage of jQuery APIs.
- kumofs - A fresh distributed key-value store for Ruby.
- Code Blocks: Ruby's Swiss Army Knife - An excerpt from the Ruby Best Practices book.
- JavaScript grid editor: I want to be Excel - A big survey of grids available for jQuery and others.
- ThinkingSphinx exits, enters ActsAsSolrReloaded - The competition between search libraries for web applications will never end.
- How many Ruby Hackers does it take to change a lightbulb? - Lots.
more »
Double Shot #619 »
Created at: 05.01.2010 14:40, source: A Fresh Cup, tagged: Double Shot cromwell firebug rubinius sphinx stencil testing
Looks like the next RailsBridge BugMash is going to focus on Rails 3, just before the beta. This could be interesting.
- Lemon - Yet another ruby unit test framework, this one focused on making sure there's a test case for every method.
- Reincarnate - How to make a ruby class inherit from itself.
- Sphinx Monitoring Plugin - The latest nice touch from the Scout guys.
- Cromwell - Wrapper for ruby signal handling to allow you to easily create unkillable scripts.
- Stencil - Free-text (ie, not assuming HTML) templating system.
- Rubinius 1.0.0-RC2 Released - Ruby in Ruby moves along.
- Firebug 1.6a1 - The next branch of Firebug (for Firefox 3.6/3.7) has gone live.
more »
Double Shot #618 »
Created at: 04.01.2010 14:31, source: A Fresh Cup, tagged: Double Shot css javascript jquery mysql passenger rssowl sphinx textmate
Well, at least it's January.
- Primer - Paste in HTML, get back a CSS stylesheet with all the classes and IDs listed.
- jLinq - LINQ style querying in Javascript. This is getting out of hand.
- Save MySQL! - You know, if the MySQL founders wanted to exercise so much control over its future, maybe they shouldn't have sold the company.
- RSSOwl 2.0.2 - A new release of a desktop RSS reader. That's a rare occurence these days.
- hanoi - Some glue for automated jQuery testing.
- netrecorder - Record actual network traffic for later use with fakeweb.
- A Month in the Life of Thinking Sphinx - Lots of nice changes to this gem lately.
- phd - Push deployments for passenger.
- ReMate - TextMate plugin to disable automatic project tree refresh, making TM more useful against remote shares.
more »
Quick Tip: Search for null dates in Thinking Sphinx »
Created at: 17.10.2009 17:35, source: Hackido, tagged: rails thinking-sphinx sphinx
In one of my projects, when a record is deleted I set a deleted_at field with the timestamp rather than actually destroying it. Because that model is indexed by Thinking Sphinx I want to make sure that it doesn't then show up in any search results (the user says she deleted it, right?) I had thought the way to do that would be as simple as passing an extra condition to my query, but I was wrong.
Instead, what you have to do is create an attribute in your model for the datetime field in question and use :with => to filter it down. It might look like this. # Search Index.
define_index do
indexes :name, :sortable => true
indexes :description, :sortable => true
has :deleted_at
set_property :delta => true
end
In the above, I'm not indexing deleted_at, rather it's set as an attribute. When I do my search, I can then use it as follows:Foo.search(params[:search], :with => {:deleted_at => 0})
Now why did I use 0 instead of nil? Because Sphinx equates nil values with 0.. you'll find out about that if you ever decide to sort any integers that involve null values..
One other thing I want to mention. In my case, I allow admins to search for all the records, including the deleted ones. If I never wanted those records even indexed I would instead add a where clause to my index itself. ('where "deleted_at IS NOT NULL"') This way I wouldn't have to specify the (:with =>) in my controller.
more »
Quick Tip: Search Email in Thinking Sphinx »
Created at: 06.06.2009 19:24, source: Hackido, tagged: rails thinking-sphinx sphinx
If you use Sphinx as your search backend you may have noticed that it won't search for an entire email address. It's a bit perplexing at first since everything else works so well. After banging my head on the issue for a few hours, I got some direct help from Pat Allan, the creator of Thinking Sphinx. The problem is with the "@" symbol which is a reserved character in Sphinx. To get around that we need to modify Sphinx's allowable character set.
Now for better or for worse, you don't actually need to define any sort of config file by default to use Thinking Sphinx.. it's smart enough to pick sensible defaults. But in this case we'll have to go ahead and create one.
Every Ruby on Rails project comes with a config folder where many files you may need to modify are stored. In this directory create a file called sphinx.yml. It's a YAML file so be careful about spacing here. It's as sensitive as your database.yml file so if you accidentally alter the spacing things may not work.
For our example, let's use the UTF-8 character set. So in that sphinx.yml file, paste this content:development:
port: 3312
charset_table: "0..9, a..z, _, @, A..Z->a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F"
test:
port: 3313
charset_table: "0..9, a..z, _, @, A..Z->a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F"
production:
port: 3312
charset_table: "0..9, a..z, _, @, A..Z->a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F"
There are a number of other options you can put in your configuration file of course, but the charset_table one is going to be the one that helps you search email. In order to see the effect, you'll need to rebuild your index. If you've got a recent version of the Thinking Sphinx plugin:rake thinking_sphinx:rebuild
Otherwise, you'll need to stop, index, and then start:rake thinking_sphinx:stop
rake thinking_sphinx:index
rake thinking_sphinx:start
After that searching for emails should work!
more »
