Skip to content

Instantly share code, notes, and snippets.

View tulios's full-sized avatar

Túlio Ornelas tulios

View GitHub Profile
@tulios
tulios / path_to_resource_helper.rb
Created March 17, 2010 14:05
path_to_resource
module ApplicationHelper
def path_to_resource(source)
generate_path(source)
end
private
def generate_path(source)
has_request = @controller.respond_to?(:request)
@tulios
tulios / gist:703197
Created November 17, 2010 09:39
rails_logger_config
if RUBY_PLATFORM =~ /java/ and ENV['RAILS_ENV'] == 'production'
require 'java'
config.log_path = java.lang.System.getProperty('catalina.home') + '/logs/migrador_inep.log'
config.logger = Logger.new(config.log_path)
config.logger.level = Logger::INFO
end
@tulios
tulios / gist:703199
Created November 17, 2010 09:41
log_formatter
class LogFormatter
def call(severity, time, program_name, message)
datetime = time.strftime("%d/%m/%Y %H:%M:%S")
process = "rails[#{$PID}]"
hostname = Socket.gethostname.split('.')[0]
message = (String === message ?
message : message.inspect).gsub(/\n/, '').strip
"#{datetime} #{hostname} #{process}: #{message}\n"
end
end
@tulios
tulios / update_android_2.3
Created March 21, 2011 16:30
atualizando_nexus_s
Você não perde nada fazendo esses updates. Esses updates são apenas para o nexus S I9029T.
Para atualizar o android da 2.3.1 (confira a versão do seu) para a 2.3.3 siga os passos a seguir:
1 - Baixe o update 2.3.2 do site do google http://android.clients.google.com/packages/ota/google_crespo/353e267378cd.signed-soju-GRH78C-from-GRH78.353e2673.zip
1.1 - Copie o update para o cartão SD (não precisa renomear)
1.2 - Desligue o celular e religue segurando a tecla aumentar volume e o power
1.3 - Selecione recovery no bootloader
1.4 - Quando aparecer um triângulo aperte segure o botão de power e aperte o aumentar volume
1.5 - Escolha aplicar update a partir do cartão de memória
@tulios
tulios / build_nginx.sh
Created July 6, 2011 14:03
Script que baixa e compila o Nginx
#!/bin/bash
PCRE=pcre-8.12
NGINX=nginx-1.0.4
## DOWNLOADS
sudo curl -OL h ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/$PCRE.tar.gz > /usr/local/src/$PCRE.tar.gz
sudo curl -OL h http://nginx.org/download/$NGINX.tar.gz > /usr/local/src/$NGINX.tar.gz
## Install PCRE
@tulios
tulios / update_git_projects.rb
Created July 8, 2011 13:36
Atualiza todos os projetos git de um determinado diretório
#!/usr/bin/env ruby
#encoding: utf-8
require 'rubygems'
require 'terminal-display-colors'
projects_dir = File.expand_path(ARGV[0] || "~/Projetos")
puts "ProjectsDir: #{projects_dir}\n".blue
projects = Dir.new(projects_dir).entries.
@tulios
tulios / api-effect.js
Created July 27, 2011 17:52
Efeitos de fadeIn, fadeOut e fadeToogle em javascript puro
WM.Effect.FADE_TICK = 10;
WM.Effect.Exception = function(message) {
this.message = message;
};
/**
* Options:
* duration: int,
* maxFade: float (0 to 1) Default: 1
@tulios
tulios / fibonacci.rb
Created October 11, 2011 16:19
fibonacci
def fibonacci number
number <= 1 ? number : (fibonacci(number - 1) + fibonacci(number - 2))
end
@tulios
tulios / dotted_pagination_jquery_destaque.js
Created October 31, 2012 11:19
Dotted pagination for jquery.destaque
var destaque = $("#slide-container").destaque({
itemSelector: ".item",
itemBackgroundSelector: ".background",
itemForegroundElementSelector: ".foreground .element",
controlsSelector: "#slide-pagination a",
onPageUpdate: function(destaque, pageData) {
$(".indicator .bullet").removeClass("active");
$(".indicator .bullet[rel='"+ pageData.currentSlide +"']").addClass("active");
}
});
@tulios
tulios / css3_activation_jquery_destaque.css
Created November 1, 2012 16:17
CSS 3 activation for jquery.destaque
.item img, .item .foreground {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}