Skip to content

Instantly share code, notes, and snippets.

View pedrogglima's full-sized avatar

Pedro Gabriel Lima pedrogglima

View GitHub Profile
@pedrogglima
pedrogglima / money_best_practices.md
Created March 10, 2022 15:51 — forked from abhinavmsra/money_best_practices.md
Tips for Money Related Arithmetic in Ruby

Tips for Money Related Arithmetic in Ruby

  1. Never use float for performing arithmetic calculations relating to money.

    Floating numbers can sometimes show funky behaviour. It is not Ruby’s fault but the very implementation of floating numbers raises precision issues.

Examples of odd behaviour:

@pedrogglima
pedrogglima / create-ruby-gem.md
Created June 10, 2021 22:36 — forked from kelvinst/create-ruby-gem.md
Como criar uma gem ruby?

Como criar uma gem ruby?

Escolhi tratar sobre esse assunto hoje simplesmente porque foi uma das primeiras coisas que me perguntei "como eu faço isso?" no mundo ruby. Acredito que muita gente se pergunte a mesma coisa e espero que eu possa ajudar em algo para elas. 😀

O que é uma gem?

Bem, se você é um programador java, você chama sua gem de jar, se você é um programador C#, você chama de dll. Resumindo, é uma lib, uma biblioteca contendo códigos que você pode reaproveitar importando em outros projetos.

E usar gems no ruby é muito fácil, se você já deu uma brincada com rails por exemplo, é só você adicionar o código gem 'nome_da_gem' no arquivo Gemfile que está no root, depois executar o comando bundle install para baixar sua gem do repositório e pronto, só sair usando a biblioteca!

@pedrogglima
pedrogglima / docker_clean.sh
Created April 13, 2021 20:22 — forked from rsignell-usgs/docker_clean.sh
Delete useless Docker image containers and volumes
#!/bin/bash
# from Kitware Jan 2017 newsletter
# remove dead and exited containers
docker ps --filter status=dead --filter status=exited -aq \
| xargs -r docker rm -v
# remove unused images
docker images --no-trunc | grep '<none>' \
| awk '{print $3 }' \
| xargs -r docker rmi
@pedrogglima
pedrogglima / Procfile
Created October 31, 2019 17:17 — forked from 0xjmp/Procfile
How to set up a Rails and Webpack app for fun and profit
api: sh -c "cd api && bundle exec rails s -p5000"
nginx: /usr/bin/nginx -c nginx.conf
client: sh -c "cd client && npm start"
@pedrogglima
pedrogglima / bootstrap-memo.md
Created June 10, 2019 20:57 — forked from yalab/bootstrap-memo.md
rails5 + webpacker + bootstrap
$ echo 'gem "webpacker"' >> Gemfile
$ bundle install
$ rails webpacker:install
$ yarn add bootstrap@4.0.0-beta jquery popper.js
diff --git a/config/webpack/environment.js b/config/webpack/environment.js
index d16d9af..86bf1a7 100644
@pedrogglima
pedrogglima / .gitignore
Created May 2, 2019 21:02 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@pedrogglima
pedrogglima / devise.pt-BR.yml
Created July 17, 2018 17:41 — forked from mateusg/devise.pt-BR.yml
pt-BR translations for Devise
# encoding: UTF-8
# pt-BR translations for Devise
pt-BR:
devise:
confirmations:
confirmed: "Sua conta foi confirmada com sucesso. Você está logado."
send_instructions: "Dentro de minutos, você receberá um e-mail com instruções para a confirmação da sua conta."
send_paranoid_instructions: "Se o seu endereço de e-mail estiver cadastrado, você receberá uma mensagem com instruções para confirmação da sua conta."
failure:
already_authenticated: "Você já está logado."
1. Gemfile
gem 'ckeditor', github: 'galetahub/ckeditor'
2. bundle install
3. app/assets/javascripts/application.js
//= require ckeditor/init
4. config/initializers/active_admin.rb
@pedrogglima
pedrogglima / Procfile
Last active June 26, 2018 14:19 — forked from czottmann/Procfile
Example of a Foreman/Capistrano/upstart setup
worker: QUEUE=* bundle exec rake environment resque:work
scheduler: bundle exec rake environment resque:scheduler

#Nginx Basics for Ubuntu

Please see http://wiki.nginx.org/Main for more information. See http://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/ for a tutorial on how to install Nginx.

##Installation To install, you can install the version which is in the standard Ubuntu repositories but it is normally quite old and will not have the latest security patches. The best way is to update the repositories first:

apt-get update
apt-get install python-software-properties

apt-get upgrade