Skip to content

Instantly share code, notes, and snippets.

View leonlaser's full-sized avatar
🍪

Leon Dietsch leonlaser

🍪
View GitHub Profile
@leonlaser
leonlaser / count_ips_in_logfile
Created March 18, 2019 12:39
[Count IPs from apache access log] #apache #accesslog #log #ip #bash #tail #sort #uniq
#!/bin/bash
tail -n10000 $logfile | cut -f3 -d' ' | sort | uniq -c | sort
@leonlaser
leonlaser / test_disk_speed
Last active March 21, 2019 14:19
[Test disk speed] #dd #hdd #disk #server #speedtest #speed #io
#!/bin/bash
# bs=file size
# count=number of tries
# if=input file
# of=output file
# conv='sync' (macos) / 'fadatasync' (linux) wait for I/O-Cache to write data on disk
dd bs=${bs:-1024} count=${count:-256} if=/dev/zero of=dd_zero_file conv=sync && rm dd_zero_file
@leonlaser
leonlaser / overwrite_typo3_class.php
Last active March 18, 2019 14:13
[Overwrite object in TYPO3] Can be used in your extensions ext_localconf.php #objects #typo3 #overwrite #replace
<?php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\Vendor\Package\Classname::class] = array(
'className' => \AnotherVendor\AnotherPackage\AnotherClassname::class
);
@leonlaser
leonlaser / typo3_404_page_handling.php
Last active March 18, 2019 14:13
[Configure TYPO3 CMS 404 page] #typo3 #404 #pagenotfound
<?php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] = 1;
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = '/page-not-found-page/';
@leonlaser
leonlaser / echo_flip_table.sh
Last active March 22, 2019 10:52
[Print ASCII Art Table Flip] #shell #asciiart #ascii #echo
#!/bin/sh
# source: https://cutekaomoji.com/misc/table-flipping/
echo "(╯°□°)╯︵ ┻━┻"
@leonlaser
leonlaser / test_php_script
Last active March 22, 2019 10:51
[Test PHP script] A script to test scripts with a shebang
#!/usr/bin/env php
<?php
echo "><(((('>" . PHP_EOL;
@leonlaser
leonlaser / seeyouspacecowboy.bash
Last active March 26, 2019 10:25
[Print colored "See you space cowboy" message] #bash #text #colored
#!/usr/bin/env bash
# SEE YOU SPACE COWBOY by DANIEL REHN (danielrehn.com)
# Displays a timeless message in your terminal with cosmic color effects
# Usage: add "sh ~/seeyouspacecowboy.sh; sleep 2" to .bash_logout (or similar) in your home directory
# (adjust the sleep variable to display the message for more seconds)
# Cosmic color sequence
@leonlaser
leonlaser / wait_forever
Last active March 26, 2019 09:56
[Bash wait forever] Test script for signaling a process to stop #bash #while #sleep #loop
#!/bin/bash
while :
do
echo "Press [CTRL+C] to stop.."
sleep 1
done
@leonlaser
leonlaser / new_ssh_key
Last active March 11, 2020 12:09
[Generate new SSH public/private key pair] #bash #ssh #key
#!/bin/bash
ssh-keygen -t ed25519 -o -a 100 -C "$identifier" -f ./id_rsa
@leonlaser
leonlaser / remove_past_tags
Last active April 1, 2019 14:10
[Delete git tags dont have $tag as an ancestor] #git #tags
comm -23 <(git tag | sort) <(git tag --contains $tag | sort) | xargs git push --delete origin
git fetch --prune origin '+refs/tags/*:refs/tags/*'