Skip to content

Instantly share code, notes, and snippets.

View mvoto's full-sized avatar

Mauricio Voto mvoto

  • Port Coquitlam, BC
View GitHub Profile
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@mvoto
mvoto / gist:2a7ff1b6682b279764c6
Created July 29, 2014 13:28
Rails Active Record + Querying References
- Basic Guides(awesome reference):
http://guides.rubyonrails.org/active_record_querying.html
http://guides.rubyonrails.org/active_record_basics.html
- Short Screencast:
http://railscasts.com/episodes/202-active-record-queries-in-rails-3
- More complete guide:
http://www.theodinproject.com/ruby-on-rails#section-advanced-forms-and-active-record
http://www.theodinproject.com/ruby-on-rails/active-record-queries
@mvoto
mvoto / gist:3866cc1c137f533647ef
Created September 26, 2014 13:52
git_ignore_global
[user]
name = Mauricio Voto
email = mauriciovoto@gmail.com
[core]
excludesfile = /Users/mvoto/.gitignore_global
editor = /usr/bin/vim
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
RAILS_ENV=production rake db:setup
# produces the error below.....hmmm.....it's a no-worky
psql:/yourprojectpath/yourproject/db/structure.sql:29: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory
# hstore postgresql extension needs to be installed, so....
sudo apt-get install postgresql-contrib
# now your extension should be available to enable so log in with psql
psql -d yourproject_production -U yourdbuser -W
@mvoto
mvoto / gist:3d17d1bdcf1f2291a44a
Created April 16, 2015 19:56
dockerfile: base: ubuntu + nginx, rbenv and ruby 2.2.1
# Ubuntu as the base image
FROM ubuntu:trusty
# Install core tools
RUN apt-get -y update
RUN apt-get -y install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
# Install nginx
RUN apt-get -y install curl nginx
@mvoto
mvoto / bash_profile
Created August 30, 2011 19:14
user + path + rvm + git branch
#RVM
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
function ruby_version {
ruby -e '/(.*)\/(.*)/.match(`echo $GEM_HOME`);print ($2.nil? ? "" : $2)'
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
@mvoto
mvoto / gist:1596594
Created January 11, 2012 20:27 — forked from lucasallan/gist:1596363
Books
Current:
* Clean Code
* Crafting Rails Applications
Next:
* Domain-driven Design
* Design Patterns in Ruby
@mvoto
mvoto / will_paginate.rb
Created March 2, 2012 15:20 — forked from isaacbowen/will_paginate.rb
extends will_paginate to play well with Twitter's Bootstrap
# config/initializers/will_paginate.rb
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
@mvoto
mvoto / gist:2161722
Created March 22, 2012 18:50 — forked from klebervirgilio/gist:2161451
Array#by
class Array
def by(n)
buff, self_ = [], self.clone
if self.size % n == 0
(self.size/n).times{ buff << self_.shift(n) }
end
buff
end
function parse_git_branch {
 git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
 local        BLUE="\[\033[0;34m\]"
 local         RED="\[\033[0;31m\]"
 local   LIGHT_RED="\[\033[1;31m\]"
 local       GREEN="\[\033[0;32m\]"
 local LIGHT_GREEN="\[\033[1;32m\]"