Skip to content

Instantly share code, notes, and snippets.

View bergpb's full-sized avatar
💻
https://blog.bergpb.dev

Lindemberg Barbosa bergpb

💻
https://blog.bergpb.dev
View GitHub Profile
@bergpb
bergpb / golang_on_rpi.md
Created August 11, 2018 21:32 — forked from simoncos/golang_on_rpi.md
Install Golang 1.9 on Raspberry Pi

Install Golang 1.9:

wget https://storage.googleapis.com/golang/go1.9.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go1.9.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin # put into ~/.profile

If already installed old golang with apt-get:

@bergpb
bergpb / command.sh
Created August 15, 2018 13:24 — forked from metaskills/command.sh
Ubuntu 16.04 Install Latest FreeTDS
$ sudo apt-get install wget
$ sudo apt-get install build-essential
$ sudo apt-get install libc6-dev
$ wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.27.tar.gz
$ tar -xzf freetds-1.00.27.tar.gz
$ cd freetds-1.00.27
$ ./configure --prefix=/usr/local --with-tdsver=7.3
$ make
$ make install
@bergpb
bergpb / gist:28a6044ac2c51ecaa9e395c1dae34ff6
Created August 21, 2018 13:45 — forked from sarahhodne/gist:1341827
Use pry for rails console
# Launch Pry with access to the entire Rails stack.
# If you have Pry in your Gemfile, you can pass: ./script/console --irb=pry
# instead. If you don't, you can load it through the lines below :)
rails = File.join(Dir.getwd, 'config', 'environment.rb')
if File.exist?(rails) && ENV['SKIP_RAILS'].nil?
require rails
if Rails.version[0..0] == '2'
require 'console_app'
@bergpb
bergpb / index.md
Created August 23, 2018 11:19 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@bergpb
bergpb / gist:f98a2c8a6c7d471cbc9c9b0bc26e1017
Created September 21, 2018 02:49 — forked from thgaskell/gist:5987fccbd8473b5ef78f
Introduction to Sequelize Migrations

What are Migrations

Just like how we use Git to version control source code, we use migrations to manage the state of our database schemas.

I'm not really sure what that means...

Imagine you're working on project with another developer, and you're both tasked with creating a specific part of an event planning application. Let's say you are in charge of creating the Users and your friend is going to create the Events.

Let's say you and your friend divided the work in a way so that neither of you will have to to use each other's code to finish your tasks. While you're working on your part of the application, you only really need to touch the Users table when you are working with the database.

Before you begin

Make sure that the project you are in is a node project (it has a package.json) and you have already installed and initialized sequelize (npm install --save sequelize, sequelize init). Also make sure that your config.json file has the correct credentials to connect to your database.

@bergpb
bergpb / npm-list-globally.md
Created September 23, 2018 17:37 — forked from brenopolanski/npm-list-globally.md
Listing globally installed NPM packages and version
npm list -g --depth=0
@bergpb
bergpb / validacao+mascara.js
Created November 20, 2018 02:15 — forked from ricardodantas/validacao+mascara.js
Máscara e validação de RG, CNPJ, CPF, etc...
// JavaScript Document
//adiciona mascara de cnpj
function MascaraCNPJ(cnpj){
if(mascaraInteiro(cnpj)==false){
event.returnValue = false;
}
return formataCampo(cnpj, '00.000.000/0000-00', event);
}
//adiciona mascara de cep
@bergpb
bergpb / .pryrc
Created January 6, 2019 21:10 — forked from bespokoid/.pryrc
# === EDITOR ===
Pry.editor = 'vim'
# == Pry-Nav - Using pry as a debugger ==
Pry.commands.alias_command 'c', 'continue' rescue nil
Pry.commands.alias_command 's', 'step' rescue nil
Pry.commands.alias_command 'n', 'next' rescue nil
Pry.commands.alias_command 'r!', 'reload!' rescue nil
Pry.config.color = true
@bergpb
bergpb / create-ruby-gem.md
Created January 15, 2019 18:08 — 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!

@bergpb
bergpb / install-docker.sh
Created February 11, 2019 02:14 — forked from sethbergman/install-docker.sh
Install Docker CE on Linux Mint 19
#!/usr/bin/env bash
# https://docs.docker.com/install/linux/docker-ce/ubuntu/
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt-get update
sudo apt-get install docker-ce
# https://docs.docker.com/compose/install/