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 / attr_acessible_security.rb
Created March 5, 2012 14:15 — forked from rafaelp/attr_acessible_security.rb
How to protect against mass assignment attack
# Put this file on config/initializer
# This will create an empty whitelist of attributes available for mass assignment for
# all models in your app. As such, your models will need to explicitly whitelist
# accessible parameters by using an attr_accessible declaration. This technique is best
# applied at the start of a new project. However, for an existing project with a thorough
# set of functional tests, it should be straightforward and relatively quick to insert this
# initializer, run your tests, and expose each attribute (via attr_accessible) as dictated
# by your failing tests.
@brennovich
brennovich / config.ru
Created March 5, 2012 21:35
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
# We are not loading Active Record, nor the Assets Pipeline, etc.
# This could also be in your Gemfile.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
# The following lines should come as no surprise. Except by
@brennovich
brennovich / gist:1988798
Created March 6, 2012 20:31
Dump and Restore through Rails
bundle

sudo apt-get install mysql-server libmysql-ruby libmysqlclient-dev

rake db:data:dump RAILS_ENV=production -> Dump contents of Rails database to db/data.yml

Edit database.yml and run:

rake db:setup

.fc {
direction: ltr;
text-align: left; }
.fc table {
border-collapse: collapse;
border-spacing: 0; }
.fc .btn {
line-height: 1.2em; }
html .fc {
@brennovich
brennovich / gist:2974992
Created June 22, 2012 20:30
~/.tm-properties
exclude = "{*.{o,pyc},Icon\r,CVS,_darcs,_MTN,\{arch\},blib,*~.nib}"
include = "{.tm_properties,.htaccess}"
TM_HG = "/opt/local/bin/hg"
TM_GIT = "/usr/local/bin/git"
# Settings
theme = "Tomorrow"
fontName = "Menlo"
fontSize = 14
@brennovich
brennovich / capybara cheat sheet
Created September 15, 2012 20:49 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=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')
@brennovich
brennovich / gist:3744380
Created September 18, 2012 17:13
.vimrc.after
" Use UTF-8 without BOM
set encoding=utf-8 nobomb
" Highlight current line
set cursorline
" Add some line space for easy reading
set linespace=4
" Show “invisible” characters
@brennovich
brennovich / Custom.css
Created October 2, 2012 14:50 — forked from danro/Custom.css
Improved webkit inspector toolbar
#-webkit-web-inspector #toolbar {
background: #cdcdcd !important;
height: 36px !important;
}
#-webkit-web-inspector #main {
top: 36px !important;
}
#-webkit-web-inspector .toolbar-item.elements:hover:after {
content: "elements";
z-index: 9999;
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'awesome_nested_fields'
gem 'carrierwave'
gem 'fog'
gem 'jquery-rails'
gem 'pg'
gem 'responders'
@brennovich
brennovich / capybara cheat sheet
Created October 8, 2012 18:07 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=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')