Skip to content

Instantly share code, notes, and snippets.

View luizpicolo's full-sized avatar
👨‍🏫
Teaching

Luiz F. Picolo luizpicolo

👨‍🏫
Teaching
View GitHub Profile
@luizpicolo
luizpicolo / app.rb
Last active July 16, 2018 05:30 — forked from hendrikswan/app.rb
sample sinatra mongodb service
require 'sinatra'
require 'mongoid'
require 'json'
require "sinatra/reloader" if development?
Mongoid.load!("mongoid.yml")
class Price
include Mongoid::Document
@luizpicolo
luizpicolo / Capybara.md
Created July 17, 2017 13:22 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
This is what I would do to backup my old database and restore
To back up your database
pg_dump --format=c olddb_name > db_dump_file.dump
To restore that backup
pg_restore -v -d newdb_name db_dump_file.dump
Read more on pg_dump and pg_restore

YARD CHEATSHEET http://yardoc.org

cribbed from http://pastebin.com/xgzeAmBn

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.

Modules

Namespace for classes and modules that handle serving documentation over HTTP

# install pyhton via brew
brew install python3
# Install pip
# https://pip.pypa.io/en/stable/installing/
python3 get-pip.py
# install virtual env
pip install virtualenv
@luizpicolo
luizpicolo / model_extension.rb
Created January 4, 2017 13:28 — forked from brenes/model_extension.rb
Removing validation of a model declared on a gem
# We have to remove validations on email, as it's no longer needed.
# Based on a solution found at http://stackoverflow.com/questions/7545938/how-to-remove-validation-using-instance-eval-clause-in-rails
Model.class_eval do
_validators.reject!{ |key, _| key == :field }
_validate_callbacks.each do |callback|
callback.raw_filter.attributes.delete :field
end
# Alterar sequencia
ALTER SEQUENCE content_builders_id_seq RESTART WITH 37178;
@luizpicolo
luizpicolo / sign-pdf.rb
Created December 20, 2016 19:01 — forked from matiaskorhonen/sign-pdf.rb
Quick and dirty PDF signing in Ruby (using Origami)
#!/usr/bin/env ruby
require "openssl"
require "time"
begin
require "origami"
rescue LoadError
abort "origami not installed: gem install origami"
end
@luizpicolo
luizpicolo / gemproject.md
Created December 6, 2016 13:03 — forked from blackjk3/gemproject.md
Creating a gem project with rspec

** Create the plugin without test-unit and specify the path for the dummy application:

rails plugin new $project_name --skip-test-unit --dummy-path=spec/dummy --mountable

** Add rspec-rails as a development dependency to the gemspec file (foobar.gemspec):

Gem::Specification.new do |s|
sudo ls -1d */ | sudo xargs -I{} du {} -sh && sudo du -sh