Skip to content

Instantly share code, notes, and snippets.

class String
def to_slug
s = self.gsub(/&/, 'and') # replace ampersand chars with 'and' before stripping HTML
s.gsub!(/<.*?>/, '') # strip HTML
s.gsub!(/&/, 'and') # replace ampersand chars with 'and'
s = Iconv.iconv('ascii//ignore//translit', 'utf-8', s).to_s # Borrowed partially from Technoweenie's PermalinkFu
s.gsub!(/\W+/, ' ') # all non-word chars to spaces
s.strip!
s.downcase!
s.gsub!(/[\W^-_]+/, '-') # replace non-word chars with dashes
#!/bin/bash
BACKUP_DIR='/home/rsync/mysql_backup'
MHOST='localhost'
MUSER='root'
MPASS='yourpass'
NOW=$(date +"%Y-%m-%d_%H")
cat ~/.ssh/id_rsa.pub | ssh user@example.com 'cat >>.ssh/authorized_keys'
# source: http://www.enriquedelgado.com/articles/2007/04/25/interactive-ruby-console-tip-remember-the-last-x-commands-even-after-logging-out
# file: .irbrc
IRB.conf[:PROMPT_MODE] = :SIMPLE
require 'irb/completion'
IRB.conf[:AUTO_INDENT] = true
# Session History
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
alias cdd='cd ~/Development'
alias gst='git status'
alias gl='git pull'
alias gp='git push'
alias gd='git diff | mate'