http://www.padrinorb.com/guides/adding-new-components#rendering-engine (a bit outdated)
Slim overview:
Helpers support
Gen Support
/* How to calculate postgreSQL database size in disk ? */ | |
SELECT pg_size_pretty(pg_database_size('thedbname')); | |
/* Calculate size of a table including or excluding the index */ | |
SELECT pg_size_pretty(pg_total_relation_size('big_table')); | |
SELECT pg_size_pretty(pg_relation_size('big_table')); /* without index */ | |
/* See indexes on a table with `\d tablename` */ |
# http://metaskills.net/2011/01/25/from-test-unit-shoulda-to-minitest-spec-minishoulda/ | |
# Gives you all the the stuff to make existing shoulda tests work! | |
class MiniTest::Spec | |
class << self | |
alias :setup :before unless defined?(Rails) | |
alias :teardown :after unless defined?(Rails) | |
alias :should :it | |
alias :context :describe | |
end | |
alias :assert_no_match :refute_match |
http://www.padrinorb.com/guides/adding-new-components#rendering-engine (a bit outdated)
Slim overview:
Helpers support
Gen Support
Using worker: staging:worker-2
$ git clone --depth=1000 --quiet git://github.com/padrino/padrino-framework.git ~/builds/padrino/padrino-framework
$ git checkout -qf 5e7f244de66bf412e5183b50827019d894eb6e4d
$ rvm use 1.9.2
Link: http://blog.therubymug.com/blog/2011/07/26/the-install-osx-lion.html
brew update && brew upgrade
rvm update --head rvm reload rvm repair all
gem pristine
Checkout RailsDevBoost:
# Gemfile
gem 'rails-dev-boost', :git => 'git://github.com/thedarkone/rails-dev-boost.git', :require => 'rails_development_boost', :branch => 'rails-2-3'
require 'benchmark' | |
haystack = (1..1_000_000).to_a | |
needles = 1.upto(100).map {|n| n * 10_000} | |
module EachDetector | |
def self.find(haystack, needle) | |
haystack.each do |v| | |
return true if v == needle | |
end |
class IndexUsersEmails < ActiveRecord::Migration | |
def self.up | |
execute "END" | |
add_pg_index :users, :email, :lock => false | |
execute "BEGIN" | |
end | |
end |
object @posts | |
attributes :id, :title, :created_at | |
child :user do | |
extends "users/show" | |
end |
require 'benchmark' | |
require 'active_support/all' | |
require 'httparty' | |
HOST = "http://listify-it.herokuapp.com" | |
def benchy(name, count=5) | |
result = Benchmark.realtime { count.times { HTTParty.get("#{HOST}/debug/#{name}") } } / count.to_f | |
"#{(result * 1000).round} ms average" | |
end |