Skip to content

Instantly share code, notes, and snippets.

👨‍🏫
Teaching

Luiz Picolo ツ luizpicolo

👨‍🏫
Teaching
Block or report user

Report or block luizpicolo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View .railsrc
# .railsrc
-B #Skip Bundle
-T #Skip Test-Unit
-d postgresql #Use postgres
@luizpicolo
luizpicolo / Exercicios5
Last active Aug 11, 2018 — forked from lrlucena/Exercicios5
Lista de Exercícios 5 da disciplina de Programação de Computadores
View Exercicios5
#encoding: utf-8
# Escreva um programa que leia um número e mostre se ele é igual a 10.
puts "Digite um número: "
x = gets.to_i
if x==10 then
puts "O valor digitado foi 10."
else
puts "O valor digitado não foi 10."
@luizpicolo
luizpicolo / app.rb
Last active Jul 16, 2018 — forked from hendrikswan/app.rb
sample sinatra mongodb service
View app.rb
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 Jul 17, 2017 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet
View Capybara.md

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
View yardoc_cheatsheet.md

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
@luizpicolo
luizpicolo / model_extension.rb
Created Jan 4, 2017 — forked from brenes/model_extension.rb
Removing validation of a model declared on a gem
View model_extension.rb
# 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
@luizpicolo
luizpicolo / sign-pdf.rb
Created Dec 20, 2016 — forked from matiaskorhonen/sign-pdf.rb
Quick and dirty PDF signing in Ruby (using Origami)
View sign-pdf.rb
#!/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 Dec 6, 2016 — forked from blackjk3/gemproject.md
Creating a gem project with rspec
View gemproject.md

** 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|
@luizpicolo
luizpicolo / install-docker.sh
Created Oct 13, 2016 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
View install-docker.sh
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# sudo apt-get -y install linux-image-extra-$(uname -r)
# Add Docker PPA and install latest version
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
View rails_admin_and_globalize3.md

RailsAdmin and Globalize3

I have a project where I need translated content. Therefore I use globalize3, wich stores its translated attributes in a seperate table that belongs to the original model. And I use RailsAdmin for painless record management.

It took me some time to figure out how to get those working together, but eventually I found a solution that is non invasive and still ok to work with.

The translated model

In my case there is a Snippet class. It holds content for static pages or text passages on the website. There is a good README for globalize3 for installation instructions and documentation.

You can’t perform that action at this time.