Skip to content

Instantly share code, notes, and snippets.

@gmmoreira
gmmoreira / script.sh
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 'https://youtube.com/watch?v=aaaaaa'
@gmmoreira
gmmoreira / commands.sh
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
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.
march=${1:-native}
mtune=${1:-native}
emacs_git_dir=emacs-pgtk-nativecomp
@gmmoreira
gmmoreira / install.sh
Last active November 1, 2022 15:05
Install Ruby 2.2.x, 2.3.x in Ubuntu 20.04
#!/bin/bash
set -e
# Usage
# ./install.sh # defaults to 2.3.8
# ./install.sh 2.3.3
# Explanation
# Ruby 2.3 or lower only support OpenSSL 1.0.
@gmmoreira
gmmoreira / openssl_certificate_chain.sh
Last active April 22, 2020 11:10
OpenSSL certificate chain
#!/bin/bash
# Original source: https://smartnets.wordpress.com/2017/04/27/create-certificate-chain-and-sign-certificates-using-openssl/
# 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)
end
def pay(paid_at = Time.now)
@gmmoreira
gmmoreira / bash.sh
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
# https://www.tecmint.com/configure-software-repositories-in-fedora/