Skip to content

Instantly share code, notes, and snippets.

@lehnerpat
lehnerpat / sha-changer.sh
Created November 15, 2012 12:23
Script to replace full shas with shorter versions (arbitrary length)
#!/bin/bash
git log --format=">%H< %cN" -10 | while read line
do
pre=`echo $line|sed -e "s/\(.*\)>[^<]*<.*/\1/"`
sha=`echo $line|sed -e "s/.*>\([0-9a-fA-F]*\)<.*/\1/"`
#echo "Cut sha as: $sha"
sha=`git rev-parse --short=4 $sha`
rest=`echo $line|sed -e "s/.*>[^<]*<\(.*\)/\1/"`
echo "$pre -- $sha -- $rest"
@lehnerpat
lehnerpat / iptrules.txt
Created November 14, 2012 17:36
Firewall rules
These lines are saved to a text file and loaded into iptables with iptables-restore (like "/sbin/iptables-restore </etc/iptables.conf"):
:DO_BLACKLIST - [0:0]
:IN_SSH - [0:0]
-A INPUT -m recent --rcheck --seconds 3600 --name blacklist --rsource -j DROP
-A INPUT -p tcp -m tcp --dport 22 -j IN_SSH
-A IN_SSH -s 192.168.1.0/24 -p tcp -m tcp --dport 22 -j ACCEPT
-A IN_SSH -m recent --rcheck --seconds 60 --hitcount 4 --name ssh_limits --rsource -j DO_BLACKLIST
-A IN_SSH -p tcp -m tcp --dport 22 --tcp-flags FIN,SYN,RST,ACK SYN -m recent --set --name ssh_limits --rsource -j ACCEPT
-A IN_SSH -j ACCEPT
@lehnerpat
lehnerpat / xkcd.java
Created October 4, 2012 10:28
xkcd.java
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;