Skip to content

Instantly share code, notes, and snippets.

View chluehr's full-sized avatar

Christoph Lühr chluehr

View GitHub Profile
@chluehr
chluehr / firewall_timestamp_fix.sh
Created April 23, 2014 12:32
Work around a misconfigured firewall by disabling TCP window scaling and TCP timestamps.
# http://prowiki.isc.upenn.edu/wiki/TCP_tuning_for_broken_firewalls
echo 0 | sudo tee /proc/sys/net/ipv4/tcp_timestamps
echo 0 | sudo tee /proc/sys/net/ipv4/tcp_window_scaling
# or add to sysctl.conf:
# net.ipv4.tcp_window_scaling=0
# net.ipv4.tcp_timestamps=0
@chluehr
chluehr / purge_clean_unused_kernels_in_boot.sh
Created October 24, 2014 12:33
removes/uninstalls/cleans all unused kernes from a system. use with caution!
#!/bin/bash
dpkg -l linux-{image,headers}-"[0-9]*" | awk '/ii/{print $2}' | grep -ve $kernelver |xargs sudo apt-get purge -y
@chluehr
chluehr / 90-u2f-securitykey.rules
Created November 12, 2014 15:08
Activate PlugUp FIDO Security Key
# Activate Plug-Up Security Key by creating: /etc/udev/rules.d/90-u2f-securitykey.rules anlegt
# (as root):
ATTRS{idVendor}=="2581", ATTRS{idProduct}=="f1d0", TAG+="uaccess"
ATTRS{idVendor}=="2581", ATTRS{idProduct}=="f1d0", GROUP="plugdev", MODE="0660"
@chluehr
chluehr / high_open_files_limit.txt
Created November 28, 2014 13:16
Set high limits on limit of open files for server tuning
/etc/security/limits.conf:
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
sysctl.conf:
fs.file-max = 65536
@chluehr
chluehr / 70-u2f.rules
Created December 25, 2014 21:28
Activate YubiCorp YubiKey FIDO Security Key / Linux
ACTION!="add|change", GOTO="u2f_end"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1050", ATTRS{idProduct}=="0113|0114|0115|0116|0120|0402|0403|0406|0407|0410", TAG+="uaccess"
LABEL="u2f_end"
@chluehr
chluehr / php_pimcore_event_replace.php
Created June 15, 2015 21:36
Sample: Replace Backend Pimcore Search Hooks - Detach ZF1 EventManager Listeners / Callbacks
<?php
namespace ElasticFind;
use Pimcore\API\Plugin as PluginLib;
class Plugin extends PluginLib\AbstractPlugin implements PluginLib\PluginInterface {
public function init() {
@chluehr
chluehr / purge_old_kernels.sh
Created June 16, 2015 09:04
Simple Script to delete all old kernels except the last recent 2 (after auto-updates) - use with caution
#!/bin/bash
OLD=$(ls -tr /boot/vmlinuz-* | head -n -3 | cut -d- -f2- |
awk '{print "linux-image-" $0 " linux-headers-" $0}' )
echo "OLD:"
echo "$OLD"
echo
echo -n "CURRENT: "
uname -r
@chluehr
chluehr / find_inode_usage.sh
Created June 24, 2015 09:03
Finds where all your inodes are being used ..
#!/bin/bash
# see: http://unix.stackexchange.com/questions/117093/find-where-inodes-are-being-used
# show inode usage:
df -i
# find where all those files are (roughly) - starts at /
find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
@chluehr
chluehr / bash_resize_crop_square_imagemagick.sh
Created July 22, 2010 13:05
BASH: resize/crop via ImageMagick
# BASH: resize/crop via ImageMagick
#==================================
function resizecrop {
SIZE=$1
SRC=$2
DST_PATH=$3
SRC_NAME=`basename $SRC`
@chluehr
chluehr / quoted_strings_detect.php
Created July 22, 2010 14:26
RegExp: Detect single/quoted string (w/ escapes) within strings
<?php
// detect single/quoted string (w/ escapes) within strings ..:
$regexp = '/(["\\\'])(?:\\\\?+.)*?\1/';
$testStr = " foo \"b\\\"ar\" baz '0\"8\"15' bing";
preg_match_all($regexp,$testStr,$matches);
print_r($matches);