Skip to content

Instantly share code, notes, and snippets.

@jarthod
jarthod / server_benchmark.md
Last active January 6, 2024 10:05
Server benchmark

Results

Server Price* CPU (1 thread) CPU (4 threads) IO
Scaleway Start1-XS
Atom C3955, 25G NVMe
$4 21 sec
P₉₅ = 2.1ms
21 sec
P₉₅ = 14ms
🚗 653 IO/s, 10 Mb/sec
P₉₅ = 0.40ms
Scaleway VC1-S
Atom C2750, 50G SSD
$4 46 sec ⚠️
P₉₅ = 4.6ms
23 sec
P₉₅ = 14ms
🚲 289 IO/s, 4.5 Mb/sec
P₉₅ = 0.39ms
Hetzner CPX11
AMD EPYC, 40G SSD
$5 20 sec
P₉₅ = 3.2ms
9.6 sec
P₉₅ = 11ms
✈️ 3656 IO/s, 57 Mb/sec
P₉₅ = 0.29ms
Hetzner CX21
Intel Xeon, 40G SSD
$6 24 sec
P₉₅ = 2.8ms
12.5 sec
P₉₅ = 11ms
🚤 1946 IO/s, 30 Mb/sec
P₉₅ = 0.97ms
AWS t2.micro 1G*Intel E5-2676 v3 2.4
@jarthod
jarthod / ffmpeg_cheat_sheet.md
Last active December 28, 2023 16:36
ffmpeg cheat sheet

base encode to H265 (HEVC)

ffmpeg -i in.mts -c:a copy -c:v libx265 out.mp4

base encode to H264

ffmpeg -i in.mts -c:a copy -c:v h264 out.mp4

base encode to AV1 (lower cpu-used = slower)

@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 / browser-mockup.png
Last active October 31, 2022 09:23
Pure CSS browser mockups
browser-mockup.png
@jarthod
jarthod / compressed_hash.rb
Last active August 16, 2022 13:39 — forked from romanbsd/compressed.rb
Compressed fields in Mongoid 6.4+
require 'zstd-ruby'
class CompressedHash < Hash
DICTIONARY = IO.read('config/dictionaries/1')
def mongoize
if size > 0 # only compress non-empty hash
# BSON::Binary.new(Zstd.compress(self.to_bson.to_s))
BSON::Binary.new(Zstd.compress_using_dict(self.to_bson.to_s, DICTIONARY))
else
self
@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"

@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 / 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 / set_nf_conntrack_max.sh
Last active October 25, 2020 09:58
Fix synology DS414 nf_conntrack: table full issue
sudo cat /proc/sys/net/netfilter/nf_conntrack_max
echo 500000 | sudo tee /proc/sys/net/netfilter/nf_conntrack_max
sudo cat /proc/sys/net/netfilter/nf_conntrack_max