Skip to content

Instantly share code, notes, and snippets.

@adrolter
adrolter / build-dev-container
Last active December 29, 2023 23:57
Symfony Xdebug bypass when building the container in dev
#!/usr/local/bin/php -dxdebug.mode=off
<?php
declare(strict_types=1);
use App\Kernel;
switch (\ini_get('xdebug.mode')) {
case false:
case 'off':
/** NOP */
@adrolter
adrolter / symfony-63-getSupportedTypes.patch
Last active June 24, 2023 20:51
jane-php/json-schema Symfony 6.3 compat
diff -ruN '--exclude=PATCHES.txt' json-schema/Generator/NormalizerGenerator.php json-schema.symfony-63-getSupportedTypes/Generator/NormalizerGenerator.php
--- json-schema/Generator/NormalizerGenerator.php 2023-06-24 16:46:45.876081361 -0400
+++ json-schema.symfony-63-getSupportedTypes/Generator/NormalizerGenerator.php 2023-06-24 16:46:39.636091630 -0400
@@ -9,6 +9,9 @@
use Jane\Component\JsonSchema\Registry\Schema;
use PhpParser\Node\Expr;
use PhpParser\Node\Name;
+use PhpParser\Node\NullableType;
+use PhpParser\Node\Param;
+use PhpParser\Node\Scalar;
@adrolter
adrolter / systemd-cheatsheet.md
Created May 11, 2018 19:09
systemd/systemctl Cheatsheet

Reload automounts

systemctl daemon-reload && { systemctl restart local-fs.target; systemctl restart remote-fs.target; }

@adrolter
adrolter / pacman-filediff
Created May 7, 2018 19:10
Arch Linux Bash script for diffing locally installed files with the current package version
#!/bin/bash
# Diff a file on the filesystem with the current package version
set -eu
file="${1:?No file specified}"
[ -e "$1" ] || { >&2 printf 'Path does not exist: %s\n' "$1"; exit 1; }
[ ! -d "$1" ] || { >&2 printf 'Path is a directory: %s\n' "$1"; exit 2; }
# Canonicalize $file without resolving the basename
dir="$(readlink -f "$(dirname "$file")")"
file="$(basename "$file")"
@adrolter
adrolter / mount-image.sh
Last active May 25, 2017 04:05
Mount the partitions of a block device image to a temporary location
#!/usr/bin/sh
# mount-image.sh – Mount the partitions of a block device image ($1) to a temporary location
# Copyright (c) 2017 Adrian Günter
#
# @Authors Adrian Günter <adrian|gntr/me>
# @URL https://gist.github.com/adrianguenter/5072827b71e27661263a5cfba651b859
# @License http://opensource.org/licenses/MIT
# @Shells Bash >=4.4, Dash >=0.5
# @Usage mount-image.sh <image-path>
# @Example
@adrolter
adrolter / qubes-sysmon.sh
Last active February 5, 2021 07:58
Qubes OS System Monitor for Lenovo ThinkPads
#!/usr/bin/sh
# qubes-sysmon.sh – Qubes OS System Monitor for Lenovo ThinkPads
# Copyright (c) 2017 Adrian Günter
#
# @Authors Adrian Günter <adrian|gntr/me>
# @URL https://gist.github.com/adrianguenter/f55958ad27de2c341a4dbc490978dd40
# @License http://opensource.org/licenses/MIT
# @Shells Bash >=4.4, Dash >=0.5
# @Usage [WATCHARGS=d] qubes-sysmon.sh <timeout-secs>
#
@adrolter
adrolter / bash-app-template-v1.sh
Last active April 24, 2017 06:20
Gist-based Bash script app template
#!/bin/bash
# bash-app-template-v1.sh
# description: Gist-based Bash script app template
# author: Adrian Günter <adrian|gntr/me>
# grepping:
# - sections: ^### (?<section>.+) ###
# - actions: ^# ACTION: (?<action>.+)
# - a function's definition: func_name\(\)
# sections: SHELLCFG,DEPENDENCIES,CONSTANTS,FUNCTIONS,ACTIONS,ROUTINE
# actions: self-install
@adrolter
adrolter / busybox-lsusb-names.sh
Last active March 10, 2016 09:24
lsusb with vendor and product strings for BusyBox 1.2x
unalias lsusb &>/dev/null; lsusb() {
/usr/bin/lsusb "$@" | awk 'BEGIN { idexpr="[[:xdigit:]]{4}"; vexpr="^"idexpr"[[:space:]]+"; pexpr="^\t"idexpr"[[:space:]]+"
while (("curl -sS http://www.linux-usb.org/usb.ids") | getline) {
if($0 == "# List of known device classes, subclasses and protocols") {break}
else if(lastv == "" && substr($1, 0, 1) == "#") {continue}
else if(lastv != "" && $0 ~ pexpr) {lastp=$1; sub(pexpr, ""); r[lastv, lastp]=$0}
else if($0 ~ vexpr) {lastv=$1; sub(vexpr, ""); r[lastv]=$0}
}
}
"ID "idexpr":"idexpr"$" {split($6, id, ":"); printf "%s %s %s\n", $0, r[id[1]], (r[id[1], id[2]])}'
@adrolter
adrolter / chrosisopw.exp
Last active March 1, 2016 07:28
Randomize the RancherOS ISO password ASAP after SSHd starts.
#!/usr/bin/expect -f
### BEGIN CONFIGURATION #######################################################
set VERBOSITY 1
set PASSWORD_LENGTH 40
### END CONFIGURATION #########################################################
exp_internal 0
@adrolter
adrolter / bootstrap.php
Created August 18, 2014 06:23
More flexible bootstrap
<?php
$dirSep = DIRECTORY_SEPARATOR;
$boltRoot = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..');
$autoloaderPaths = array(
'Standard' => $boltRoot . $dirSep . 'vendor' . $dirSep . 'autoload.php',
'Composer' => $boltRoot . $dirSep . '..' . $dirSep . '..' . $dirSep . 'autoload.php';
);