Skip to content

Instantly share code, notes, and snippets.

View cassioscabral's full-sized avatar

Cassio Cabral cassioscabral

View GitHub Profile
@cassioscabral
cassioscabral / bash_prompt
Created October 2, 2013 18:54
bash_prompt # @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt” # Shamelessly copied from https://github.com/gf3/dotfiles
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
default_username='username'
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
@cassioscabral
cassioscabral / bashrc
Last active December 24, 2015 12:38
bashrc calling bash_prompt with custom setup showing current branch, short PS1 and colored fonts.
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
HISTFILESIZE=100000000
alias ll="ls -la"
alias rss="python manage.py runserver 0.0.0.0:8000"
export PS1="[\u@\w]\$: "
alias cg="cd ~/git/"
alias restart_nginx='/usr/local/Cellar/nginx/1.4.1/bin/nginx -s reload'
alias mysass='sass --watch --sourcemap'
. ~/.nvm/nvm.sh
// SASS variable overrides must be declared before loading up Active Admin's styles.
//
// To view the variables that Active Admin provides, take a look at
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the
// Active Admin source.
//
// For example, to change the sidebar width:
// $sidebar-width: 242px;
// Active Admin's got SASS!

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.

@cassioscabral
cassioscabral / gist:5510578
Created May 3, 2013 16:17
Simple example of inflections on Rails
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'noticia', 'noticias'
end