Using Raw SQL snippets to create Thinking-Sphinx Indexes

We have used Thinking-Sphinx in several projects to implement search engines. Thinking-Sphinx is a wrapper in Ruby to use ActiveRecord with Sphinx. But in the project I’m working right now I had to solve a different problem: the user should be able to search for formatted values, however without using the formatting characters, i.e, suppose a field containing 111.444.777-35, the user should be able to find it searching for 11144477735 (or a substring of it).

The default behaviour for Thinking-Sphinx is to index the exact values for each column it scans, but we can by-pass it. The Thinking-Sphinx index definition allows us to use raw SQL to define which values should be indexed for each attribute. In my case, I used the native PostgreSQL regular expressions functions to get rid of the punctuation characters, indexing only the “clean” version of each value. My database column is called “entity_number”:

define_index

Continue reading

How to send a large quantity of email in Rails, using ar_mailer

Radu Cojocaru

email-newsletterSending a large number of emails is not an easy task. It can take a lot of time so you need to do it asynchronously. Also, if you are on a shared hosting, you might be limited to a certain number of emails per hour, so you need to divide your list of email addresses in batches and send them at certain intervals.

There’s a plugin that can help us with this: ar_mailer.

This plugin adds a new deliver method to ActionMailer::Base :activerecord. In this delivery method, emails are not actually delivered, they are stored into a database table. A ruby script ar_sendmail can then be run (in a cron job) in order to send the emails saved in the database.

Step by step intructions on how to use the plugin:

1) Install the plugin

./script/plugin install git://github.com/adzap/ar_mailer.git

Add following line to config/environment.rb:

config.gem "adzap-ar_mailer",

Continue reading

Facebook GUI free PSD resource

Ney Ricardo

Facebook developers already have a useful info on Facebook components documentation, i.e., they count on Facebook FBML wiki as reference.

Thinking of designers and, of course, ourselves as designers, we made a Facebook Graphic User Interface (FBGUI) resource kit for Photoshop to make our work easier.

fb-gui-thumb

The purpose is to speed up Facebook interface design, sparing you from drawing all the comps and letting you customize all the texts, buttons and data as you need.

The kit brings the Facebook vector icon and logo. Also, since the focus of this resource are the UI elements, it brings a main window with the header, menu and the chat window for you to set up your realistic mock-ups. Cannot forget to mention all the modal components, comment boxes, buttons, message boxes, tabs, etc.

Needless to say, all the components are full layered, built

Continue reading

Code blocks with optional arguments in Ruby 1.8.x

Ruby 1.9 has some cool new features. One of them is the ability to define default values for the arguments passed to code blocks, like in the following example:

pow = proc { |a, b = 2| a**b }
 
pow.call 3, 3
# 27
 
pow.call 3
# 9

This is very useful, for instance, when we dynamically create new methods using metaprogramming and want some of the arguments for these methods to be optional.

class MyMath
  class < < self
    define_method :pow do |base, exponent = 2|
      base**exponent
    end
  end
end
 
MyMath.pow 3 # 9
MyMath.pow 2, 3 # 8

But in Ruby 1.8.x we can’t do that, we can’t define default values the arguments of a code block. So what if your application runs on 1.8.x and you need to dynamically create methods with optional arguments? There is a solution, not so elegant as the

Continue reading

How long will it take to understand Rails 3 in and out?

Brad Midgley

According to David Heinemeier Hansson, you will never understand it all. Case in point? David himself.

That was the gist of his answer to how a new change to the way rails 3 renders actions in the browser would be handled for older browsers.

DHH gets involved in the parts he cares about and doesn’t worry about the exact details that have been delegated to someone else. He says we should not worry about knowing the whole framework because he doesn’t either. We don’t need to live up to an impossible standard.

Continue reading

How to Fix Chrome for Mac Broken Fonts

Mauro Dalu

ChromeFontBrokenIf your Google Chrome browser is acting awkward with fonts like in the picture (displays all “A” characters) instead of serif fonts or of all fonts, you may need to clean your Mac OS X Font Cache.

Here’s how to do it.

Continue reading

Surgeworks’ eCommerce team leader to open the Web: Startegy Conference in Zagreb, Croatia

Mauro Dalu

tomislav-opening-web-strategy-conference-in-zagrebTomislav Bilic will open the 7th edition of the Web Conference: Startegy in Zagreb, Croatia on March 18, 2010.

Web Conference: Strategy 7 – “Good developer spirit” includes educational lectures, directly and indirectly related to the web development thematic by lecturers who will educate participants on how to improve their knowledge and working environment in their company. The conference will be divided into development and technological issues, and will be the word on access to web development of experienced web professionals who will reveal some of their small business secrets. Also, as part of the conference will be held the ceremony of the Golden Web Award: Strategy.

Continue reading

We’re hiring! Ruby on Rails/Rhodes developer

Mauro Dalu

job-opening-hire-rails-rhodes-developerOffshore software developer position using Ruby on Rails and web technologies to build web applications for desktop browsers and targeting mobile devices. Also using Rhomobile to make native mobile applications.

Candidate should be a remote worker, must use an Intel Mac running OSX 10.5 or 10.6, should have strong communications skills, good written and spoken English. Availability on IM or Skype required during work hours.

Continue reading

Happy Holidays! :)

Mauro Dalu

Surgeworks-Happy-HolidaysDear friend,
Our global Surgeworks team prepared a greeting card for you. Click here to see it.

Merry Christmas and Happy New Year!

Continue reading

Google Chrome vs. Safari

Mauro Dalu

chrome-091208Everyone can finally download the public beta of Google Chrome for Mac. Many could think this is a piece of software that should only appeal to windows users, since they are the most subject to be unsatisfied by their Internet Explorer standard web experience, however there are reasons for you to try out Chrome even if you’re a happy Safari user.

At least, these are 3 reasons why I’ll try it out.

Continue reading