Skip to content

Instantly share code, notes, and snippets.

View mschmitt's full-sized avatar
🥾
Busier than a one-legged man in an ass-kicking contest.

Martin Schmitt mschmitt

🥾
Busier than a one-legged man in an ass-kicking contest.
View GitHub Profile
@mschmitt
mschmitt / sshgrouplog.pl
Created July 12, 2011 14:22
Script for group SSH log entries per session
#!/usr/bin/perl -w
use strict;
use diagnostics;
use File::Navigate;
my $nav = File::Navigate->new($ARGV[0]);
my @connects = @{$nav->find(qr/sshd\[\d+\]: Connection from .+ port \d/)};
foreach (@connects){
@mschmitt
mschmitt / json.pl
Created July 28, 2011 11:15
Playing with the Firefox session file...
#!/usr/bin/perl -w
use strict;
use diagnostics;
use JSON;
use Data::Dumper;
my $sessionstore = '/home/martin/.mozilla/firefox/12345678.default/sessionstore.js';
my $json_raw;
open my $fh_in, "<$sessionstore" or die "Can't open $sessionstore: $!\n";
@mschmitt
mschmitt / half.sh
Created September 5, 2011 18:04
Crop foo for double-spread comic scans
#!/bin/sh
FILE=$1
echo $FILE
WIDTH=$(identify $FILE | awk '{print $3}' | awk -F x '{print $1}')
HEIGHT=$(identify $FILE | awk '{print $3}' | awk -F x '{print $2}')
HALFWIDTH=$(expr $WIDTH / 2)
LEFT=$(echo $FILE | sed 's/.jpg$/.l.jpg/i')
RIGHT=$(echo $FILE | sed 's/.jpg$/.r.jpg/i')
convert $FILE -crop "${HALFWIDTH}x${HEIGHT}+0x0" $LEFT
convert $FILE -crop "${HALFWIDTH}x${HEIGHT}+${HALFWIDTH}x0" $RIGHT
@mschmitt
mschmitt / gist:1388529
Created November 23, 2011 12:14
Perl wrapper to run process as different user and group
#!/usr/bin/perl -w
use strict;
use diagnostics;
my $uid = (getpwnam("saned"))[2];
my $gid = (getgrnam("scanner"))[2];
$( = $) = "$gid $gid";
$< = $> = "$uid";
if (
@mschmitt
mschmitt / deletepad.pl
Created February 28, 2012 13:10
Delete a pad from the default group in etherpad lite
#!/usr/bin/perl -w
use strict;
use diagnostics;
use LWP::Simple;
my $baseurl = 'http://127.0.0.1:9001/api/1/';
my $apikey = '***';
my $request_url = $baseurl.'deletePad?apikey='.$apikey.'&padID='.$ARGV[0];
print "$request_url\n";
@mschmitt
mschmitt / uhpg.pl
Created March 22, 2012 14:33
The user hater's password generator. Have a lot of fun!
#!/usr/bin/perl -w
use strict;
use diagnostics;
my @normal_chars = qw(I 1 l 0 O);
my @special_chars = qw(| [ ]);
my $length = 12;
print "The user hater's password generator. Have a lot of fun!\n";
print "-------------------------------------------------------\n";
@mschmitt
mschmitt / linksys-notes.txt
Created March 24, 2012 08:07
Linksys router notes
# Disassembly
## WRT54G
Pull off the blue front bezel at one edge. The black main case is hooked below
the blue bezel below the side edge.
http://blog.irrashai.com/blog/2008/09/how-to-crack-open-a-wrt54g-router/
# Serial Port
@mschmitt
mschmitt / transifex_downloader.pl
Created April 24, 2012 04:56
Transifex translation downloader
#!/usr/bin/perl -w
use strict;
use diagnostics;
use LWP::Simple;
use JSON;
my $proj = 'friendica';
my $lang = 'eo';
my $auth = 'user:password';
@mschmitt
mschmitt / Makefile
Created June 22, 2012 10:42
/boot/Makefile
all:
update-initramfs -u
grub-mkconfig
update-grub
grub-install /dev/sdc
@mschmitt
mschmitt / test_lockfile.pl
Created September 14, 2012 14:38
Script to test file locking
#!/usr/bin/perl -w
use strict;
use diagnostics;
use Fcntl qw(:flock);
my $lockfile = '/home/.test.lock';
open my $lock_fh, ">$lockfile" or die "Can't open $lockfile: $!\n";
if (flock($lock_fh,LOCK_EX|LOCK_NB)){