Skip to content

Instantly share code, notes, and snippets.

@jkullick
jkullick / enable-nginx-logs-goaccess.md
Created March 27, 2017 10:02
Enable Nginx Logs in Goaccess

Add to /etc/goaccess.conf:

time-format %T
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
@jkullick
jkullick / remove-all-but-newest-folder-directory-linux.md
Created March 21, 2017 13:02
Remove All but x Newest Folders in Directory on Linux
KEEP=5
rm -rf `ls -td $PATH_TO_FILES/*/ | tail -n +$(($KEEP+1))`
@jkullick
jkullick / backup-whole-linux-system-ssh.md
Created March 12, 2017 21:55
Backup & Restore whole Linux System over SSH
# Backup
ssh root@$SSH_HOST "tar cpf - / --exclude=/sys --exclude=/proc --exclude=/dev" | pv | gzip | cat > backup.tar.gz

# Restore
cat backup.tar.gz | ssh root@$SSH_HOST "pv | tar zxvf - -C /"
@jkullick
jkullick / iptables-rate-limit.md
Created March 10, 2017 15:04
IPTables Rate Limit
iptables -N LOGGING
iptables -A LOGGING -m limit --limit 2/min -j LOG --log-prefix "IPTables-Dropped: " --log-level 4

iptables -A INPUT -p tcp --dport 80 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 80 -m state --state NEW -m recent --update --seconds 60 --hitcount 20 -j LOGGING

iptables -A LOGGING -j DROP
@jkullick
jkullick / convert-serialized-php-json.md
Last active June 13, 2022 10:23
Convert Serialized PHP to JSON
cat $SERIALIZED_PHP_FILE | php -r 'echo json_encode(unserialize(file_get_contents("php://stdin")));'
@jkullick
jkullick / pgp-sign-all-old-git-commits.md
Created February 16, 2017 15:00
PGP Sign all old Git Commits
git filter-branch -f --commit-filter 'git commit-tree -S "$@"' HEAD

Source

@jkullick
jkullick / fix-jira-upgrade-error-agile.md
Last active January 24, 2017 09:42
Fix JIRA Upgrade Error ("JIRA Agile is currently unavailable")
  1. Stop JIRA

  2. Execute Database Queries:

UPDATE propertynumber SET propertyvalue = 47 
WHERE id = (SELECT id FROM propertyentry WHERE property_key = 'GreenHopper.Upgrade.Latest.Upgraded.Version');
UPDATE propertystring SET propertyvalue = '47' 
WHERE id = (SELECT id FROM propertyentry WHERE property_key = 'com.pyxis.greenhopper.jira:build');
@jkullick
jkullick / reset-mysql-auto-increment-value-after-delete.md
Last active January 18, 2017 13:51
Reset MySQL Auto Increment Value after Delete
SELECT @max := MAX(ID)+ 1 FROM ABC; 

PREPARE stmt FROM 'ALTER TABLE ABC AUTO_INCREMENT = ?';
EXECUTE stmt USING @max;

DEALLOCATE PREPARE stmt;

@jkullick
jkullick / check-cpu-hardware-virtualization-support-linux.md
Created January 17, 2017 15:46
Check if CPU supports Hardware Virtualization on Linux
grep -E '(vmx|svm)' /proc/cpuinfo
@jkullick
jkullick / s25r-anti-spam-system-postfix.md
Last active January 17, 2017 15:14
S25R Anti-Spam-System in Postfix
postconf -e "smtpd_client_restrictions = check_client_access regexp:/etc/postfix/client_restrictions"

cat > /etc/postfix/client_restrictions << EOF
/^(dhcp|dialup|ppp|adsl|pool)[^.]*[0-9]/  550 S25R6 check
EOF

postfix reload