Skip to content

Instantly share code, notes, and snippets.

View gene1wood's full-sized avatar
🎩

Gene Wood gene1wood

🎩
View GitHub Profile
@gene1wood
gene1wood / example_aws_lambda_cloudformation_event_object.json
Created October 26, 2015 22:24
An example "event" object passed to AWS Lambda from AWS CloudFormation upon CloudFormation stack creation.
{
"StackId":"arn:aws:cloudformation:us-west-2:123456789012:stack/ExampleCloudFormationStackName/32fd2e81-0859-4c79-bd06-964b73da56cb",
"ResponseURL":"https://cloudformation-custom-resource-response-uswest2.s3-us-west-2.amazonaws.com/arn%3Aaws%3Acloudformation%3Aus-west-2%3A123456789012%3Astack/ExampleCloudFormationStackName/32fd2e81-0859-4c79-bd06-964b73da56cb%7CExampleCustomResourceName%7C438bd4b7-1e33-4f94-a39f-d8a39396ca4f?AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE&Expires=1445904945&Signature=eHFpU1Vuc0U5U2NKV211MlV0dWJ%3d",
"ResourceProperties":{
"RoleName":"ExampleCloudFormationStackName",
"ServiceToken":"arn:aws:lambda:us-west-2:123456789012:function:ExampleCloudFormationStackName-ExampleLambdaFunctionResourceName-AULC3LB8Q02F"
},
"RequestType":"Create",
"ServiceToken":"arn:aws:lambda:us-west-2:123456789012:function:ExampleCloudFormationStackName-ExampleLambdaFunctionResourceName-AULC3LB8Q02F",
"ResourceType":"Custom::ExampleCustomResourceName",
@gene1wood
gene1wood / example_create_google_group.py
Created November 10, 2015 21:54
Example code to create a Google group (which I don't have authorization to run)
from oauth2client.client import SignedJwtAssertionCredentials
import json
from httplib2 import Http
from apiclient.discovery import build
with open('AWS Security Email Group-1f0fae884116.json', 'r') as f:
credential_data = json.load(f)
domain = 'mozilla.com'
list_name = 'genetest'
@gene1wood
gene1wood / mailvelope_public_key_import.sh
Created November 12, 2015 21:24
Command to export all keys in a format that mailvelope can import
for key in `gpg --list-keys | awk '$1 == "pub" {print $2}' | awk -F "/" '{print $2}'`; do
gpg --export -a ${key} >> output.txt
done
@gene1wood
gene1wood / sns_topic_policy.json
Created November 27, 2015 19:51
Example SNS topic policy that is generated when a Notification ARN is set when launching a CloudFormation template
{
"Version": "2008-10-17",
"Id": "__default_policy_ID",
"Statement": [
{
"Sid": "__default_statement_ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
@gene1wood
gene1wood / gist:4988366
Created February 19, 2013 18:12
Re-implementation of bash wait to do parallel commands. I prefer wait but this is an alternative.
for host in $hostlist; do
scp $filename $host: &
echo "$!" >>$pidlistfile
done
while [ "`wc -l $pidlistfile`" -gt 0 ]; do
for pid in `cat $pidlistfile`; do
if ! kill -0 $pid 2>/dev/null; then
sed -e "/^$pid\$/d" $pidlistfile
fi
@gene1wood
gene1wood / transmission-daemon
Created February 26, 2013 18:16
Some simple logic to put the IP address of a specific interface into your /etc/sysconfig/transmission-daemon to get it to bind to that interface while issue https://trac.transmissionbt.com/ticket/2313 gets worked out. This applies to RHEL based installations.
# Username/password example
# DAEMON_ARGS="-b -t -a \"*.*.*.*\" -e /var/log/transmission/transmission.log"
# No username/password, but limited to 192.168.1.*
# DAEMON_ARGS="-b -T -a \"192.168.1.*\" -e /var/log/transmission/transmission.log"
INTERFACE=ppp0
if ifconfig $INTERFACE >>/dev/null 2>&1; then
BIND_ADDR="`/sbin/ifconfig $INTERFACE | awk '$1 == \"inet\" {print $2}' | awk -F: '{print $2}'`"
@gene1wood
gene1wood / adndroll.py
Last active December 15, 2015 07:09
Roll up an AD&D 1st Edition character
import random
# 1st Ed ranger with 10% XP bonus
#target_stats = [15,15,14,15]
# 1st Ed ranger
#target_stats = [13,13,14,14]
# A coupld of 17s
target_stats = [17,17]
@gene1wood
gene1wood / hostname_from_url.rb
Last active December 15, 2015 17:29
Extract the hostname from a url in Ruby
"https://www.example.com/"[/https?:\/\/([^\/]*)/, 1]
@gene1wood
gene1wood / date_examples.sh
Last active December 15, 2015 19:29
Date timestamp
# 20130404101032
date +%Y%m%d%H%M%S
# 1365095494
date +%s
@gene1wood
gene1wood / disable-opsview-core-ads.patch
Last active December 17, 2015 00:10
Disable Opsview Core Ads
--- /usr/local/opsview-web/root/navmenu/megamenu.orig 2013-05-04 17:23:26.000000000 -0400
+++ /usr/local/opsview-web/root/navmenu/megamenu 2013-05-04 17:23:46.000000000 -0400
@@ -83,8 +83,6 @@
</div>
<div id="demo_opsview_cta_buttons">
- <a href="http://www.opsview.com/solutions/pro/trial?[% c.track_back_querystring %]" border="0"><span>30-Day Pro Trial</span></a>
- <a href="http://www.opsview.com/solutions/pro?[% c.track_back_querystring %]" border="0"><span>Buy Pro NOW!</span></a>
</div>