Skip to content

Instantly share code, notes, and snippets.

@hopeseekr
hopeseekr / amazing-aliases.sh
Last active April 8, 2025 18:32
Amazing Linux, PHP and Git aliases
# Dev aliases
alias free="free -m"
alias dup='(docker-compose up -d && docker-compose logs -ft)'
# I recomment putting this in /etc/cron.daily/
alias docker-prune='docker rmi $(docker images | grep "^<none>" | awk "{print $3}")'
# Git
alias gd='git diff'
alias ga='git add'
alias gco='git checkout --ours'
@hopeseekr
hopeseekr / 001-calibre-web.conf
Created March 29, 2025 15:49
Optimized Calibre-web Nginx reverse proxy
# Prequiste: For security, set Calibre to listen to 127.0.0.4:8383:
# Admin -> Basic Configuration -> Server Settings: Server port 8383.
# Then edit `/etc/systemd/system/multi-user.target.wants/calibre-web.service`:
# Change to `ExecStart=/usr/lib/calibre-web/cps.py -i 127.0.0.4`.
# sudo systemctl daemon-reload
# sudo systemctl restart calibre-web
server {
listen [::]:443 ssl;
listen 443 ssl;
@hopeseekr
hopeseekr / calibre-web.apache.conf
Created March 29, 2025 17:18
Optimized Calibre-web Apache reverse proxy
# Prequiste: For security, set Calibre to listen to 127.0.0.4:8083:
# Edit `/etc/systemd/system/multi-user.target.wants/calibre-web.service`:
# Change to `ExecStart=/usr/lib/calibre-web/cps.py -i 127.0.0.4`
# sudo systemctl daemon-reload
# sudo systemctl restart calibre-web
<VirtualHost *:443>
ServerName read.your.site
# SSL Configuration
@hopeseekr
hopeseekr / ComposerConstraintsMatchingTest.php
Last active March 27, 2025 15:57
Automated Development of Composer version constraints reverse-engineering
<?php
namespace Bettergist\Tests\Feature;
use Bettergist\Tests\TestCase;
use Composer\Semver\Constraint\Constraint;
use Composer\Semver\Semver;
use Composer\Semver\VersionParser;
class ComposerConstraintsMatcherTest extends TestCase
@hopeseekr
hopeseekr / StackOverflow Stats.md
Last active March 25, 2025 01:49
StackOverflow Dec 2024 stats

Disclaimer: I'm in the Top 1% of StackOverflow contributors with 23,315 rep points.

I asked 1 high-quality question in 2024, and it was closed almost immediately, and I haven't engaged with the site since.

If someone with 20,000+ karma has their nicely-formatted questions closed so quickly, what must the newbies and rank-in-file encounter? This is probably a big reason why it's declining.


@hopeseekr
hopeseekr / docker_dedicated_filesystem.md
Created February 3, 2018 04:01
Putting Docker on its own pseudo filesystem

Docker on BTRFS is very buggy and can result in a fully-unusable system, in that it will completely butcher the underlying BTRFS filesystem in such a way that it uses far more disk space than it needs and can get into a state where it cannot even delete any image, requiring one to take drastic actions up to and including reformatting the entire affected BTRFS root file system.

According to the official Docker documentation:

btrfs requires a dedicated block storage device such as a physical disk. This block device must be formatted for Btrfs and mounted into /var/lib/docker/.

In my experience, you will still run into issues even if you use a dedicated partition. No, it seems it requires a standalone

-- Combine these two queries into a table.
SELECT
sub.min_version AS version,
COUNT(*) AS count
FROM (
SELECT
package,
min(version) AS min_version
FROM
@hopeseekr
hopeseekr / arch-chroot
Last active August 26, 2024 14:42 — forked from bhelm/arch-chroot.sh
Chroot script from Archlinux (arch-chroot), works on any distri
#!/bin/bash
shopt -s extglob
# generated from util-linux source: libmount/src/utils.c
declare -A pseudofs_types=([anon_inodefs]=1
[autofs]=1
[bdev]=1
[bpf]=1
[binfmt_misc]=1
@hopeseekr
hopeseekr / redis-active-lines.log
Last active March 25, 2024 02:17
Redis Authorship Stats 2024-03-20
Redis Contributors with more than 10 Active lines of code in the `unstable` branch, ignoring whitespace changes.
Statistics based on HEAD
Active files: 1,566
Active lines: 417,517
Total commits: 9,516
Note: Files matching MIME type image, binary has been ignored
+----------------------------------+---------+---------+-------+--------------------+
@hopeseekr
hopeseekr / thin_space.php
Created January 21, 2023 19:50
ASCII Space vs UTF-8 Thin Space in PHP
<?php
/** See it live: https://onlinephp.io/c/551a0 **/
$helloWorld = [
'ascii' => 'Hello, World!',
'utf-8' => 'Hello, World!',
];
$spacePos = strpos($helloWorld['ascii'], ' ');