Skip to content

Instantly share code, notes, and snippets.

View obrodinho's full-sized avatar

Rafael "Brodinho" Guimarães obrodinho

View GitHub Profile
@ritog
ritog / alacritty.toml
Created October 6, 2023 10:58
Example configuration file for Alacritty and simple guide
# $HOME/.config/alacritty/alacritty.toml
# by Rito Ghosh 2023-10-06
# Alacritty now uses TOML formatting for its config files.
# This is a simple example.
# There are the specification here: https://github.com/alacritty/alacritty/blob/master/extra/man/alacritty.5.scd
# It is not obvious how it translates to TOML. But it is extremely straightforward.
# example: WINDOW, COLORS, etc. are tables, and should be represented as [window], [colors], respectively.
@PhilipWee
PhilipWee / debounce-hook.ts
Last active December 25, 2023 02:24
A simple typescript hook for debouncing functions
import { useRef, useEffect } from "react";
type Timer = ReturnType<typeof setTimeout>;
type SomeFunction = (...args: any[]) => void;
/**
*
* @param func The original, non debounced function (You can pass any number of args to it)
* @param delay The delay (in ms) for the function to return
* @returns The debounced function, which will run only if the debounced function has not been called in the last (delay) ms
*/
@wlonkly
wlonkly / debugging.md
Last active July 8, 2021 15:13
Steps I took to troubleshoot a full disk

I wrote this down after I responded to a page today (a holiday) because it would've been a decent pairing opportunity for a couple of new people on my team. Second best is that people can read what I did afterwards and ask me any questions. And then I realized that there's nothing PagerDuty-specific or confidential in here, so I may as well share it wider. It's hardly an epic incident, but it's a good example of "doing the work", I think. I borrowed the "write down what you learned" approach from Julia "b0rk" Evans. It's a fantastic practice.

The PagerDuty incident: "Disk will be full in 12 hours. device:/dev/nvme0n1p1, host:stg-nomadusw2-client-..."

(Note for non-PD readers: We run Nomad where others might run Kubernetes.)

Here's the process I went through.

  • Noticed that the usual docker system prune -a -f didn't resolve it
  • Tried docker system prune -a -f and it cleared up 0B
@aanari
aanari / set-alacritty-default.sh
Last active April 29, 2024 16:28
Set Alacritty as Default Terminal Editor (Ubuntu)
sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator $(which alacritty) 50
sudo update-alternatives --config x-terminal-emulator
@bszwej
bszwej / echo.js
Last active April 26, 2024 05:22
Pure Node.js echo server, that logs all incoming http requests (method, path, headers, body).
const http = require('http');
const server = http.createServer();
server.on('request', (request, response) => {
let body = [];
request.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
#!/bin/bash
url="https://gist.githubusercontent.com/RichardBronosky/2d04c7c2e9a5bea67cd9760a35415a3f/raw/install_mongo.sh"
script="/tmp/userdata.sh"
echo "Running userdata script as $(whoami) from $(pwd)"
# Log commands to stdout and vicariously /var/log/cloud-init-output.log
set -o xtrace
# Exit on error
@chris-jamieson
chris-jamieson / setup.md
Created April 19, 2016 15:43
Set up Franz for Ubuntu
  • Download Franz for your distribution from MeetFranz.com
  • change into the same directory as the downloaded file, then sudo tar -xf Franz-linux-x64-0.9.10.tgz -C /opt/franz
  • (optional) wget "https://cdn-images-1.medium.com/max/360/1*v86tTomtFZIdqzMNpvwIZw.png" -O franz-icon.png then sudo cp franz-icon.png /opt/franz
  • (optional) sudo touch /usr/share/applications/franz.desktop then sudo vim /usr/share/applications/franz.desktop

paste the following lines into the file, then save the file:

[Desktop Entry]
Name=Franz
Comment=
@julz
julz / main.go
Created November 20, 2015 12:39
containersched minicontainer
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
)
func main() {
@fjmk
fjmk / README.md
Last active October 5, 2016 13:01
Howto use dnsdock in Ubuntu 14.04 trusty

Howto use dnsdock in Ubuntu 14.04 trusty

Using dnsdock resolves the problem of the changing IP's of containers. It is much easier to start a named container and use dns on the host to access the container simply by its name.

patch your /etc/ files so NetworkManager's dnsmasq to use the dnsdock nameserver.

sudo su -
cd
wget https://gist.githubusercontent.com/fjmk/a2bc6f9e01df9966c17b/raw/ad58b0823271e2f448df21f8a2226b719dec9353/etc-dnsdock.patch
cd /etc
@paulopatto
paulopatto / README.md
Last active January 18, 2024 23:57
Converter taxa de cambio entre Moedas com Google SpreadSheet

Cotação de moedas com Planilhas do Google SpreadSheet

Hoje enquanto eu tentava criar minha calculadora de importação de produtos (com tributos, Taxa ilegal de processamento de encomendas internacionais e IOF). Com isso precisava de dados de conversão autmática de valores em Dollar americano para o Real brasileiro (USD -> BRL). A melhor solução que encontrei foi efetuar a pesquisa de cotação na url do google finance convert em https://www.google.com/finance/converter?a=1&from=USD&to=BRL. Bem tendo a url que nos retorna um documento HTML vamos pegar o dados com a função IMPORTXML

ImportXML(url; xpath query)

Importa dados de qualquer um dos vários tipos de dados estruturados, incluindo XML, HTML, CSV, TSV e XML de feeds RSS e Atom.

Com isso tenho o resultado como texto, ai tive de converter a planilha para formatação U.S.A para usar ponto como separador decimal e usar a formula de regex [0-9]*\.[0-9]+[0-9]+para extrair apenas o valor numérico. Minha formula completa