Skip to content

Instantly share code, notes, and snippets.

@deploy595
deploy595 / main.md
Last active June 8, 2025 06:53
Block all outgoing connections from inside a docker container except http(s) and smtp using firewalld (fixin' Hetzner netscan abuse)

Install, start and enable:

  apt install firewalld
  systemctl start firewalld 
  systemctl enable firewalld

Make sure the file /etc/docker/daemon.json does not contain this line. If it does, delete/comment it. If the file is missing, it is OK, you can skip the step:

{
@deploy595
deploy595 / Tickets.sql
Last active June 8, 2025 06:56
sql.sql
# Two SQL queries. One built using ActiveRecord, the other - manually assembled.
# Both return the same result.
# Each table has 500 thousand and a million records respectively (Ticket has many Messages).
# The first query works 10 times slower.
#
# 1) Active Record
# 130 rows retrieved starting from 1 in 645 ms (execution: 635 ms, fetching: 10 ms)
# 130 rows retrieved starting from 1 in 623 ms (execution: 611 ms, fetching: 12 ms)
# 130 rows retrieved starting from 1 in 640 ms (execution: 631 ms, fetching: 9 ms)