Migrating a Rails app from MySQL with Spatial Extensions to PostgreSQL with PostGIS

pThere#8217;s much documentation about converting a Rails app from MySQL to PostgreSQL (if you haven#8217;t written any SQL in your code, you can often just use a href="http://rubydoc.info/gems/taps"Taps/a), but very little about converting a Rails app (or any app, actually) from using MySQL Spatial Extensions to using PostGIS./p

pIn my case, I#8217;m working on a Rails 2.3.14 app using the a href="https://github.com/fragility/spatial_adapter"spatial_adapter/a, a href="https://github.com/imajes/geokit"geokit/a, a href="https://github.com/imajes/geokit-rails"geokit-rails/a and a href="https://

Using Jinja2 in Django with Coffin: The Easy Way

pThere is stronga lot/strong of old, incorrect and just plain bad documentation on how to use the a href="http://jinja.pocoo.org/docs/"Jinja2 templating language/a in a href="https://www.djangoproject.com/"Django/a.

CSS3 SCSS mixins

p class="gist"a href="http://gist.github.com/1545194"http://gist.github.com/1545194/a/pimg src="http://feeds.feedburner.com/~r/slashpoundbang/RQTZ/~4/2WdcHy-_bc4" height="1" width="1"/

Fix Facebook Like button for IE6 and IE7

pYou may have noticed in your server logs or analytics a significant number of requests to pages on your site with the query string code?fb_xd_fragment=/code. This behaviour is a symptom of the Facebook Like button working improperly in IE6 and IE7.

Google News Search parameters (The Missing Manual)

pThere is a severe lack of documentation of Google News Search#8217;s query parameters. Here is the most comprehensive list I am aware of. A number of these overlap with Google Search#8217;s query parameters. I exclude any Google Search parameters that don#8217;t make sense in the context of Google News Search. These parameters are primarily of interest to anyone querying Google News for articles using its RSS and Atom output formats./p


pThe following query parameters control Google#8217;s interpretation of keywords.

Google Refine fingerprint clustering algorithm in Ruby

pIf you#8217;ve used a href="http://code.google.com/p/google-refine/"Google Refine/a, you know how useful its clustering algorithms are for finding and merging alternative representations of the same thing, e.g. #8220;Gödel, Escher, Bach#8221;, #8220;Godel, Escher, Bach#8221; (accents), #8220;Gödel Escher Bach#8221; (punctuation), #8220;gödel, escher, bach#8221; (case)./p

pIn my open data and data journalism projects, I perform similar data consolidation and reconciliation steps to avoid unwanted duplicates.

Remove all accents and diacritics from string in Ruby

pAs a follow-up to a href="http://blog.slashpoundbang.com/post/12938588984/google-refine-fingerprint-clustering-algorithm-in-ruby"this post/a, if you want to remove all accents and diacritics from a text string in Ruby, while preserving case, use this snippet:/p

p class="gist"a href="http://gist.github.com/1374687"http://gist.github.com/1374687/a/pimg src="http://feeds.feedburner.com/~r/slashpoundbang/RQTZ/~4/PPoUlHCX8YI" height="1" width="1"/

Reserved methods in Rails

pI occasionally waste many hours debugging code that fails because I accidentally redefine a method inherited from a Rails class. For future reference:/p


ullia href="http://api.rubyonrails.org/classes/ActionMailer/MailHelper.html#method-i-message"message/a/li
/ulimg src="http://feeds.feedburner.com/~r/slashpoundbang/RQTZ/~4/xRDs9V1VOOs" height="1" width="1"/

How to cache an internationalized site with Rack::Cache in Rails 3

pI have bilingual and international websites that serve different translated content depending on the current locale. The current locale may be set according to the domain, subdomain, path, query string, or a cookie. If it is set according to a cookie, read on! If it is set using anything in the URL, Rails 3 (using Rack::Cache internally) will cache pages correctly for you./p

pNow, in my cookie-based site, I want to implement caching.

How to safely create friendly From addresses including name and email

pYou have a contact form that collects a person#8217;s name and email address. When sending their email, you want to get these two pieces of information from looking like this:/p

Name: John Doe
Email: john@example.com

pto this:/p

From: John Doe lt;john@example.comgt;


Reply-To: John Doe lt;john@example.comgt;

pIf you simple concatenate strings, then you will either send a malformed email or introduce a security risk.