Skip to content

Instantly share code, notes, and snippets.

View basmoura's full-sized avatar

Breno Moura basmoura

View GitHub Profile
[{"Name":"Afghanistan","Code":"AF"},{"Name":"Åland Islands","Code":"AX"},{"Name":"Albania","Code":"AL"},{"Name":"Algeria","Code":"DZ"},{"Name":"American Samoa","Code":"AS"},{"Name":"Andorra","Code":"AD"},{"Name":"Angola","Code":"AO"},{"Name":"Anguilla","Code":"AI"},{"Name":"Antarctica","Code":"AQ"},{"Name":"Antigua and Barbuda","Code":"AG"},{"Name":"Argentina","Code":"AR"},{"Name":"Armenia","Code":"AM"},{"Name":"Aruba","Code":"AW"},{"Name":"Australia","Code":"AU"},{"Name":"Austria","Code":"AT"},{"Name":"Azerbaijan","Code":"AZ"},{"Name":"Bahamas","Code":"BS"},{"Name":"Bahrain","Code":"BH"},{"Name":"Bangladesh","Code":"BD"},{"Name":"Barbados","Code":"BB"},{"Name":"Belarus","Code":"BY"},{"Name":"Belgium","Code":"BE"},{"Name":"Belize","Code":"BZ"},{"Name":"Benin","Code":"BJ"},{"Name":"Bermuda","Code":"BM"},{"Name":"Bhutan","Code":"BT"},{"Name":"Bolivia, Plurinational State of","Code":"BO"},{"Name":"Bonaire, Sint Eustatius and Saba","Code":"BQ"},{"Name":"Bosnia and Herzegovina","Code":"BA"},{"Name":"Botswana","Cod
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d DATABASE_NAME latest.dump
# rubocop:disable MethodLength
module HitsBarGraphHelper
def hits_bar_chart(data, options = {})
data_formated = [
{
name: 'Erros',
data: [['Questões', data[:incorrect]]]
},
{
name: 'Acertos',
@basmoura
basmoura / ntp.sh
Last active August 29, 2015 14:01
Configuração do ntp
# Configuração de data e hora no ubuntu server por Haroldo Furtado
# Digite
sudo dpkg-reconfigure tzdata
# É necessário utilizar o America/Maceio
# Verifique se o timezone está correto com o comando
cat /etc/timezone
# A resposta deverá ser America/Maceio
require 'open-uri'
def convert_json_to_object
emp_json = JSON.parse(open("json_url").read))
emp_json.each do |emp|
employee = Employee.new
employee[:name] = emp["name"]
employee[:cpf] = emp["cpf"]
employee[:email] = emp["email"]
employee.save
def self.check_cpf(cpf=nil)
return false if cpf.nil?
nulos = %w{12345678909 11111111111 22222222222 33333333333 44444444444 55555555555 66666666666 77777777777 88888888888 99999999999 00000000000}
valor = cpf.scan /[0-9]/
if valor.length == 11
unless nulos.member?(valor.join)
valor = valor.collect{|x| x.to_i}
soma = 10*valor[0]+9*valor[1]+8*valor[2]+7*valor[3]+6*valor[4]+5*valor[5]+4*valor[6]+3*valor[7]+2*valor[8]
soma = soma - (11 * (soma/11))
@basmoura
basmoura / floatnumber.rb
Last active August 29, 2015 14:00
Float Number
inicio = 0
print "Digite a quantidade de casas decimais: "
nr_casa = gets.chomp.to_f
div = (10**nr_casa)
soma = (1/div)
resultado = inicio/div
while resultado < 1 do
puts resultado.round(nr_casa)
resultado +=soma
end
@basmoura
basmoura / deploy.rb
Last active August 29, 2015 13:58
Deploy cfg with mina
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
set :user, 'ubuntu'
set :domain, 'example.com'
set :deploy_to, 'path'
set :repository, 'git repository url'
set :branch, 'master'
@basmoura
basmoura / VPS Config
Last active July 20, 2017 14:28
VPS Config
https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04
sudo apt-get update
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvmsudo /usr/bin/apt-get install build-essential nodejs openssl libcurl4-openssl-dev libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
@basmoura
basmoura / privacy-policy
Created September 20, 2013 16:33
Privacy Policy
Privacy Policy
Your privacy is very important to us. Accordingly, we have developed this Policy in order for you to understand how we collect, use, communicate and disclose and make use of personal information. Please be aware that the terms of this policy can be changed at any time at the sole discretion of Breno Moura. The following outlines our privacy policy:
* Before or at the time of collecting personal information, we will identify the purposes for which information is being collected.
* We will collect and use of personal information solely with the objective of fulfilling those purposes specified by us and for other compatible purposes, unless we obtain the consent of the individual concerned or as required by law.
* We will only retain personal information as long as necessary for the fulfillment of those purposes.
* We will collect personal information by lawful and fair means and, where appropriate, with the knowledge or consent of the individual concerned.
* Personal data should be relevant to