Skip to content

Instantly share code, notes, and snippets.

View dmitryrck's full-sized avatar

Dmitry L Rocha dmitryrck

View GitHub Profile
require 'benchmark'
require File.dirname(__FILE__)+"/config/environment"
DEFAULT = 10_000
Benchmark.bm do |x|
x.report do
DEFAULT.times do |num|
Page.create :title => num, :content => num, :slug => num, :slug => num
end
# run ./beck.rb
require 'benchmark'
arr = []
10_000_000.times do |t|
arr.push t
end
class User < ActiveRecord::Base
has_many :things
end
class Thing < ActiveRecord::Base
validates :field_id, :uniqueness => { :scope => :user_id }
end
# Se vc for salvar um `user` com DENTRO DE UM NESTED FORM usando `things` ele vai gerar "falso positivo", ex.:
#
# Vi configuration from: https://github.com/skwp/dotfiles/blob/master/oh-my-zsh/themes/kylewest.zsh-theme
function zle-line-init zle-keymap-select {
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
bindkey -v
ZSH_THEME_VI_MODE_COMMAND="%{$fg_bold[magenta]%}<#%{$reset_color%}"
context "satanás" do
it "its you?" do
expect(satanas).to be_you
end
end
@dmitryrck
dmitryrck / poro.rb
Created December 20, 2012 17:34 — forked from romulostorel/poro.rb
class EnrollmentAcademicYearsCreator
def initialize(enrollment, enrollment_academic_year_storage = EnrollmentAcademicYear)
@enrollment = enrollment
@enrollment_academic_year_storage = enrollment_academic_year_storage
end
def create
enrollment_academic_year = @enrollment_academic_year_storage.create(
:enrollment => @enrollment,
:academic_year => @enrollment.academic_year,

Hello there! This is a sample post for gist.io, a super-lightweight writing soapbox for hackers.

Now look up. Further. Above the post title. See that grey text with the gist ID?

Now back to me. That grey text is a link! Open that sucker in a new tab to see the source for this post. Also, I'm on a horse.

This is a fork:

source 'http://rubygems.org'
server {
listen 81;
root /home/dmitry/project/public;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;

Parte 1: Instalar

Primeiro leia:

4.5 Ways to Install Ruby in Userspace.

Esse artigo apresenta quatro formas de instalar no espaço de usuário, escolha apenas um deles (ou mais se você souber o que está fazendo).

Caso ainda esteja na dúvida: use o RVM.