Skip to content

Instantly share code, notes, and snippets.

View ColinLeverger's full-sized avatar

Colin LEVERGER ColinLeverger

View GitHub Profile
@dacr
dacr / sshhack-iploc
Last active September 6, 2015 19:22
Quick hack to automatically ip geoloc people who tried to get access to your server (using SSH)
#!/bin/sh
exec scala -nc "$0" "$@"
!#
import scala.io._
import java.io._
import scala.util.matching._
val logfiles=if (args.size==0) List("/var/log/auth.log") else args.toList
val failRE="""^(\w+\s+\d+\s+\d{2}:\d{2}:\d{2}).*: Failed password for(?: invalid user)? (\w+) from ([.0-9A-Fa-f:]+) port.*""".r
val jstrRE=""""(\w+)":"([^"]+)"""".r
@baojie
baojie / hello_multiprocessing.py
Created July 21, 2013 07:04
Python multiprocessing hello world. Split a list and process sublists in different jobs
import multiprocessing
# split a list into evenly sized chunks
def chunks(l, n):
return [l[i:i+n] for i in range(0, len(l), n)]
def do_job(job_id, data_slice):
for item in data_slice:
print "job", job_id, item