Skip to content

Instantly share code, notes, and snippets.

View blizzz's full-sized avatar
🌴
On vacation

Arthur Schiwon blizzz

🌴
On vacation
  • Milky Way
View GitHub Profile
@blizzz
blizzz / occ
Last active December 19, 2023 19:28
shortcut for "sudo -u http php[vv] occ"
#!/usr/bin/env bash
# Require: run from a Nextcloud root dir
if [ ! -f lib/versioncheck.php ]; then
echo "Enter the Nextcloud root dir first" > /dev/stderr
exit 255;
fi
# Test general php bin first
if php lib/versioncheck.php 1>/dev/null ; then
@blizzz
blizzz / max_nf_conntrack_count.sh
Created January 25, 2023 17:15
track nf_conntrack_count and output new high values
#!/usr/bin/env bash
CTT_HIGH=0
while :
do
CTT=$(cat /proc/sys/net/netfilter/nf_conntrack_count)
if (( ${CTT} > ${CTT_HIGH} )); then
echo $CTT
CTT_HIGH=${CTT}
fi
sleep 3
@blizzz
blizzz / purge-kernels.sh
Created December 5, 2022 11:16
remove old installed linux kernel (tested on ubuntu releases)
#!/usr/bin/env bash
# ⚠️ ATTENTION! It purges kernels without asking for confirmation!!!
CURRENT_KERNEL=$(uname -r | grep -oE '[0-9\.]+-[0-9]+')
LATEST_KERNEL=$(apt show linux-image-generic | grep -oE 'linux-image-[0-9\.]+-[0-9]+' | cut -d '-' -f3-)
BASE_KERNEL=$(echo ${CURRENT_KERNEL} | cut -d '.' -f 1-2)
apt list --installed | grep linux | cut -d '/' -f 1 | egrep -v "(${CURRENT_KERNEL}|${LATEST_KERNEL})" | grep "${BASE_KERNEL}." | tr '\n' ' ' | xargs apt purge -y
@blizzz
blizzz / lastStatus.sh
Created December 1, 2022 13:18
Apache HTTP request statuus of the last minute
grep $(date -d 'last minute' '+%d/%b/%Y:%H:%M') /var/log/apache2/access.log | grep -oE 'HTTP/..." [0-9]{3}' | awk '{ print $2; }' | sort | uniq -c | sort -n
@blizzz
blizzz / runWithNodeAndNpm.sh
Last active September 27, 2022 21:38
Execute a command with the node and npm version as required in package.json (on arch)
#!/bin/env bash
# requires nvm installed from AUR (i.e. only tested on Arch), and also jq
# run from the project directory like: runWithNodeAndNpm.sh make dev-setup
# the package.json is taken from the current working directory
NODE_MAJOR_VERSION=$(cat package.json | jq .engines.node | grep -oE '[0-9]*' | head -1)
NPM_MAJOR_VERSION=$(cat package.json | jq .engines.npm | grep -oE '[0-9]*' | head -1)
source /usr/share/nvm/init-nvm.sh
nvm install ${NODE_MAJOR_VERSION} && \
@blizzz
blizzz / assign-groups-to-groups.sh
Created February 18, 2021 18:01
randomly assign groups to groups in samba4
#!/bin/bash
for i in {1..200}
do
R_GID="Osmium ${i}"
MEMBERSHIPS="$((($RANDOM % 3)))"
for j in {1..${MEMBERSHIPS}}; do
R_GROUP="Osmium $((($RANDOM % 200) + 1))"
samba-tool group addmembers "${R_GROUP}" "${R_GID}" || true
done
@blizzz
blizzz / assign-users-to-groups.sh
Created February 18, 2021 18:01
randomly assign users to groups in samba4
#!/bin/bash
for i in {1..3200}
do
R_UID="Joker ${i}"
MEMBERSHIPS="$((($RANDOM % 10) + 10))"
for j in {1..${MEMBERSHIPS}}; do
R_GROUP="Osmium $((($RANDOM % 200) + 1))"
samba-tool group addmembers "${R_GROUP}" "${R_UID}" || true
done
@blizzz
blizzz / Batch create groups in samba4
Created February 18, 2021 18:00
Batch create groups in samba4
#!/bin/bash
for i in {1..200}
do
#echo "samba-tool group add 'Osmium ${i}'"
samba-tool group add "Osmium ${i}"
done
@blizzz
blizzz / create-users.sh
Created February 18, 2021 17:59
Batch create users in samba4
#!/bin/bash
if [ ! -f /dev/shm/first-names.txt ]; then
wget -q https://raw.githubusercontent.com/dominictarr/random-name/master/first-names.txt -O /dev/shm/first-names.txt
fi
if [ ! -f /dev/shm/last-names.txt ]; then
wget -q https://raw.githubusercontent.com/dominictarr/random-name/master/names.txt -O /dev/shm/last-names.txt
fi
IFS=$'\r\n' GLOBIGNORE='*' command eval 'FIRST_NAMES=($(cat /dev/shm/first-names.txt))'
@blizzz
blizzz / _intellij_phpdebug_validator.php
Created February 16, 2018 11:39
_intellij_phpdebug_validator.php
<?php
error_reporting(0);
define('HHVM_PHP_INI', "/etc/hhvm/php.ini");
define('HHVM_SERVER_INI', "/etc/hhvm/server.ini");
define('XDEBUG', "xdebug");
define('ZEND_DEBUGGER', "Zend Debugger");
function createXmlHeader()