Skip to content

Instantly share code, notes, and snippets.

View henriquegogo's full-sized avatar

Henrique Gogó henriquegogo

View GitHub Profile
@henriquegogo
henriquegogo / .vimrc
Last active December 4, 2020 03:02
My .vimrc
" Made by @henriquegogo
" Script moved to https://github.com/henriquegogo/dotfiles
" I'll maintain this one just for compatibility with old references and history
au VimEnter * !wget https://raw.githubusercontent.com/henriquegogo/dotfiles/master/.vimrc -O ~/.vimrc
@henriquegogo
henriquegogo / devise.pt-BR.yml
Created February 15, 2011 19:38
Arquivo de tradução para a gem devise
pt-BR:
errors:
messages:
not_found: "não encontrado"
already_confirmed: "já foi confirmado"
not_locked: "não está bloqueado"
devise:
failure:
unauthenticated: 'Você precisa logar-se ou cadastrar-se antes de continuar.'
@henriquegogo
henriquegogo / quantidad_registros.rb
Created February 23, 2011 20:34
Exemplo de uma soma da quantidade de determinado registro num período
q=0;
r = Registro.find(:all, :conditions => ["created_at BETWEEN ? AND ?", Date.new(2010,6,1), Date.new(2010,7,1)])
r.each do |reg|
q = (q + reg.quantidade)
end
puts q
@henriquegogo
henriquegogo / parser.rb
Created March 2, 2011 12:21
Parser em Ruby usando o Nokogiri
require 'rubygems'
require 'nokogiri'
require 'open-uri'
click = Nokogiri::HTML(open('http://www.clickon.com.br/clickon-client-http-deal/Fortaleza'))
chuchu = Nokogiri::HTML(open('http://www.baratoprachuchu.com.br/'))
coletivo = Nokogiri::HTML(open('http://www.baratocoletivo.com.br/'))
puts 'Oferta do ClickOn: ' + click.css('.offer a')[0].content.strip() + ' Valor: ' + click.css('.price h2')[0].content.strip()
puts 'Oferta do Barato pra Chuchu: ' + chuchu.css('.tituloBanner h3')[0].content.strip() + ' Valor: R$' + chuchu.css('.comparacaoPrecos td:last')[0].content.strip()
@henriquegogo
henriquegogo / parser.py
Created March 2, 2011 12:22
Parser em Python usando o pyquery
from pyquery import PyQuery
import urllib
#peixe = PyQuery(urllib.urlopen('http://www.peixeurbano.com.br').read())
click = PyQuery(urllib.urlopen('http://www.clickon.com.br/clickon-client-http-deal/Fortaleza').read())
chuchu = PyQuery(urllib.urlopen('http://www.baratoprachuchu.com.br/').read())
coletivo = PyQuery(urllib.urlopen('http://www.baratocoletivo.com.br/').read())
#print 'Oferta do Peixe Urbano: ' + peixe('html').html()
print 'Oferta do ClickOn: ' + click('.offer a').html().strip() + ' Valor: ' + click('.price h2').html().strip()
@henriquegogo
henriquegogo / drum.sh
Last active December 9, 2015 17:58
Electronic Drums with Shell Script + SoX
#!/usr/bin/env sh
options='--multi-thread -q'
while read -n 1 -s key
do
case $key in
0) echo "Kick "; play $options kick.wav &;;
4 | 5) play $options hat.wav &;;
1 | 2) echo "Snare "; play $options snare.wav &;;
@henriquegogo
henriquegogo / sxcdown.py
Created March 3, 2011 12:01
Script que baixa todas as fotos do SXC
#!/usr/bin/env phyton
#-*- encoding: utf8 -*-
'''
Esse programa vai baixar todas as imagens do SXC
e construir um banco de dados com as TAGs de cada
imagem.
'''
import urllib
@henriquegogo
henriquegogo / hint.html
Created March 15, 2011 18:59
Mostra uma hint "help" quando passa pelo input
<script>
function ajuda(qual, msg) {
var ajudante = document.getElementById("ajudante");
ajudante.style.display = "block";
ajudante.style.top = (qual.offsetTop - 26);
ajudante.style.left = qual.offsetLeft;
ajudante.innerHTML = msg;
}
</script>
@henriquegogo
henriquegogo / delete-rails.js
Created March 16, 2011 13:22
Função delete do rails em jQuery
$('a[data-method="delete"]').click(function(event) {
csrf_param = $('meta[name=csrf-param]').attr('content');
csrf_token = $('meta[name=csrf-token]').attr('content');
if (confirm($(this).attr("data-confirm"))) {
var attr = {};
attr['_method'] = 'delete';
attr[csrf_param] = csrf_token;
$.post(this.href, attr, function() { location.reload(true) }, "script");
}
return false;
@henriquegogo
henriquegogo / easyRoutes.js
Last active December 27, 2018 04:37
Easy routes with javascript and hash
(function() {
var Router = function(routes) {
var hash;
var splitParams = function() {
for (route in routes) {
var routeRegex = "^" + route.replace(/:([A-z0-9_-]*)/g, "([A-z0-9_-]*)") + "(/?)$";
var callRoute = routes[route];
var matches = new RegExp(routeRegex).exec(hash);