Skip to content

Instantly share code, notes, and snippets.

@ismarsantos
ismarsantos / __readme.md
Created December 6, 2017 01:07 — forked from maxivak/__readme.md
Tree with ancestry. Rails

Contents:

  • show full path for the item
  • show tree in ol li
  • show tree in dropdown select

Show full path for item

  • one item
@ismarsantos
ismarsantos / ubuntu_agnoster_install.md
Created December 6, 2017 15:47 — forked from renshuki/ubuntu_agnoster_install.md
Ubuntu 16.04 + Terminator + Oh My ZSH with Agnoster Theme

Install Terminator (shell)

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

Terminator should be setup as default now. Restart your terminal (shortcut: "Ctrl+Alt+T").

Install ZSH

@ismarsantos
ismarsantos / dokku_setup.md
Created December 18, 2017 05:57 — forked from joshteng/dokku_setup.md
Using Dokku to deploy a Rails Application

#Goal Deploy your Rails App super easily with Dokku on Digital Ocean cheap cheap!

##Notes

  • Follow 12 factor design (include the rails_12factor gem)
  • Don't forget your Procfile with the command to start up your application server
  • I prefer using external hosted logging services like Logentries (not in this guide)
  • Set up performance monitoring AppSignal or New Relic (not in this guide)
@ismarsantos
ismarsantos / application_helper.rb
Created January 5, 2018 18:18
Ruby on Rails. Class "active" for menu items based on Path or Controller and Action names
module ApplicationHelper
def active_for(options = {})
name_of_controller = options[:controller] || nil
name_of_action = options[:action] || nil
request_path = options[:path] || nil
if request_path.nil?
if (name_of_action.nil? or name_of_action == action_name) and
name_of_controller == controller_name
'active'
<fieldset>
<div class="form-inline" style="margin-bottom:10px;">
<div class="form-group">
<%= f.text_field "synonyms[value]", class: "form-control" %>
</div>
<div class="form-group">
<%= f.text_field "synonyms[synonyms]", class: "form-control", style: 'width: 300px;' %>
</div>
@ismarsantos
ismarsantos / 1. README.md
Created April 14, 2018 22:58 — forked from sauloarruda/1. README.md
Configurando aplicação Rails com Nginx e Unicorn

Configurando aplicação Rails com Nginx e Unicorn

TL;DR Como configurar uma aplicação Rails usando Nginx + Unicorn + Upstart + RVM (gemset por aplicação).

Dependências: (TODO) Configuração de Servidor Nginx

Essas instruções são aplicáveis para o seguinte ambiente:

  • Sistema Operacional: Ubuntu Server 12.04 beta2
  • Servidor: AWS EC2 usando ESB AMI: ubuntu/images-milestone/ebs/ubuntu-precise-12.04-beta2-amd64-server-20120328 (ami-b5ea34dc)
@ismarsantos
ismarsantos / generate-ssh-key.sh
Created May 14, 2018 20:06 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa
@ismarsantos
ismarsantos / prawn_io_image.rb
Created May 23, 2018 01:50 — forked from lappi-lynx/prawn_io_image.rb
Prawn PDF images with Base64 and StringIO
def render
pdf = Prawn::Document
pdf.image StringIO.new(Base64.decode64(splitBase64(BASE64_IMAGE_GOES_HERE)[:data])), at: [10, cursor - 50], width: 200, height: 125
end
def splitBase64(uri)
if uri.match(%r{^data:(.*?);(.*?),(.*)$})
return {
type: $1, # "image/png"
encoder: $2, # "base64"
@ismarsantos
ismarsantos / how_to_set_up_ssh_keys.md
Created June 5, 2018 23:20 — forked from stormpython/how_to_set_up_ssh_keys.md
Setting up ssh keys for remote server access

How to Set up SSH Keys

Create the RSA Key Pair

ssh-keygen -t rsa

Store the Keys and Passphrase

Once you have entered the Gen Key command, you will get a few more questions:

@ismarsantos
ismarsantos / moeda.rb
Last active June 6, 2018 23:14
Moeda em Rails migrações
Model:
create_table :products do |t|
...
t.decimal :price, :precision => 8, :scale => 2, :default => 0.0
...
end