Skip to content

Instantly share code, notes, and snippets.

gmmoreira /
Created June 30, 2023 17:00
Download a full album from Youtube
yt-dlp -v --ignore-config --split-chapters -o 'chapter:%(title)s - %(section_number)02d - %(section_title)s.%(ext)s' -f bestaudio[ext=m4a] --extract-audio --embed-thumbnail ''
gmmoreira /
Last active February 16, 2023 13:14
avrdude commands for Pro Micro (ATMega32U4)
# Using bootloader
# To enter bootloader, connect the board to the computer and connect briefly the GND and RST pins.
# Some boards may require this connection to be done twice.
# When the bootloader is running, a virtual serial connection is created and so we can read/write to the device
# Checking connection and fuses
avrdude -c avr109 -p m32u4 -P /dev/ttyACM0 -n
# It should write something like the example below
# Connecting to programmer: .
gmmoreira / script.rb
Created September 29, 2021 20:48
Attach Watir (and Selenium) to an already running browser (Chrome)
# I had to automate a few tasks in my browser with my current logged session, but by default
# Selenium always starts a new session.
# After some research, the only way I found to attach Selenium to my running browser session
# was through the debugger address option.
# Start chrome with the command line option: google-chrome --remote-debugging-port=8181
# Then start selenium webdriver with the debug address option (I could only find the option
# in latest selenium-webdriver gem (v4.0))
require 'bundler/inline'
#!/usr/bin/env bash
set -euox pipefail
# Build Emacs 28 with GTK and native compilation.
# The pure GTK implementation enable native support in Wayland.
# Apt dependencies are for Ubuntu 20.04.
gmmoreira /
Last active November 1, 2022 15:05
Install Ruby 2.2.x, 2.3.x in Ubuntu 20.04
set -e
# Usage
# ./ # defaults to 2.3.8
# ./ 2.3.3
# Explanation
# Ruby 2.3 or lower only support OpenSSL 1.0.
gmmoreira /
Last active April 22, 2020 11:10
OpenSSL certificate chain
# Original source:
# RootCA.crt and IntermediateCA.crt must be manually trusted in the certificate store
# The Server.pfx is optional and can be imported directly in IIS certificates settings
# The Server.csr is optional
openssl genrsa -out RootCA.key 4096
openssl req -new -x509 -days 1826 -key RootCA.key -out RootCA.crt
openssl genrsa -out IntermediateCA.key 4096
class Payment
attr_reader :authorization_number, :amount, :invoice, :order, :payment_method, :paid_at
def initialize(attributes = {})
@authorization_number, @amount = attributes.values_at(:authorization_number, :amount)
@invoice, @order = attributes.values_at(:invoice, :order)
@payment_method = attributes.values_at(:payment_method)
def pay(paid_at =
gmmoreira /
Last active May 3, 2019 18:55
Arch useful commands
# Building Ruby 2.3.x
PKG_CONFIG_PATH=/usr/lib/openssl-1.0/pkgconfig asdf install ruby 2.3.8
# Fedora