Skip to content

Instantly share code, notes, and snippets.

View mgcon's full-sized avatar

Mike mgcon

View GitHub Profile
@mgcon
mgcon / resizeImages.sh
Last active August 29, 2015 14:27
batch resize images using Image Magik convert
#! /bin/bash
# adjust to taste
for i in `ls *JPG`; do
BASENAME=$(basename "$i" .JPG)
convert $i -resize 400x Resized/$BASENAME.png
done
@mgcon
mgcon / aptUpdate.sh
Created August 17, 2015 02:13
check apt for available updates
# /bin/bash
#this file just checks to see if there are any packages to install
# we will run this script from the root crontab each night
if [[ `apt-get update 2>&1 | grep Get` ]]; then
if [[ `apt-get --simulate dist-upgrade 2>&1 | grep Inst` ]]; then
apt-get --simulate dist-upgrade
fi
fi
@mgcon
mgcon / parseIptables.py
Created August 17, 2015 02:16
parse an ipTables log file
file = sys.stdin.readlines()
for line in file:
line = line.rstrip()
# don't laugh, the following line works fine for what I need.
# it uses a little regex to put what I need into a list called 'parts'
parts = re.findall("(.*)(moses.*)(IN=.*)(OUT=.*)(MAC=.*)(SRC=.*)(DST=.*)(LEN=.*)(TOS=.*)(PREC=.*)(TTL=.*)(PROTO=.*)(SPT=.*)(DPT=.*)(WINDOW=.*)", line)
for p in parts:
src = re.match("(SRC=)(.*)", p[5])
dst = re.match("(DST=)(.*)", p[6])
@mgcon
mgcon / replaceSpaces.pl
Created August 17, 2015 02:18
replace spaces in file names with underscores
#!/usr/bin/perl
# replace spaces in all filenames with underscores
$dir = ".";
opendir(DIR, $dir) || die "Can't open $dir\n";
for (readdir(DIR)) {
next if $_ eq '.';
next if $_ eq '..';
next if $_ eq 'lost+found';
@mgcon
mgcon / stripeReport.py
Last active November 19, 2015 01:34
a small script to quickly report all transactions that made up a Stripe transfer
#! /usr/bin/python
import stripe
import decimal
import datetime
stripe.api_key ='yourStripeKey'
def runBalance():
# change limit to suit taste
bal = stripe.BalanceTransaction.all(limit=30)