Skip to content

Instantly share code, notes, and snippets.

@focustrate
focustrate / gist:6868884
Created October 7, 2013 14:26
1. parse unique IPs from file of access log entries (store to a file) 2. run whois against all of them (store to another file)
# grep -oP "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" file_of_access_log_entries | sort -u > file_of_ip_addresses
# xargs -L1 whois < file_of_ip_addresses > file_of_whois_output
@focustrate
focustrate / gist:6251873
Created August 16, 2013 17:35
find number of days between now and modified date on folders in a directory -- ordered by longest since modified
$ end_date=`date '+%s'`; stat -f "%m;%N" * | awk -F\; -v e=$end_date '{print int((e-$1)/86400), "days \t", $2}' | sort -rn
@focustrate
focustrate / check_dg.sh
Created October 31, 2012 15:56
Datagram static page update check during Hurricane Sandy
#!/bin/bash
#
# Because of Hurricane Sandy (and us having all of our stuff co-located at Datagram in lower Manhattan)
# we had a major outage. I used this to monitor their website for updates.
# It's running on a local cronjob, every 5 minutes:
# */5 * * * * /Users/me/check_dg
#
# More about the outage:
# http://www.datacenterknowledge.com/archives/2012/10/30/major-flooding-nyc-data-centers/
@focustrate
focustrate / gist:3965822
Created October 27, 2012 19:36
Sports Guy Tube backend
<?php
/*
* this is what "powers" http://sportsguytube.blogspot.com/
* It pulls all the youtube links from Bill Simmons' tweets and then posts them to Blogger via email.
* I put it together in a couple hours one night and built the site on a whim.
* Simmons tweeted it out to his 1MM followers: https://twitter.com/sportsguy33/status/4176287276
*
*/
@focustrate
focustrate / save_disney_photos
Created October 27, 2012 19:25
Auto-download Disney Photopass Photos
#!/bin/bash
#
# takes a url like this:
# http://www.disneyphotopass.com/api/photostore/getSharedImageList.ashx?ShareToken=[[token]]
# and saves all the pictures to ./disneypics
#
# url can be found by going to http://www.disneyphotopass.com/photoshare.aspx and sharing photos by email.
# the link will be in the email
[[ -n "$1" ]] || { echo "Please add the share url as a parameter"; exit 0; }
@focustrate
focustrate / gist:3961183
Created October 26, 2012 20:10
Random string generator
<?php
$use_upper = true;
$use_lower = true;
$use_digits = true;
$use_symbols = true;
$string_length = 24;
$letters = 'abcdefghijklmnopqrstuvwxyz';