Skip to content

Instantly share code, notes, and snippets.

View dmitryrck's full-sized avatar

Dmitry L Rocha dmitryrck

View GitHub Profile
@dmitryrck
dmitryrck / nginx
Created December 28, 2011 18:26
/etc/init.d/nginx
#!/bin/bash
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx
### END INIT INFO
#!/bin/sh
NAME=$(basename $0)
dbprefix=${HOME}/Data/mongodb
mkdir -p "${dbprefix}/db" >/dev/null 2>/dev/null
repair() {
mongod --repair --dbpath ${dbprefix}/db
@dmitryrck
dmitryrck / gist:1973996
Created March 4, 2012 17:27
Run mongodb on ubuntu 11.10 x64
# Passos:
% wget -c http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.3.tgz
tar xfz mongodb-linux-x86_64-2.0.3.tgz
mkdir -p ${HOME}/db
./mongodb-linux-x86_64-2.0.3/bin/mongod run --dbpath ${HOME}/db
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'