Skip to content

Instantly share code, notes, and snippets.

View rtfpessoa's full-sized avatar

Rodrigo Fernandes rtfpessoa

View GitHub Profile
@rtfpessoa
rtfpessoa / nextdns.js
Last active January 14, 2024 02:05
nextdns.io Block Youtube Ads
// ID of the config, e.g. A1234BCD.
const configID = "A1234BCD";
// API key, found at the bottom of your account page in https://my.nextdns.io/account
const APIKey = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
// Mark true or false. If true, failed links will be retried 3 times at progressively increasing intervals.
// If false, failed links will not be retried.
const retryFailedLinks = true;
// Time delay between requests in milliseconds.
// 800 seems to not give any errors but is rather slow while anything faster will give errors (in limited testing).
// If you want to go lower, it is recommended that "retryFailedLinks" is true
@rtfpessoa
rtfpessoa / lazy-load-nvm.sh
Created August 26, 2016 11:42
NVM lazy loading script
#!/bin/bash
#
# NVM lazy loading script
#
# NVM takes on average half of a second to load, which is more than whole prezto takes to load.
# This can be noticed when you open a new shell.
# To avoid this, we are creating placeholder function
# for nvm, node, and all the node packages previously installed in the system
# to only load nvm when it is needed.
@rtfpessoa
rtfpessoa / getopts_long.sh
Created January 21, 2017 19:06
getopts_long -- POSIX shell getopts with GNU-style long option support
#!/usr/bin/env bash
#
# getopts_long -- POSIX shell getopts with GNU-style long option support
#
# Copyright 2005-2009 Stephane Chazelas <stephane_chazelas@yahoo.fr>
#
# Permission to use, copy, modify, distribute, and sell this software and
# its documentation for any purpose is hereby granted without fee, provided
# that the above copyright notice appear in all copies and that both that
@rtfpessoa
rtfpessoa / tvi-player-downloader.sh
Last active July 17, 2023 09:14
TVI Player Downloader
#!/usr/bin/env bash
set -eux
for SEASON_NUMBER in 1 2; do
for EPISODE_NUMBER in 1 2; do
EPISODE_URL="http://tviplayer.iol.pt/programa/pesadelo-na-cozinha/58bd77b50cf26a3bdcfca690/episodio/t${SEASON_NUMBER}e${EPISODE_NUMBER}"
PLAYLISTS_BY_QUALITY_URLS=$(curl -L $EPISODE_URL 2>/dev/null | grep 'vod/_definst_' | awk -F, '{print $3}' | sed -E 's/"videoUrl":"(.*)"/\1/')
youtube-dl -f best --audio-quality 0 -o pesadelo-na-cozinha-S01E0${EPISODE_NUMBER}.ts --prefer-ffmpeg $PLAYLISTS_BY_QUALITY_URLS &
@rtfpessoa
rtfpessoa / nvidia-shield-flash-recovery.sh
Created August 22, 2015 12:50
Nvidia Shield Recovery Script
#!/bin/bash
dir=$1
[[ -z dir ]] && echo "Missing bins dir!"
fastboot flash recovery {dir}/recovery.img
fastboot flash boot {dir}/boot.img
fastboot flash system {dir}/system.img
fastboot flash userdata {dir}/userdata.img
@rtfpessoa
rtfpessoa / handle-ctrl-c.py
Created March 19, 2016 11:28
Handle CTRL+C in Python
#!/usr/bin/env python
import signal
import sys
def signal_handler(signal, frame):
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
@rtfpessoa
rtfpessoa / openvpn-client-key-gen.sh
Last active April 16, 2022 19:25
OpenVPN Client Key Generator
#!/bin/bash
#
# OpenVPN Client Key Generation Script
#
# Author: rtfpessoa
# Date: 03-09-2016
#
# Based on the guide:
# * https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-16-04
@rtfpessoa
rtfpessoa / java-8-ami.md
Last active March 21, 2022 14:46
[Guide] Install Oracle Java (JDK) 8 on Amazon EC2 Ami
@rtfpessoa
rtfpessoa / covid-vaccine-scheduling-check.sh
Last active July 5, 2021 09:43
Verificação de disponibilidade para agendamento de vacina contra covid-19 (Portugal)
#!/usr/bin/env bash
while true
do
RESP="$(curl -fsS 'https://covid19.min-saude.pt/pedido-de-agendamento' \
-H 'Connection: keep-alive' \
-H 'Cache-Control: max-age=0' \
-H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'Origin: https://covid19.min-saude.pt' \
@rtfpessoa
rtfpessoa / estimate-costs.sh
Last active December 8, 2020 17:50
Estimate Terraform Costs
#!/usr/bin/env bash
# Runs https://github.com/antonbabenko/terraform-cost-estimation with sanitization
#
# Depends on:
# - terraform cli >= 0.12
# - curl
# - jq >= 1.6
set -eo pipefail