Skip to content

Instantly share code, notes, and snippets.

View bergpb's full-sized avatar
🏠
Working from home

Lindemberg Barbosa bergpb

🏠
Working from home
View GitHub Profile
@bergpb
bergpb / files.php
Last active February 28, 2020 14:51
laravel erro na validacao de um campo
##### form request
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class PessoaFormRequest extends FormRequest
{
/**
@bergpb
bergpb / cifra_de_cesar.py
Last active March 20, 2020 22:54
Cifra de César em Python
import string
from random import randint
texto_cifrado = ''
texto_original = ''
deslocamento = randint(1, 26)
alfabeto = list(string.ascii_lowercase)
print('Deslocamento igual a: {}'.format(deslocamento))
texto = input('Insira texto a ser cifrado, ou aperte enter para texto padrão: ')
@bergpb
bergpb / lines_in_file_into_list.py
Created March 28, 2020 04:31
Read a file line by line and put content into a list.
#file.txt
#1 2 3
#4 5 6
#7 8 9
with open('file.txt') as file:
content = file.readlines()
numbers = [line.strip().split(' ') for line in content]
print(numbers)
@bergpb
bergpb / secrets.md
Last active November 1, 2020 20:48
Generate secret key in python 3.6

Generate secret key in python +3.6

python -c "import secrets; print(secrets.token_hex(32))"
@bergpb
bergpb / state.py
Last active April 11, 2020 22:19
Gerenciamento de Estados com Python
# https://www.youtube.com/watch?v=QXorM9jsBNo
import time
class Main:
def __init__(self) -> None:
self.state = False
class Tv:
@bergpb
bergpb / sum-months.py
Last active April 16, 2020 00:14
Sum months in python, justpython.
import sys
month = sys.argv[1]
add = sys.argv[1]
def add_month(month, add):
next = month + add
if next >= 13:
return 1 if next-12 == 0 else next-12
return next
@bergpb
bergpb / how-to-use-pelican.md
Created April 22, 2020 15:16 — forked from JosefJezek/how-to-use-pelican.md
How to use Pelican on GitHub Pages
@bergpb
bergpb / vernan_cipher.py
Created April 24, 2020 22:29
Cifra de Vernan em Python
msg = "0 0 1 0 1 1 0 1 0 1 1 1"
pad = "1 0 0 1 1 1 0 0 1 0 1 1"
def str_to_list(itens: str) -> list:
"""Converte string para lista"""
return [int(i) for i in itens.split(" ")]
def list_to_str(itens: list) -> str:
@bergpb
bergpb / vernan_cipher_complete.py
Last active April 28, 2020 02:45
Cifra de Vernan em Python, entrada de texto pelo usuário.
import random
text = input('Entre com o texto a ser cifrado (ou aperte enter para texto padrão):')
if text == '':
text = "O rato roeu a roupa do rei de roma"
def xor(x: str, y: str) -> str:
@bergpb
bergpb / whatsappweb.user.js
Last active May 22, 2020 21:37
Tampermonkey script to turn on dark mode in whatsappweb based on current time
// ==UserScript==
// @name dark_mode_whatsappweb
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Activate dark mode in https://web.whatsapp.com/
// @author https://github.com/bergpb
// @match https://web.whatsapp.com
// @grant none
// ==/UserScript==