Skip to content

Instantly share code, notes, and snippets.

View simonjgreen's full-sized avatar

Simon Green simonjgreen

View GitHub Profile
@simonjgreen
simonjgreen / gist:6347157
Last active December 21, 2015 18:28
Colourises an access log
#Puts a splash of colour in your access logs. IP addresses are gray, 200 and 304 are green, all 4xx errors are red.
#Works well with e.g. "colourise access_log | less -R" if you want to see your colours while paging.
#Use as inspiration for other things you might be tailing, like syslog or vmstat
#Usage:
#tail -f access.log | colourise
function colourise() { c="--line-buffered --color=yes"; GREP_COLORS="mt=01;34" egrep $c '(^| 200 | 304 )' "${@}" | GREP_COLORS="mt=02;31" egrep $c '(^|"(GET|POST) .*[^0-9] 4[0-1][0-9] )' | GREP_COLORS="ms=02;37" egrep $c '(^|^[0-9\.]+) ';}
@simonjgreen
simonjgreen / 4word.sh
Created August 26, 2013 21:58
Creates an XKCD style 4word password from your dict files
#!/bin/bash
p=""
word=$(shuf -n4 /usr/share/dict/words)
for w in ${word[@]}
do
w=${w^}
w=${w//\'/}
p+=$w
done
echo $p
@simonjgreen
simonjgreen / netstat-open.sh
Created August 26, 2013 22:00
Nice output of listening services
#!/bin/bash
sudo netstat -plntu --inet | sort -t: -k2,2n | sort --stable -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | sort -s -t" " -k1,1
@simonjgreen
simonjgreen / gist:6347213
Created August 26, 2013 22:01
Update your no-ip.com dynamic DNS address, stick it in your crontab
curl -u USERNAME:PASSWORD "http://dynupdate.no-ip.com/nic/update?hostname=HOSTNAME"
@simonjgreen
simonjgreen / whatsMyAgeAgain.sh
Created August 26, 2013 22:03
Show how old your Linux install is
#!/bin/bash
sudo tune2fs -l $(df -h / |(read; awk '{print $1; exit}')) | grep -i created
@simonjgreen
simonjgreen / colourtheme.sh
Created September 22, 2013 19:47
This file echoes a bunch of colour codes to the terminal to demonstrate what's available. Each line is the colour code of one foreground colour, out of 17 (default + 16 escapes), followed by a test use of that colour on all nine background colours (default + 8 escapes).
#!/bin/bash
T='Test' # The test text
echo -e "\n 40m 41m 42m 43m\
44m 45m 46m 47m";
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
' 36m' '1;36m' ' 37m' '1;37m';
@simonjgreen
simonjgreen / resize-windows.txt
Created September 28, 2013 20:43
So you want to break your Windows installation / Move an OS from one server to another. Extract from gparted docs.
----> This is a draft to update "resize-windows.txt",
----> which is a part of "GParted" info package.
----> Not all suggestions are based on personal experience
----> or testing (estimated 20 % do NOT !).
----> There might be grammatical or other faults, because
----> English is not my native language.
----> Important question to the programmers of "Gparted":
----> Why does "fdisk (i)" not work as expected or what
----> am I doing wrong ? I also tried "sudo fdisk ..."
----> with no effect !
@simonjgreen
simonjgreen / printerquickref
Created April 1, 2014 19:33
Arduino printer quick ref
// Test inverse on & off
printer.inverseOn();
printer.println("Inverse ON");
printer.inverseOff();
// Test character double-height on & off
printer.doubleHeightOn();
printer.println("Double Height ON");
printer.doubleHeightOff();
#!/usr/bin/env python2
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford (jspenguin@jspenguin.org)
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select

Keybase proof

I hereby claim:

  • I am simonjgreen on github.
  • I am simonjgreen (https://keybase.io/simonjgreen) on keybase.
  • I have a public key whose fingerprint is C453 F4A3 9CA1 E58A 462B D14D F956 1595 2D15 8735

To claim this, I am signing this object: