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 / install_composer.sh
Created August 15, 2020 19:28
Install composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '572cb359b56ad9ae52f9c23d29d4b19a040af10d6635642e646a7caa7b96de717ce683bd797a92ce99e5929cc51e7d5f') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"
@bergpb
bergpb / send_fake_data.py
Created August 11, 2020 16:55
Send fake data to phishing web pages
import requests
import random
import string
from faker import Faker
from time import sleep
faker = Faker()
def get_random_alphanumeric_string(letters_count, digits_count):
sample_str = ''.join((random.choice(string.ascii_letters) for i in range(letters_count)))

Typing vagrant from the command line will display a list of all available commands.

Be sure that you are in the same directory as the Vagrantfile when running these commands!

Creating a VM

  • vagrant init -- Initialize Vagrant with a Vagrantfile and ./.vagrant directory, using no specified base image. Before you can do vagrant up, you'll need to specify a base image in the Vagrantfile.
  • vagrant init <boxpath> -- Initialize Vagrant with a specific box. To find a box, go to the public Vagrant box catalog. When you find one you like, just replace it's name with boxpath. For example, vagrant init ubuntu/trusty64.

Starting a VM

  • vagrant up -- starts vagrant environment (also provisions only on the FIRST vagrant up)
@bergpb
bergpb / http_dolarhj.go
Created June 2, 2020 19:16
Scrapy de páginas com o a linguagem Go
package main
import (
"fmt"
"log"
"github.com/anaskhan96/soup"
)
var coinsURL = []string{
@bergpb
bergpb / dolarhj-parse.go
Created June 1, 2020 03:18
Example to parse a string with Go
package main
import (
"fmt"
"strings"
)
var data string = `<p>O dólar hoje tá R$ 5,40<br/>O Bitcoin hoje tá R$ 51347,38</p><p></p><p>O dólar australiano hoje tá R$ 3,57<br/>O dólar canadense hoje tá R$ 3,92<br/>O dólar neozelandês hoje tá R$ 3,42<br/>O euro hoje tá R$ 5,98<br/>O franco suíço hoje tá R$ 5,60<br/>O real hoje tá 19,90 ienes<br/>A libra hoje tá R$ 6,66<br/>O novo sol hoje tá R$ 1,57<br/>O grama do ouro hoje tá R$ 295,83<br/>O peso argentino hoje tá R$ 0,07<br/>O real hoje tá 149,54 pesos chilenos<br/>O peso mexicano hoje tá R$ 0,17<br/>O peso uruguaio tá R$ 0,11<br/>O rublo russo hoje tá R$ 0,07<br/>O won sul-coreano hoje tá R$ 0,004366<br/>O yuan hoje tá R$ 0,75</p><p></p><p>O dólar turismo hoje tá R$ 5,59<br/>O euro turismo hoje tá R$ 6,22</p><p></p><p>O Aeternity hoje tá R$ 0,68<br/>A ARK hoje tá R$ 1,15<br/>O Basic Attention Token hoje tá R$ 1,12<br/>O Bitcoin Cash hoje tá R$ 1280,50<br/>O Bitcoin Diamond hoje tá R$ 3,05<br/>O Bitcoin Gold hoje tá R$ 49,13<br/>O Bitcoin SV hoje tá R$ 1020
@bergpb
bergpb / exception.py
Last active May 20, 2020 13:57
Catching exceptions in python
a = 1
b = 'a'
try:
a / b
except Exception as e:
print(f"Exception of type {type(e)} as ocurred: {e}")
@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==
@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 / 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 / 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