Skip to content

Instantly share code, notes, and snippets.

View mrpatrick's full-sized avatar

Patrick Tully mrpatrick

View GitHub Profile
$ mysqldump -u user -p'password' db-name foo | ssh user@remote.box.com mysql -u user -p'password' db-name foo
@mrpatrick
mrpatrick / harvest_email.worker
Created September 15, 2014 16:15
daily_harvest email report automated on iron.io (worker file). http://workshop.avatarnewyork.com/project/daily-harvest/
# define the runtime language
runtime "python"
stack "python-2.7"
full_remote_build true
# includes
dir "Harvest"
file "harvest.json"
file "mailgun.json"
file "recipients.json"
@mrpatrick
mrpatrick / harvest_backup.worker
Created September 15, 2014 15:56
daily_harvest mysql backups automated on iron.io (worker file). http://workshop.avatarnewyork.com/project/daily-harvest/
# define the runtime language
runtime "python"
stack "python-2.7"
full_remote_build true
# includes
dir "Harvest"
file "harvest.json"
file "mysql.json"
@mrpatrick
mrpatrick / sed-tsv2mod_rewrite
Created September 5, 2014 19:39
sed command to create mod_rewrite rules from tab delimited spreadsheet.
cat redirects.tsv | sed -e 's/\(^\/\)\([a-zA-Z0-9\/!#$&-;=?%-_a-z~]*\)\(\t*\)\(.*\)/RewriteRule ^\/?\2$\4 [L,R=302]/'
@mrpatrick
mrpatrick / rackspace_statuspageio.sh
Created July 3, 2014 22:30
Get the status of Rackspace-ORD and set them on StatusPage.io Components
#!/bin/bash
# Set from statuspage.io
PAGE_ID=""
AUTH_TOKEN=""
# Set from statuspage.io Component ID's
COMP_SERVERS_NEXT=""
COMP_SERVERS_FIRST=""
COMP_LOAD_BALANCERS=""
<?php
use \avatarnewyork\pagerdutysayswebhook; include("classes/pagerdutysays.php");
$pds = new pagerdutysayswebhook\PagerDutySays($HTTP_RAW_POST_DATA);
$pds->enableAirPlay(true);
$pds->say();
?>
{ "messages": [ { "id": "bb8b8fe0-e8d5-11e2-9c1e-22000afd16cf", "created_on": "2013-07-09T20:25:44Z", "type": "incident.trigger", "data": { "incident": { "id": "PIJ90N7", "incident_number": 1, "created_on": "2013-07-09T20:25:44Z", "status": "triggered", "html_url": "http://acme.pagerduty.com/incidents/PIJ90N7", "incident_key": "null", "service": { "id": "PBAZLIU", "name": "service", "html_url": "http://acme.pagerduty.com/services/PBAZLIU" }, "assigned_to_user": { "id": "PPI9KUT", "name": "Alan Kay", "email": "alan@pagerduty.com", "html_url": "http://acme.pagerduty.com/users/PPI9KUT" }, "trigger_summary_data": { "subject": "45645" }, "trigger_details_html_url": "http://acme.pagerduty.com/incidents/PIJ90N7/log_entries/PIJ90N7", "last_status_change_on": "2013-07-09T20:25:
@mrpatrick
mrpatrick / apache_piped_json_errors.conf
Created October 31, 2013 21:19
Apache Piped JSON excluding 2xx and 3xx statuses
# JSON extended log format including: User-Agent, Referer, and X-Forwarded-For
LogFormat "{ \"time\":\"%t\", \"remoteIP\":\"%a\", \"host\":\"%V\", \"request\":\"%U\", \"query\":\"%q\", \"method\":\"%m\", \"status\":\"%>s\", \"userAgent\":\"%{User-agent}i\", \"referer\":\"%{Referer}i\", \"X-Forwarded-For\":\"%{X-Forwarded-For}i\" }" jsonlog
# Pipe only warnings/errors to json log file
CustomLog "|/bin/grep -E --invert-match --line-buffered 'status.?[[:punct:]].?[23]' |cat >> /var/log/httpd/errors.json" jsonlog
LogFormat "%s %h %l %u %t \"%r\" %b" splunk
CustomLog "|stdbuf -o0 /bin/grep --invert-match '^200' | /usr/sbin/rotatelogs /var/log/apache2/splunk-access.log 86400" splunk
curl -X POST https://identity.api.rackspacecloud.com/v2.0/tokens -d '{ "auth":{ "passwordCredentials":{ "username":"$USER", "password":"$PASSWORD"}}}' -H "Content-type: application/json"