This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_fixtures(dirname) | |
sql = "SELECT * FROM %s" | |
skip_tables = ["schema_info"] | |
ActiveRecord::Base.establish_connection | |
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name| | |
extract_fixture_from table_name, "#{dirname}/#{table_name}.yml" | |
end | |
end | |
def extract_fixture_from(table_name, filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
helper :all # include all helpers, all the time | |
protect_from_forgery | |
private | |
def require_user | |
unless @current_user | |
store_location | |
flash[:notice] = "You must be logged in to access this page" | |
redirect_to login_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def p80(text = '') | |
p text | |
yield if block_given? | |
end | |
def remove_files_from(dir_name, subdir = true) | |
dir = Dir.new(dir_name) | |
dir.sort.each do |file_name| | |
unless file_name =~ /^\./ | |
file = "#{dir_name}/#{file_name}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
module Test | |
module Unit | |
module TestCase | |
def turn_public_methods(klass) | |
klass.class_eval do | |
private_instance_methods.each { |instance_method| public instance_method } | |
private_methods.each { |method| public_class_method method } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Say hi. Use USER environment variable as default" | |
task :hi, :user do |t, args| | |
args.with_defaults(:user => ENV["USER"]) | |
puts "Hi #{args[:user]}!" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
celestino@macbook:~/Projects/blog (master) | |
$ git log --pretty=oneline | |
0a49fcb771a39b7d3931c63a818de94eed5f10e8 limpando o README | |
245d8ce9d09c1645583e93e53896b638f664e6a2 ajustes no rake do rcov | |
be76c6dd3a155079e99195e0335382291653efa1 tarefas do rcov | |
8d7dc0a7b3832965f5fc021467ee44687df31a8e PostController publico | |
d34b775d33d0887109cd45848ef73a85fcbf0f9c Post com comentarios e comentarios de um post | |
3a510b83646bef7f1a9f69f9b7efc74a099589f9 substituindo fixtures por factories | |
7c1e5231858a8afbd409e3437fca80b88831e206 Movi os CRUDS de Post e Comentarios para admin | |
1d2ab7b0ceaf7257ff812791e06de72ef55d399a merge with branch "comments" <<== o erro está aqui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "benchmark" | |
params = {} | |
puts "with params = {}" | |
Benchmark.bm(16) do |x| | |
x.report("with if-inline: ") { 1_000_000.times { params[:page] ? params[:page].to_i : 1 } } | |
x.report("with max......: ") { 1_000_000.times { [params[:page].to_i, 1].max } } | |
x.report("with or.......: ") { 1_000_000.times { (params[:page] || 1).to_i } } | |
x.report("with fetch....: ") { 1_000_000.times { params.fetch(:page, 1).to_i } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dns - http://freedns.ws | |
google apps - http://google.com/a | |
yola, pra criar o site - http://www.yola.com/ | |
logonerds, logos por $50 - http://www.logonerds.com/ | |
wuffo, forms builder - http://wufoo.com/ | |
analytics, pra monitorar - http://www.google.com/analytics/ | |
blog (tumblr) | |
adwords |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Benchmark: !!(value) or (value == expected) | |
require 'benchmark' | |
n = 5000000 | |
value = :value | |
Benchmark.bm do |x| | |
x.report { p( !!(1 < 0 || 1 > 0) ) } | |
x.report { p( (1 < 0 || 1 > 0) == true ) } | |
x.report { p( !!(nil || value) ) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
BASE=/tmp | |
PID=$BASE/app.pid | |
LOG=$BASE/app.log | |
ERROR=$BASE/app-error.log | |
PORT=11211 | |
LISTEN_IP='0.0.0.0' | |
MEM_SIZE=4 |
OlderNewer