Skip to content

Instantly share code, notes, and snippets.

View da2x's full-sized avatar

Daniel Aleksandersen da2x

View GitHub Profile
@mathiasverraes
mathiasverraes / TestFrameworkInATweet.php
Last active May 23, 2022 12:28
A unit testing framework in a tweet.
<?php
function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);}
@da2x
da2x / authlog-ip-counter.sh
Last active December 14, 2015 06:38
Counts unique IP-addresses in /var/log/auth.* so you know who is brute-forcing you on SSH or other publicly exposed services. Also useful to run against other logs such as mail.* to look for attempted server abuse.
#!/bin/sh
cat /var/log/auth.* | \
egrep --only-matching '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | \
sort | uniq --count | \
sort --general-numeric-sort