Skip to content

Instantly share code, notes, and snippets.

View brennovich's full-sized avatar
👋
Hey, there

Brenno Costa brennovich

👋
Hey, there
View GitHub Profile
@brennovich
brennovich / friendly_urls.markdown
Created October 9, 2012 00:22 — forked from agnellvj/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

@brennovich
brennovich / nginx.puma.conf
Created October 31, 2012 02:46 — forked from HuyaZhao/nginx.puma.conf
Nginx + Puma
upstream myapp {
server unix:///myapp/tmp/puma.sock;
}
server {
listen 80;
server_name myapp.com;
# ~2 seconds is often enough for most folks to parse HTML/CSS and
# retrieve needed images/icons/frames, connections are cheap in
@brennovich
brennovich / gist:4029010
Created November 7, 2012 01:38
Brennovich's oh-my-zsh theme
RPS1='%{$fg[red]%}`rbenv version | sed -e "s/ (set.*$//"`%{$reset_color%} $EPS1'
PROMPT='%{$fg[red]%}∷ %{$fg[cyan]%}%c %{$fg[blue]%}$(git_prompt_info)%{$fg[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%} %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}"
@brennovich
brennovich / gist:4062339
Created November 12, 2012 22:14
Project Euler
# Pretty Version!
n = 600_851_475_143
f = 2 # smallest prime factor
# Divide the big number by lowest prime factors to get the biggest one.
n % f == 0 ? n /= f : f += 1 while n > 1
puts f
# Ugly Version
def prime(factorized)
@brennovich
brennovich / pair
Created November 21, 2012 17:56 — forked from steveklabnik/pair
A ruby script to change pairs
#!/usr/bin/env ruby
def usage
puts "./pair [name]: pair two people"
puts "./pair : switch to just steve"
exit
end
def set_config(name, email)
`git config user.name "#{name}"`
module Devise
module Models
module RemoteAuthenticatable
extend ActiveSupport::Concern
#
# Here you do the request to the external webservice
#
# If the authentication is successful you should return
# a resource instance
@brennovich
brennovich / Instructions.markdown
Last active December 10, 2015 15:38
Setup your OSX Ruby development environment
// sizeSelectionModule and addToCartModule are local variables that
// act as shortcuts to their namespaces
describe("when add to cart form is submitted", function () {
var $form;
beforeEach(function () {
// We use div instead of form so we can just mock the submit behavior
$form = $("<div />");
});
# encoding: UTF-8
# pt-BR translations for Devise
pt-BR:
devise:
confirmations:
confirmed: 'Sua conta foi confirmada com sucesso. Você está logado.'
send_instructions: 'Dentro de minutos, você receberá um e-mail com instruções para a confirmação da sua conta.'
send_paranoid_instructions: 'Se o seu endereço de e-mail estiver cadastrado, você receberá uma mensagem com instruções para confirmação da sua conta.'
failure:
already_authenticated: 'Você já está logado.'
#
# This is a shell fragment that initializes rbenv, if it
# has not been inited yet. Managed by puppet - DO NOT EDIT
#
if ! echo $PATH | grep -q rbenv; then
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
fi