Skip to content

Instantly share code, notes, and snippets.

View manfe's full-sized avatar
🇧🇷

Mauricio N. Ferreira manfe

🇧🇷
View GitHub Profile
@manfe
manfe / _some_field.html.haml
Created September 11, 2012 20:24
Creating <optgroup> in select fields using simple_form
= f.association :cities, :collection => State.all, :as => :grouped_select,
:group_method => :cities, :group_label_method => :name
@manfe
manfe / alias
Created October 5, 2012 23:47
Git Status
git st
@manfe
manfe / database.yml
Created October 15, 2012 02:44
Postgres database.yml example
development:
adapter: postgresql
encoding: utf8
reconnect: false
host: localhost
database: database_development
username: username
password: password
test:
@manfe
manfe / script.rb
Created October 23, 2012 16:39
Recuperando Cidades de Estados Brasileiros do Site do IBGE
require 'nokogiri'
require 'htmlentities'
require 'open-uri'
estados = [ "ac", "al", "am", "ap", "ba", "ce", "df", "es", "go", "ma", "mg", "ms", "mt",
"pa", "pb", "pe", "pi", "pr", "rj", "rn", "ro", "rr", "rs", "sc", "se", "sp",
"to" ]
@result = Hash.new
@manfe
manfe / script.sh
Created October 24, 2012 19:59
Removing First 2 lines from file (Shell Command)
awk '{ if( NR > 2 ) { print } }' file > outputfile
@manfe
manfe / script.rb
Created October 28, 2012 18:22
Script to convert haml to textile
require 'haml'
require 'html2textile'
files = Dir["*"]
files.each do |f|
unless f == 'script.rb' || f == 'index.html.haml'
system("awk '{ if( NR > 2 ) { print } }' #{f} > #{f[0..-11] + '.temp'}") # remove first 2 lines
end
end
@manfe
manfe / dump.sql
Created October 29, 2012 19:27
Postgres - Estados e Cidades Brasileiras, dados extraídos do site do IBGE - SQL
-- Os dados contidos nesse arquivo foram extraídos do site: http://ibge.gov.br/cidadesat utilizando ruby, nokogiri e expressões regulares.
-- Autor: Mauricio Natanael Ferreira
-- Github: https://github.com/manfe
-- Twitter: @manfe01
-- Email: contato [at] ferreiramauricio [dot] com
-- ***********************************************************************************************************************************************
-- id ...
@manfe
manfe / estados_cidades_brasileiras.rb
Last active April 10, 2022 20:51
Recuperando as Cidades Brasileiras do Site do IBGE utilizando ruby
# encoding: utf-8
require 'rubygems'
require 'mysql2'
require 'pry'
require 'nokogiri'
require 'htmlentities'
require 'open-uri'
require 'active_record'
@manfe
manfe / index.html
Created May 21, 2013 19:36
Exemplo para processar um formulário de radio button e checkbox em PHP.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<form action="processarFormulario.php" method="GET">
<p>Blablabla pergunta.... blablabla</p>
@manfe
manfe / style.css
Created June 30, 2013 03:01
Exemplo de uso de seletores CSS
/* Todos os elementos H1 receberão os estilos que estiverem dentro das chaves. */
h1 {
text-align: center;
color: #BD1010;
}
/* Todos os parágrafos que estiverem com a classe ‘nome-da-classe’ receberão os estilos */
p.nome-da-classe {
color:#ABC;
}