Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import sys
import subprocess
data = subprocess.run(['ls', '-l'], stdout=subprocess.PIPE).stdout.decode('utf-8').split('\n'))
for line in data:
items = line.split('.')
for element in items[15:-1]:
import json
import requests
from requests.auth import HTTPBasicAuth
class BitcoinRpc(object):
def __init__(self, username, password, host, port=8332):
self.username = username

Configuring HTTPS Servers

To configure an HTTPS server, the ssl parameter must be enabled on listening sockets in the server block, and the locations of the server certificate and private key files should be specified:

server {
    listen              443 ssl;
    server_name         www.example.com;
    ssl_certificate     www.example.com.crt;
 ssl_certificate_key www.example.com.key;
@cdodd
cdodd / parse-o365-ip-addrs.py
Last active March 15, 2018 20:37
Parse and reformat the IP address ranges for various Office 365 services.
#!/usr/bin/env python
import xmltodict
from socket import inet_ntoa
from struct import pack
import sys
import urllib
def calcDottedNetmask(mask):
bits = 0xffffffff ^ (1 << 32 - mask) - 1
@cdodd
cdodd / teensy-arcade-controller.ino
Created July 17, 2016 14:57
Code for a Teensy based DIY game controller
#include <Bounce.h>
// ============================================================================
// Begin configuration items
// ============================================================================
// Define the numbers for the hat switch pins
#define HAT_UP_PIN 3
#define HAT_DOWN_PIN 1
#define HAT_LEFT_PIN 0
@cdodd
cdodd / aws-puppet-cert-cleaner.py
Last active February 16, 2016 10:02
AWS Puppet Cert Cleaner
#!/usr/bin/env python
import subprocess
import boto.ec2 as ec2
import boto.utils
# Get all "private_dns_name"s from AWS
conn = ec2.connect_to_region(
boto.utils.get_instance_metadata()['placement']['availability-zone'][:-1]
)
@cdodd
cdodd / keybase.md
Last active February 3, 2017 00:59
keybase.io proof

Keybase proof

I hereby claim:

  • I am cdodd on github.
  • I am cdodd (https://keybase.io/cdodd) on keybase.
  • I have a public key whose fingerprint is 3915 9EE5 AC74 FA4F E4C6 4E03 27D1 49AB BD73 92C6

To claim this, I am signing this object:

@cdodd
cdodd / install-squid.sh
Last active June 17, 2022 15:08
Install a basic squid proxy with authentication on Centos 6 x64. Just modify the variables at the top and run the script on a clean system.
#!/bin/sh
PROXY_USER=user
PROXY_PASS=password
PROXY_PORT=3128
# Clear the repository index caches
yum clean all
# Update the operating system
@cdodd
cdodd / create_cname.py
Last active October 28, 2016 05:09
Create a CNAME record using the DynECT REST API.
import sys
from dynect.DynectDNS import DynectRest
rest_iface = DynectRest()
# Log in
credentials = {
'customer_name': 'my_cust',
'user_name': 'my_user',
'password': 'my_pass',
@cdodd
cdodd / abv-calculator.py
Created September 5, 2013 12:28
Alcohol by volume (ABV) calculator based on original and final beer gravity readings.
#!/usr/bin/python
import sys
# Get the original and final gravity from the commandline args
try:
og = float(sys.argv[1])
fg = float(sys.argv[2])
except IndexError:
print 'Usage %s <original gravity> <final gravity>' % sys.argv[0]
sys.exit(1)