Posted by dpirotte
on October 07, 2009
Ben Johnson’s excellent Searchlogic gem makes searching your ActiveRecord models trivial. But, what if you want to include tags in your search? If you are using acts_as_taggable_on, this is pretty straightforward.
There is a catch, though… you can only search one tag context at a time due to the way acts_as_taggable_on handles its joins. Patching this would be straightforward, but you would end up joining tags into your query once per context, which could get nasty fast depending on the size of your data set. If you have a medium-sized data set or larger, strongly consider offloading the tag search to Sphinx or your search engine of choice.
Posted by dpirotte
on July 08, 2009
EnterpriseDB provides a wonderful one-click installer for PostgreSQL on OS X that comes packaged with several contrib modules.
If you need to enable any of these, you can find the SQL in /Library/PostgreSQL/8.3/share/postgresql/contrib/. For example…
$ psql -U postgres template1 < /Library/PostgreSQL/8.3/share/postgresql/contrib/fuzzystrmatch.sql
Remember to execute the SQL on any pre-existing databases in which you want to use the specified contrib functions.
Posted by dpirotte
on March 14, 2009
Mail::Chimp::API is a simple Perl wrapper around the MailChimp v1.1 API. The object exposes the MailChimp XML-RPC methods and confesses fault codes/messages when errors occur.
For example…
use strict;
use warnings;
use Mail::Chimp::API;
my $chimp = Mail::Chimp::API->new($username, $password);
my $campaigns = $chimp->campaigns;
my $lists = $chimp->lists;
my $subscribers = $chimp->listMembers($lists->[0]->{id});
print 'success' if $chimp->listSubscribe($lists->[0]->{id}, 'someone@somewhere.com', {}, 1);
You can download it from github or from CPAN.
Enjoy!