Skip to content

Instantly share code, notes, and snippets.

@wh13371
wh13371 / nano.sh
Created July 6, 2015 15:34
gist - bash date with nano-second
date +%s.%N
@wh13371
wh13371 / cat.sh
Created July 6, 2015 15:37
linux - cat
cat -v moo.sh
cat moo.sh | hexdump -c
cat moo.sh | hexdump -C
@wh13371
wh13371 / find.sh
Created July 6, 2015 15:38
linux - find files less than x chars
find . -not -name '?????*'
@wh13371
wh13371 / docopt_simple.py
Created July 21, 2015 19:34
python - docopt example (simple)
#!/usr/bin/python
"""
Usage:
% [-dv] FILE ...
% -h | --help
% --version
Options:
@wh13371
wh13371 / .bashrc.sh
Created October 3, 2015 11:20
centos - bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
# a decent bash prompt # \d or \D = date - \t = time - \u = user - \h = host - \w = cwd
@wh13371
wh13371 / flipflop.pl
Created February 18, 2016 16:07
perl - flipflop
# tiny "flip-flop"
use strict;
use warnings;
use 5.020;
use Getopt::Long qw(GetOptions);
Getopt::Long::Configure ("bundling"); # -lcd => line / chomp / debug
my $debug;
@wh13371
wh13371 / exif.py
Created February 19, 2016 10:30
python - exif image renamer
#! /usr/bin/python
import sys, datetime, os, time
from PIL import Image # for <PIL> on Python 2.6 => "pip install Pillow" - for Python 2.7 <PIL> part of core modules
from PIL.ExifTags import TAGS
# usage examples:
# ./exif.py ~/Pictures/*
# ./exif.py DSCF0155.JPG
# ./exif.py ~/Pictures/DSCF0155.JPG ~/Pictures/DSCF0156.JPG
@wh13371
wh13371 / tee.pl
Created February 26, 2016 19:08
perl - tee
#! /usr/bin/perl
# usage: ping 8.8.8.8 | tea.pl [-v] [-t] [FILE]
# -v = verbose | -t = prefix timestamp to output | FILE = output filename
use IO::Handle;
use Getopt::Long;
use Time::HiRes;
use POSIX;
@wh13371
wh13371 / iis_log_parser.py
Created March 3, 2016 11:39
python - very basic IIS log parser
import fileinput, sys
from pprint import pprint
header = ['date', 'time', 's-ip', 'cs-method', 'cs-uri-stem', 'cs-uri-query', 's-port', 'cs-username', 'c-ip', 'cs(User-Agent)', 'sc-status', 'sc-substatus', 'sc-win32-status', 'sc-bytes', 'cs-bytes', 'time-taken']
l = [] # a list to hold a <dict> for each line in the IIS log file
for line in fileinput.input(sys.argv[1]):
if not line.startswith('#'):
fields = line.split()
@wh13371
wh13371 / get.lines.pl
Created May 7, 2016 06:41
perl - get X to Y lines from file
use strict;
use warnings;
use 5.020;
use Getopt::Long qw(GetOptions);
Getopt::Long::Configure ("bundling"); # -d
my $debug;
GetOptions('debug|d' => \$debug) or die "$0";