Skip to content

Instantly share code, notes, and snippets.

@jarthod
jarthod / vat.rb
Last active April 26, 2022 19:35
EU VAT rates in ruby (2020) + online fetcher to verify/update rates.
module VAT
RATES = {
"AT" => 20.0,
"BE" => 21.0,
"BG" => 20.0,
"CY" => 19.0,
"CZ" => 21.0,
"DE" => 19.0,
"DK" => 25.0,
"EE" => 20.0,
@jarthod
jarthod / mongo_spy.rb
Created April 16, 2021 21:36
Ruby module (rspec) to count and assert number of mongo queries
# Examples:
#
# expect { code }.to change { finds("users") }.by(3)
# expect { code }.to change { updates("contents") }.by(1)
# expect { code }.not_to change { inserts }
#
# MongoSpy.flush
# ..code..
# expect(MongoSpy.queries).to match(
# "find" => { "users" => 1, "contents" => 1 },
@jarthod
jarthod / backup.md
Last active December 28, 2022 14:07
Linux backup cheat sheet

Prepare (Ubuntu 22.04 Live):

sudo su
apt install pv

Dump disk (or partition) to local file

zstd < /dev/nvme0n1 | pv > laptop.img.zst

Dump disk (or partition) to compressed image over network (NAS)

@jarthod
jarthod / RestRequest.inc.php
Created July 7, 2022 19:24
Quickly mute or unmute multiple checks in bulk using this small PHP page made by Eric Bouquerel from Bol d'Air (@Boldairdev)
<?php
class RestRequest
{
protected $url;
protected $verb;
protected $requestBody;
protected $requestLength;
protected $apiKey;
protected $username;
@jarthod
jarthod / website-dump.md
Created August 10, 2022 18:36
How to dump a website using wget

Example with wget:

wget --no-parent -rpk --wait=1 --random-wait https://wbsite.com/page

--no-parent prevents going up in the URLs --wait=1 --random-wait slows down request and add jitter to go easy on the server

If it needs a connected session:

--header="Cookie: session=xxxx"