Skip to content

Instantly share code, notes, and snippets.

View fgbreel's full-sized avatar
🦆

Gabriel Francisco fgbreel

🦆
  • Berlin
View GitHub Profile
@fgbreel
fgbreel / mount_qcow2.md
Created November 5, 2025 00:00 — forked from shamil/mount_qcow2.md
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8
@fgbreel
fgbreel / NVMe_tweaks.md
Created November 4, 2025 23:58 — forked from v-fox/NVMe_tweaks.md
Linux kernel optimizations for NVMe

By default Linux distros are unoptimized in terms of I/O latency. So, here are some tips to improve that.

Most apps still don't do multi-threaded I/O access, so it's a thread-per-app which makes per-app speed always bottlenecked by single-core CPU performance (that's not even accounting for stuttering on contention between multiple processes), so even with NVMe capable of 3-6 GB/s of linear read you may get only 1-2 GB/s with ideal settings and 50-150/100-400 MB/s of un/buffered random read (what apps actually use in real life) is the best you can hope for.

All writes are heavily buffered on 3 layers (OS' RAM cache, device's RAM cache, device's SLC-like on-NAND cache), so it's difficult to get real or stable numbers but writes are largelly irrelevant for system's responsiveness, so they may be sacrificed for better random reads.

The performance can be checked by:

  • `fio --name=read --readonly --rw={read/randread} --ioengine=libaio --iodepth={jobs_per_each_worker's_command} --bs={4k/2M} --direct={0/1} --num
@fgbreel
fgbreel / copy_firmware
Created June 14, 2025 12:12
/etc/initramfs-tools/hooks
#!/bin/sh -e
if [ "$1" = "prereqs" ]; then exit 0; fi
. /usr/share/initramfs-tools/hook-functions
cp /lib/firmware/adsp.* $DESTDIR/lib/firmware/
// This DTS overlay sets up one input and one output pin for use by
// PRU0 via its Enhanced GPIO mode, which will let us access those pins
// by writing to R30 bit 15 or reading from R31 bit 14.
// Save this file wherever you want (but I recommend /lib/firmware), as
// "PRU-GPIO-EXAMPLE-00A0.dts".
// Compile with:
// dtc -O dtb -I dts -o /lib/firmware/PRU-GPIO-EXAMPLE-00A0.dtbo -b 0 -@ PRU-GPIO-EXAMPLE-00A0.dts
@fgbreel
fgbreel / download-and-update-local-repository.sh
Created March 31, 2022 17:06
Download installed packages and generate local debian repository.
#!/bin/bash
# download installed packages and generate local debian repository
# this command can make your computer very busy! watch out!
dpkg -l | tail -n +5 | awk '{print $2}' | while read line; do (apt download $line -t sid &); done && dpkg-scanpackages ./ > Packages && gzip -k -f Packages
@fgbreel
fgbreel / default.vcl_PREFACE.md
Created November 1, 2021 10:04 — forked from fevangelou/default.vcl_PREFACE.md
The perfect Varnish configuration for Joomla, WordPress & other CMS based websites

The perfect Varnish configuration for Joomla, WordPress & other CMS based websites

IMPORTANT: Read this before implementing one of the configuration files below (for either Varnish 3.x or 4.x+).

USE: Replace the contents of the main Varnish configuration file located in /etc/varnish/default.vcl (root server access required - obviously) with the contents of the configuration you'll use (depending on your Varnish version) from the 2 examples provided below.

IMPORTANT: The following setup assumes a 180 sec (3 minute) cache time for cacheable content that does not have the correct cache-control HTTP headers. You can safely increase this to 300 sec (or more) for less busier sites or drop it to 60 sec or even 30 sec for high traffic sites.

This configuration requires an HTTP Header and a user cookie to identify if a user is logged in a site, in order to bypass caching overall (see how it's done for Joomla & WordPress). If your CMS provides a way to add these two requirements, then you can use this configurati

@fgbreel
fgbreel / jenkins-ssh-decrypt.py
Created March 12, 2021 10:15 — forked from khramtsoff/jenkins-ssh-decrypt.py
Decrypt jenkins ssh hashes
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# original: https://raw.githubusercontent.com/tweksteen/jenkins-decrypt/master/decrypt.py
# detailed explanation: http://thiébaud.fr/jenkins_credentials.html
import re
import sys
import base64
from hashlib import sha256
from binascii import hexlify, unhexlify
@fgbreel
fgbreel / create_admin_user.sh
Last active March 1, 2021 10:04 — forked from steimntz/create_user_for_namespace.sh
Script to create admin user.
#!/bin/bash
#
# Script based on https://jeremievallee.com/2018/05/28/kubernetes-rbac-namespace-user.html
#
# In honor of the remarkable Windson
#
# Modified by Gabriel Francisco to create cluster-admin users.
username=$1
@fgbreel
fgbreel / Dockerfile
Last active November 3, 2020 11:16
k8s nutshell
FROM debian:stable
RUN apt-get update \
&& apt-get -y --no-install-recommends install \
python \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
EXPOSE "8000"
ENTRYPOINT ["python", "-m", "SimpleHTTPServer"]
@fgbreel
fgbreel / docker-networking.sh
Created June 16, 2017 12:34
docker networking
# create network for containers
docker network create foobar
# launch mysql container within foobar network and set its name to 'database':
# you can also add --network-alias='mysql.foobar.local' to add a FQDN if you like.
docker run --detach --name=database --network=foobar --tmpfs=/var/lib/mysql/:rw,noexec,nosuid,size=7000m --env MYSQL_ALLOW_EMPTY_PASSWORD=1 --env MYSQL_DATABASE=foobar mysql:5.6 mysqld
# wait mysql to initialize innodb logs and become ready for connections:
sleep 5