Skip to content

Instantly share code, notes, and snippets.

View GabrielMMelo's full-sized avatar

Gabriel Melo GabrielMMelo

View GitHub Profile
@GabrielMMelo
GabrielMMelo / docker-pi
Last active May 12, 2021 14:53
Installing docker on raspberry 3
sudo apt-get update && sudo apt-get upgrade
sudo rpi-update
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker Pi
docker run hello-world
# to install docker-compose
sudo apt install -y libffi-dev libssl-dev
sudo pip3 -v install docker-compose
@GabrielMMelo
GabrielMMelo / wpa_linux.md
Last active October 19, 2020 14:05
Connect to WPA/WPA2 WiFi through Linux terminal

install requirements

sudo apt update
sudo apt install wpa_supplicant

get the interface name e check if it's up

iw dev
ip link show 
@GabrielMMelo
GabrielMMelo / getJusBrasilEmenta.js
Last active August 3, 2020 21:51
Copy "ementa" from JusBrasil
[].slice.call(document.getElementsByClassName("clipboardBoxTemp")).map(element => element.remove())
document.getElementsByClassName("btn btn--blue")[0].click();
let div = document.createElement('div')
let h3 = document.createElement('h3')
let ta = document.createElement('textarea');
div.style.textAlign = "center"
div.style.marginBottom = "30px"
div.classList.add("clipboardBoxTemp")
h3.textContent = "Ementa copiável ↓"
h3.style.marginBottom = '10px'
@GabrielMMelo
GabrielMMelo / dates_between.sql
Created July 28, 2020 11:22
Select that returns all dates between 2 dates
-- FROM here: https://stackoverflow.com/questions/7824831/generate-dates-between-date-ranges
DECLARE @StartDate DATE = '20110901'
, @EndDate DATE = '20111001'
SELECT DATEADD(DAY, nbr - 1, @StartDate)
FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY c.object_id ) AS Nbr
FROM sys.columns c
) nbrs
WHERE nbr - 1 <= DATEDIFF(DAY, @StartDate, @EndDate)
@GabrielMMelo
GabrielMMelo / last_row_column_vba.txt
Created July 17, 2020 16:16
Reliable way to get last used cell in Excel using vba
Dim rLastCell As Range
Set rLastCell = ws.Cells.Find(What:="*", After:=ws.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)
-- from stackoverflow (i miss the author)
SELECT
t.NAME AS TableName,
p.rows AS RowCounts,
CONVERT(DECIMAL,SUM(a.total_pages)) * 8 / 1024 / 1024 AS TotalSpaceGB,
SUM(a.used_pages) * 8 / 1024 / 1024 AS UsedSpaceGB ,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 / 1024 / 1024 AS UnusedSpaceGB
FROM
sys.tables t
INNER JOIN
@GabrielMMelo
GabrielMMelo / switch-eshop.md
Last active March 14, 2025 08:47 — forked from rynkis/switch-eshop.md
Nintendo Switch eShop API
@GabrielMMelo
GabrielMMelo / weird names
Created May 14, 2019 12:13
Approach to figure out the weird network interface names in Debian
sudo ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
reboot
@GabrielMMelo
GabrielMMelo / commands
Created May 12, 2019 14:46
A simple docker powered container management with load balancing with docker swarm and services
# Garanta que possua 3 máquinas acessíveis remotamente e que possuam docker instalado
@ 1# máquina
# inicializar o cluster (swarm), criar um manager e gerar token para worker
docker swarm init --advertise-addr <ADDRESS>
@ 2# e 3# máquina
# incluir um worker
docker swarm join --token <TOKEN> <ADDRESS>:<PORT>
@GabrielMMelo
GabrielMMelo / requester.py
Last active May 14, 2019 21:46
A simple script to send HTTP requests to test if a load balancing server is working properly
# -*- coding: utf-8 -*-
import sys
import requests
if len(sys.argv) != 4:
print("Missing arguments")
print("shape: script.py <IP> <PORT> <REQUESTS_COUNT>")
sys.exit(0)