Skip to content

Instantly share code, notes, and snippets.

View spalenza's full-sized avatar

Rodolfo Spalenza spalenza

  • RDStation
  • Vitória - ES - Brazil
View GitHub Profile
@spalenza
spalenza / gist:4224200
Created December 6, 2012 12:44
Help with Rails

Generate model without test and assets

rails g model MODEL_NAME ATTRIBUTES --skip-test-framework --skip-assets

# 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
@spalenza
spalenza / gist:4511407
Last active December 10, 2015 23:39
Fix Duplicate or Old Item on "Open With..." List in Mac OSX

Run Command

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/\LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local\-domain system -domain user

Relaunch Finder

⌃ ⌥ CLick on Finder icon in the Dock

@spalenza
spalenza / define_method.rb
Created February 7, 2013 00:42
Ruby create methods with define_method
# normal
class Library
attr_accessor :games
def each(&block)
games.each(&block)
end
def map(&block)
games.map(&block)
ul.token-input-list-bootstrap {
cursor: text;
overflow: hidden;
height: auto !important;
margin: 0;
list-style-type: none;
border: 1px solid #cccccc; }
ul.token-input-list-bootstrap {
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
@spalenza
spalenza / ckeditor-fixes.js
Created January 24, 2014 12:58
CKEditor Solutions
// HTML special characters
$(document).ready(function() {
CKEDITOR.on('instanceReady', function(){
// liquidize_template é o nome da campo para o CKEditor
CKEDITOR.instances.liquidize_template.on('mode', function(ev) {
if (ev.editor.mode == 'source') {
var str = ev.editor.getData();
str = str.replace(/&/g, "&")
.replace(/>/g, ">")
.replace(/&lt;/g, "<")
@spalenza
spalenza / my.cnf
Last active January 4, 2016 16:59
brew mysql with thinking sphinx
# /etc/my.cnf
[mysqld]
sort_buffer_size = 512M
sort_buffer = 512M
innodb_file_per_table
[mysql]
default-character-set = utf8
@spalenza
spalenza / download.sh
Created May 25, 2014 14:30
Split and download files with wget
# Split string by '|'
IFS='|' read -a array <<< "strig"
# Download
for element in "${array[@]}"; do wget "$element"; done
@spalenza
spalenza / store_controller.rb
Created July 10, 2014 21:31
Access controller's methods in anywhere.
module StoreController
@@controllers = Hash.new
Finalizer = lambda { |id|
@@controllers.delete id
}
class << self
def set_controller(controller)
unless @@controllers.has_key?(Thread.current.object_id)