Skip to content

Instantly share code, notes, and snippets.

View diogopms's full-sized avatar
🏠
Working from home (🇵🇹)

Diogo Serrano diogopms

🏠
Working from home (🇵🇹)
View GitHub Profile
@diogopms
diogopms / videoinfo.js
Last active October 30, 2023 18:24
Get video information using ffprobe and url
var exec = require('child_process').exec
var url = 'https://URL'
var command =
'curl --silent ' + url + '| ffprobe pipe:0 -print_format json -show_format'
exec(command, function callback (error, stdout, stderr) {
if (stderr.indexOf('Invalid data') > -1) {
console.error('Error!')
}
@diogopms
diogopms / reboot_huawei_b593.md
Last active August 28, 2022 14:09
Reboot - Router huawei b593

Reboot - Router huawei b593

Login and save cookie

curl --cookie-jar cookies.txt 'http://192.168.1.1/index/login.cgi' -H 'Cookie: Language=en_us' --data 'Username=admin&Password=CHANGEME' --compressed

Read cookie and reboot request

@diogopms
diogopms / README.md
Created May 2, 2022 19:11 — forked from gjreasoner/README.md
Expand Ubuntu 20 Proxmox Disk
# Resize the file system in UI, under VM -> Hardware -> Click on the disk to resize, click "Resize disk" button

# Confirm increase in disk space (1TB in my case)
$ lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                         8:0    0    1T  0 disk
├─sda1                      8:1    0    1M  0 part
├─sda2                      8:2    0    1G  0 part /boot
└─sda3                      8:3    0    1T  0 part
@diogopms
diogopms / withings.md
Created October 20, 2019 20:30
Get temperature sensors from withings scale and CO2
curl --cookie-jar cookies.txt 'https://account.withings.com/connectionwou/account_login' --data 'email=<USERNAME>&password=<PASSWORD>' --compressed

curl  -b cookies.txt  'https://scalews.withings.com/cgi-bin/v2/measure' --data-binary 'action=getmeashf&meastype=35%2C12&deviceid=<DEVICE_ID>' --compressed
@diogopms
diogopms / homelab-planning.md
Last active December 31, 2021 13:57
Homelab planning

Homelab planning

Olá :)

ALGUÉM já fez o planeamento da eletricidade de uma CASA de origem ou com obras qual são as dicas que fizeram para o Prewire de uma casa com CAT6 (alarme com cabos network, tablets na parede, HDMI over Ethernet, cat6 no tecto para app, bastidor na garagem, homeassistant, shelly). Eu tenho alguns requisitos mas gostava de saber a vossa opinião especialmente na parte de HDMI over ehternet.

Eu vou tentar centralizar tudo num documento, mas a ideia era seria se ganhares o "euromilhões"

@diogopms
diogopms / list-constraints.sql
Created December 15, 2021 13:04 — forked from PickledDragon/list-constraints.sql
Postgres list all constraints
SELECT
tc.constraint_name, tc.table_name, kcu.column_name,
ccu.table_name AS foreign_table_name,
ccu.column_name AS foreign_column_name
FROM
information_schema.table_constraints AS tc
JOIN information_schema.key_column_usage AS kcu
ON tc.constraint_name = kcu.constraint_name
JOIN information_schema.constraint_column_usage AS ccu
ON ccu.constraint_name = tc.constraint_name
@diogopms
diogopms / homebrew-install-older-version.md
Created October 6, 2021 19:42
Homebrew: Install an older version of a formula

Homebrew: Install an older version of a formula

kubernetes-cli (v1.10.3) taken as example

  1. Downgrade Homebrew to the commit which upgrades the formula to the specific version that we want
$ cd "$(brew --repo homebrew/core)"
$ git log Formula/kubernetes-cli.rb

...
@diogopms
diogopms / gist:28d66c10de0e92a5cc20223bb89fde7d
Created February 25, 2021 19:41 — forked from nosuchuser/gist:3a67d06bb054273ef390d4a2ed4a5d89
Configuração Vodafone FTTH / pihole
1. Configurar IPv4 estático e IPv6 estático no pihole (YMMV)
192.168.1.2 e 2001:818:xxxx::192:168:1:2 no meu caso
2. Configurar DNS uplink do pihole igual ao IP do Router (192.168.1.1)
3. Configurar Router
Huawei HS8247W (Smart Router 2)
1. Configurações Avançadas -> LAN -> Configuração de DHCP
Servidor DNS Primário: 192.168.1.2
@diogopms
diogopms / README.md
Created February 4, 2021 07:53 — forked from qdm12/README.md
Wireguard and iptables restrictions for multiple users

Wireguard and iptables restrictions for multiple users

If you don't know what Wireguard is, well, you should. It's fast, easy to setup and highly configurable. We will configure Wireguard for multiple users with various restrictions using iptables.

Assumptions

This should fit most setups (not mine though 😉)

@diogopms
diogopms / delete-data-glacier.sh
Created January 28, 2021 12:27
delete all data from glacier
#!/usr/bin/env bash
file='./output.json'
id_file='./output-archive-ids.txt'
if [[ -z ${AWS_ACCOUNT_ID} ]] || [[ -z ${AWS_REGION} ]] || [[ -z ${AWS_VAULT_NAME} ]]; then
echo "Please set the following environment variables: "
echo "AWS_ACCOUNT_ID"
echo "AWS_REGION"
echo "AWS_VAULT_NAME"