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 / 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 / double_of_odds.py
Last active December 20, 2018 11:02
Python list comprehensions.
# example to use list comprehensions with python, the pythonic mode.
def double_of_odds(list):
return [x*2 for x in list if x%2]
list = [1,2,3,4,5,6,7,8,9,10]
double_of_odds(list)
# out: [2, 6, 10, 14, 18]
@bergpb
bergpb / double_of_odds_dict.py
Last active December 20, 2018 11:02
Python dict comprehensions.
# dict comprehensions
list = [1,2,3,4,5,6,7,8,9,10]
doubles_of_odds_dict = {'number_'+str(i):i*2 for i in list if i%2}
doubles_of_odds_dict
# out: {'number_1': 2, 'number_3': 6, 'number_5': 10, 'number_7': 14, 'number_9': 18}
@bergpb
bergpb / show_name_and_age.py
Created December 20, 2018 11:01
Python args and kwargs usage.
show_name_and_age(*args, **kwargs):
for name in args:
print('My name is: {}'.format(name))
for name in kwargs.keys():
print('{} has {} years old.'.format(name, kwargs[name]))
show_name_and_age('Josh', 'Hannah', Josh=19, Hannah=26)
# out
# My name is: Josh
# My name is: Hannah
# Hannah has 26 years old.
@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 / angucomplete-alt.js
Created January 23, 2019 16:59
Angucomplete-Alt with electron apps.
/*
* angucomplete-alt
* Autocomplete directive for AngularJS
* This is a fork of Daryl Rowland's angucomplete with some extra features.
* By Hidenari Nozaki
*/
/*! Copyright (c) 2014 Hidenari Nozaki and contributors | Licensed under the MIT license */
(function () {
@bergpb
bergpb / angularjs-helloworld.html
Last active February 9, 2019 12:34
Just a simple Hello World writed in Angular.
<html>
<head>
<meta charset="utf-8">
<title>Simple AngularJS App</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="app.js"></script>
</head>
<body ng-app="nameApp">
<div ng-controller="NameCtrl" class="container">
@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/