Skip to content

Instantly share code, notes, and snippets.

View cat5inthecradle's full-sized avatar

Darin Webb cat5inthecradle

View GitHub Profile
@cat5inthecradle
cat5inthecradle / cloudfront_function_redirect.yml
Last active January 20, 2022 17:03
Cloudfront function redirect
AWSTemplateFormatVersion: 2010-09-09
Description: Cloudfront redirect lambda demo
Parameters:
FromDomain:
Type: String
Default: darin.dev-code.org
Description: The domain you wish to redirect traffic from
ToDomain:
Type: String
@cat5inthecradle
cat5inthecradle / cloudfront_lambda_redirect
Last active January 10, 2022 17:14
Redirect one domain to another via Cloudfront Lambda@Edge
AWSTemplateFormatVersion: 2010-09-09
Description: Cloudfront redirect lambda demo
Parameters:
FromDomain:
Type: String
Default: darin.dev-code.org
Description: The domain you wish to redirect traffic from
ToDomain:
Type: String
@cat5inthecradle
cat5inthecradle / gist:66a09261e51d4303aa9fc94d5d2c8826
Created March 27, 2017 19:51
Cloudformation change-set samples
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-updating-stacks-changesets.html
# create it
aws cloudformation create-change-set \
--stack-name arn:aws:cloudformation:us-east-1:123456789012:stack/SampleStack/1a2345b6-0000-00a0-a123-00abc0abc000
--change-set-name SampleChangeSet \
--use-previous-template \
--parameters ParameterKey="InstanceType",UsePreviousValue=true ParameterKey="KeyPairName",UsePreviousValue=true ParameterKey="Purpose",ParameterValue="production"
# view it
@cat5inthecradle
cat5inthecradle / getEndTime.php
Last active April 12, 2016 16:44
Calculates the end time given a start time a number of hours remaining
function getEndTime(DateTime $startDate, int $hoursRemaining) {
$endDate = $startDate;
# Can we finish it today?
$hoursLeftInWorkday = $this->getHoursLeftInWorkday($startDate);
if ($hoursRemaining < $hoursLeftInWorkday) {
$endDate->modify('+' . $hoursRemaining . ' hours');
return $endDate;
# Ok, so this is cheating and actually checks for the most
# recent time the Event Log service started, but 99% of
# the time this'll do.
$xml=@'
<QueryList>
<Query Id="0" Path="System">
<Select Path="System">*[System[(EventID=6005)]]</Select>
</Query>
</QueryList>
# download the bofh excuse list from http://pages.cs.wisc.edu/~ballard/bofh/excuses
# save the list to ./bofh/bofh.txt with each excuse on a new line
@botcmd
def why(self, mess, arg):
try:
excuses = open('bofh/bofh.txt')
self.send_simple_reply(mess, random.choice(excuses.readlines()).rstrip('\r\n'))
except Exception, e:
self.send_simple_reply(mess, "Sorry I can't think of a good excuse, or bofh/bofh.txt is missing.")
@cat5inthecradle
cat5inthecradle / get_firefox_tabs.py
Last active August 29, 2015 14:21
Python Firefox Tab Counter
import json
import os
import glob
from datetime import datetime
appdata = os.getenv('APPDATA')
fi = open(glob.glob(appdata + '/Mozilla/Firefox/Profiles/*.default/sessionstore-backups/recovery.js')[0], "r")
jdata = json.loads(fi.read())
fi.close()
@cat5inthecradle
cat5inthecradle / VipreRemovalScript.cmd
Created March 4, 2015 18:43
Vipre Removal Script
@echo off
setlocal
echo ####################################################
echo # #
echo # VIPRE Business Removal Tool v0.1 #
echo # #
echo # Last update: Nov. 17, 2014 #
echo # Source Instructions: http://bit.ly/1qeyRtH #
echo # #
@cat5inthecradle
cat5inthecradle / hostswap.bat
Created January 27, 2015 21:32
Hosts File Util
@echo off
REM Usage
REM
REM hostswap.bat <ip address> <hostname>
REM This will add the given information to the hosts file,
REM and save the original file to hosts.bak.
REM
REM hostswap.bat -revert
REM This will swap hosts and hosts.bak.