Skip to content

Instantly share code, notes, and snippets.

View tulios's full-sized avatar

Túlio Ornelas tulios

View GitHub Profile
@tulios
tulios / helper.rb
Created April 26, 2014 05:01
asset_pipeline_force_debug_false_only_some_manifest
# Helper that use the same logic as javascript_include_tag ensuring body=0 for the manifests
# Usage: <%= always_no_debug_javascript_include_tag 'manifest' %>
#
def always_no_debug_javascript_include_tag *sources
options = sources.extract_options!.stringify_keys
path_options = options.extract!('protocol').symbolize_keys
sources.uniq.map {|source|
path = path_to_javascript(source, path_options)
path.gsub!(/\?body=1/, "?body=0") if path =~ /\?body=1$/
@tulios
tulios / server_side_reactjs_with_state.js
Created February 3, 2015 20:19
Server side ReactJS with state
var Promise = require('promise');
var React = require('react/addons');
var Router = require('react-router');
var App = buildRequire('app-server-bundle');
var parseAssetManifest = appServerRequire('utils/parse-asset-manifest');
var assetManifest = parseAssetManifest(App.Settings.ASSET_HOST);
function fetchData(routes, done) {
@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