Skip to content

Instantly share code, notes, and snippets.


Berg Paulo bergpb

View GitHub Profile
bergpb / Program.cs
Created Aug 19, 2020
Outro exemplo de Extension Methods no C#
View Program.cs
using System
public class ProcessFile
public static void Main()
string s1 = "Good morning dear students";
bergpb / DateTimeExtensions.cs
Created Aug 19, 2020
Exemplo de Extension Methods in C#
View DateTimeExtensions.cs
using System.Globalization
namespace System
static class DateTimeExtensions
public static string ElapsedTime(this Datime thisObj)
TimeSpan duration = DateTime.Now.Subtract(thisObj);
bergpb / bitbucket-pipelines.yml
Created Aug 15, 2020 — forked from mcnamee/bitbucket-pipelines.yml
Bitbucket Pipelines - Deploy via FTP to shared hosting
View bitbucket-pipelines.yml
# Installation ---
# 1. In Bitbucket, add $FTP_USERNAME $FTP_PASSWORD and $FTP_HOST as environment variables.
# 2. Commit this file to your repo
# 3. From Bitbucket Cloud > Commits > Commit Number > Run Pipeline > Custom:Init (this will
# push everything and initial GitFTP)
# Usage ---
# - On each commit to master branch, it'll push all files to the $FTP_HOST
# - You also have the option to 'init' (from Bitbucket Cloud) - pushes everything and initialises
# - Finally you can also 'deploy-all' (from Bitbucket Cloud) - if multiple deploys fail, you
php -r "copy('', '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 /
Created Aug 11, 2020
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 / http_dolarhj.go
Created Jun 2, 2020
Scrapy de páginas com o a linguagem Go
View http_dolarhj.go
package main
import (
var coinsURL = []string{
bergpb / dolarhj-parse.go
Created Jun 1, 2020
Example to parse a string with Go
View dolarhj-parse.go
package main
import (
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 /
Last active May 20, 2020
Catching exceptions in python
a = 1
b = 'a'
a / b
except Exception as e:
print(f"Exception of type {type(e)} as ocurred: {e}")
bergpb / whatsappweb.user.js
Last active May 22, 2020
Tampermonkey script to turn on dark mode in whatsappweb based on current time
View whatsappweb.user.js
// ==UserScript==
// @name dark_mode_whatsappweb
// @namespace
// @version 0.2
// @description Activate dark mode in
// @author
// @match
// @grant none
// ==/UserScript==