Skip to content

Instantly share code, notes, and snippets.

@AMekss
AMekss / string.rb
Created October 9, 2012 10:56
String#normalize_encoding! for working with differently encoded strings in Ruby 1.9.3
# -*- encoding : utf-8 -*-
class String
# method always returns string with valid encoding which is equal to Encoding#default_internal
# handy for working with strings which encoding may differ (all kinds of imports and free text inputs)
def normalize_encoding!
return self unless !!defined?(Encoding) # apply for Ruby 1.9.3 only
encoding_equal_to_default_internal = (self.encoding == Encoding.default_internal)
# return unchanged if encoding is valid and equal to default_internal
@lucasallan
lucasallan / install_postgis_osx.sh
Created September 6, 2011 21:03 — forked from klebervirgilio/install_postgis_osx.sh
Installing PostGIS on Mac OS X and Ubuntu
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start