Skip to content

Instantly share code, notes, and snippets.

View colinmcintosh's full-sized avatar
🏳️‍🌈

Colin McIntosh colinmcintosh

🏳️‍🌈
View GitHub Profile
@colinmcintosh
colinmcintosh / exercise_13.py
Created November 9, 2015 16:15
exercise_13.py
def max_in_list(list_of_numbers):
x = list_of_numbers.pop()
for i in list_of_numbers:
if i > x: x = i
return x
@colinmcintosh
colinmcintosh / second_largest.py
Last active November 10, 2015 19:27
Second Largest
def second_largest(list_of_numbers):
return sorted(set(list_of_numbers))[-2]
def second_largest_two(list_of_numbers):
x = None
for i in list_of_numbers:
if x is None or i > x:
x, y = i, x
return y
@colinmcintosh
colinmcintosh / average_file_size.sh
Created January 5, 2016 05:51
Find average file size recursively on FreeBSD
find / -name '*' -type f -print0 | xargs -0 ls -l | awk '{ total += $5; count += 1}; END { print (total/count)/1024/1024 " GB" }'

Keybase proof

I hereby claim:

  • I am colinmcintosh on github.
  • I am colinmcintosh (https://keybase.io/colinmcintosh) on keybase.
  • I have a public key whose fingerprint is 8677 7BE8 2F3B 4345 6B86 2837 B0BD 806E 5D45 F2FF

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am colinmcintosh on github.
  • I am colinmcintosh (https://keybase.io/colinmcintosh) on keybase.
  • I have a public key whose fingerprint is 8677 7BE8 2F3B 4345 6B86 2837 B0BD 806E 5D45 F2FF

To claim this, I am signing this object:

@colinmcintosh
colinmcintosh / freenas_jail_certbot_cloudflare
Created April 25, 2019 03:01
Configure a FreeBSD Jail for NGINX with LetsEncrypt including Auto-renewal using Cloudflare DNS
pkg install nginx
pkg update
pkg install vim py27-certbot py27-certbot-dns-cloudflare
mkdir ~/.secrets
vim ~/.secrets/cloudflare.ini
##### BEGIN INI FILE
# Cloudflare API credentials used by Certbot
dns_cloudflare_email = cloudflare-email@youremail.com
@colinmcintosh
colinmcintosh / ubuntu_nginx_certbot_cloudflare
Last active May 1, 2019 03:48
Configure Ubuntu 18.04 for NGINX with LetsEncrypt including Auto-renewal using Cloudflare DNS
adduser colin
usermod -aG sudo colin
sudo visudo
# %sudo ALL=(ALL:ALL) NOPASSWD: ALL
mkdir /home/colin/.ssh
cp ~/.ssh/authorized_keys /home/colin/.ssh/
chown -R colin:colin /home/colin/.ssh
exit
@colinmcintosh
colinmcintosh / yang_type.go
Last active February 14, 2020 06:28
This is an example of how to use github.com/openconfig/goyang to determine the modeled type of an OpenConfig path
// Copyright 2020 Netflix Inc
// Author: Colin McIntosh (colin@netflix.com)
// Copyright 2015 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
@colinmcintosh
colinmcintosh / octopi_certbot_haproxy_cloudflare
Created May 10, 2020 02:15
Configure Octopi with HA Proxy for LetsEncrypt including Auto-renewal using Cloudflare DNS
# Pre-reqs
sudo apt update
sudo apt upgrade -y
sudo apt install software-properties-common certbot python-certbot-nginx python-pip
sudo pip install -U pip
sudo pip install setuptools wheel
sudo pip install certbot-dns-cloudflare
# Setup your Cloudflare API credentials
sudo mkdir ~/.secrets
## First Terminal
[cmcintosh@Apogee ~/.../github.com/openconfig/gnmi-gateway:release] :) make run
rm -f gnmi-gateway
rm -f cover.out
go build -o gnmi-gateway -ldflags "-X github.com/openconfig/gnmi-gateway/gateway.Version="v0.8.0-8-gcc25dbc-cc25dbc" -X github.com/openconfig/gnmi-gateway/gateway.Buildtime=2020-11-22T01:14:39Z" .
./gnmi-gateway -version
gnmi-gateway version v0.8.0-8-gcc25dbc-cc25dbc (Built 2020-11-22T01:14:39Z)
./gnmi-gateway -EnableGNMIServer -ServerTLSCert=server.crt -ServerTLSKey=server.key -TargetLoaders=json -TargetJSONFile=targets.json
{"level":"info","time":"2020-11-21T17:14:45-08:00","message":"Starting GNMI Gateway."}
{"level":"info","time":"2020-11-21T17:14:45-08:00","message":"Clustering is NOT enabled. No locking or cluster coordination will happen."}