Skip to content

Instantly share code, notes, and snippets.

View illiafox's full-sized avatar
🎀

Illia illiafox

🎀
View GitHub Profile
@illiafox
illiafox / promtail-docker-config.yaml
Last active March 1, 2025 10:02
Promtail Read Docker Logs
server:
http_listen_port: 10080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: "http://localhost:9428/insert/loki/api/v1/push"
scrape_configs:
- job_name: containers
docker_sd_configs:
@illiafox
illiafox / docker-postgres-backups.md
Created December 6, 2024 23:06
Postgres - Docker backups guide

Backup your databases

docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql

or dump only needed tables

docker exec -t your-db-container pg_dump -c -U test_user --table mytable1 --table mytable12 postgres > dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql
@illiafox
illiafox / main.c
Created December 6, 2024 21:48
lab 06
#include <stdio.h>
void bubbleSort(const int n, int** arr) {
int boundary = n - 1;
while (boundary > 0) {
int lastSwap = 0;
for (int i = 0; i < boundary; i++) {
if (arr[n-i][i] > arr[n-i][i + 1]) {
const int temp = arr[n-i][i];
@illiafox
illiafox / ufw-ssh-manual-fix.md
Created September 2, 2024 09:58
How to manually edit ufw to open ssh port

Problem: you enabled ufw on your RaspberryPi or OrangePi, but forgot to open the 22 port (rookie mistake)

Solution: manually edit ufw rules

  1. Eject sd card, connect it to your pc and mount into some directory
  2. Find /etc/ufw/user.rules
  3. Add these lines
### tuple ### allow any 22 0.0.0.0/0 any 0.0.0.0/0 in
-A ufw-user-input -p tcp --dport 22 -j ACCEPT
@illiafox
illiafox / run-arm-chroot-on-x86.md
Created September 2, 2024 06:36 — forked from gokart23/run-arm-chroot-on-x86.md
Run ARM chroot on x86 machine (both ArchLinux)

Steps

  1. Install qemu-user-static (yay -S qemu-user-static).
    • This might need you to install pcre-static and update PGP keys (follow the tips in the comments here).
  2. If not already present, install systemd-binfmt, the revamped version of binfmt-support tools
    • Your system has to support transparent Qemu user emulation, but fortunately, that is mostly enabled once the steps here have been followed.
  3. Check the status of the systemd-binfmt unit (systemctl status systemd-binfmt) and (re)start if needed (sudo systemctl restart systemd-binfmt)
    • This unit has ARM support by default, but check the current documentation to make install it if needed
  4. Mount the root partition of the ARM system into a folder (for e.g., sudo mount /dev/sdb2 arm_mountpoint)
  5. Copy the QEMU ARM static binary (/usr/bin/qemu-arm-static on my distro) to the mounted root directory's usr/bin
@illiafox
illiafox / cloudflare-opensuse.md
Created May 14, 2023 10:21 — forked from andikahilmy/cloudflare-opensuse.md
Make Cloudflare-WARP work on RPM-based systems other than RHEL-based distro

Install notes

  • For OpenSUSE, install the RPM package from CLoudflare for CentOS using zypper. When asked, type 2.
  • For Fedora, not tested yet

How to enable after installing

Copy warp-svc.service file to /etc/systemd/system/, then enable in systemd using this command:

package storages
import (
"context"
"math/rand"
"testing"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
"github.com/illiafox/saga-shop/api/apptrace"
func (s balanceStorage) ChangeBalance(ctx context.Context, userID int64, amount int64, desc string) error {
// acquire connection
c, err := s.pool.Acquire(ctx)
if err != nil {
return errors.NewInternal(err, "acquire connection")
}
defer c.Release()
// begin transaction
tx, err := c.Begin(ctx)