Skip to content

Instantly share code, notes, and snippets.

View gene1wood's full-sized avatar
🎩

Gene Wood gene1wood

🎩
View GitHub Profile
@gene1wood
gene1wood / check-persona-url.py
Created August 22, 2012 08:32 — forked from jrgm/check-persona-url.py
enumerate possible urls
#!/usr/bin/env python
import json
import os
import requests
# https://bugzilla.mozilla.org/show_bug.cgi?id=781838
# - POSTs MUST never redirect
# - POST over non-SSL MUST fail 400 Bad Non-SSL
# - GETs to the old domains MUST redirect to the new domain
# - www. MUST always redirect
@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 / configure-pat.sh
Last active March 7, 2021 17:33
/usr/local/sbin/configure-pat.sh from ami-vpc-nat-1.0.0-beta.i386-ebs (ami-6eff725e)
#!/bin/bash
# Configure the instance to run as a Port Address Translator (PAT) to provide
# Internet connectivity to private instances.
#
set -x
echo "Determining the MAC address on eth0"
ETH0_MAC=`/sbin/ifconfig | /bin/grep eth0 | awk '{print tolower($5)}' | grep '^[0-9a-f]\{2\}\(:[0-9a-f]\{2\}\)\{5\}$'`
if [ $? -ne 0 ] ; then
@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>
@gene1wood
gene1wood / command_line_logging_arguments.py
Created August 8, 2013 19:05
Python command line settable logging verbosity example.
#!/usr/bin/env python2.7
import argparse
import logging
def type_loglevel(level):
try:
result = getattr(logging, level.upper())
except AttributeError:
raise argparse.ArgumentTypeError("'%s' is not a valid log level. Please use %s" % \
#!/usr/bin/env python
import argparse
import ConfigParser
conf_parser = argparse.ArgumentParser(
# Turn off help, so we print all options in response to -h
add_help=False
)
conf_parser.add_argument("-c", "--conf_file",
help="Specify config file", metavar="FILE")