Skip to content

Instantly share code, notes, and snippets.

View talarczykco's full-sized avatar

Michael Talarczyk talarczykco

View GitHub Profile
@talarczykco
talarczykco / provision-proxmox-template.sh
Last active September 14, 2022 00:57
Provision a Proxmox VM template from an Ubuntu cloud image
#!/bin/bash
# https://gist.github.com/talarczykco/d4cfc9188a061f68880ee5b630a4aeb6
# https://pve.proxmox.com/wiki/Cloud-Init_Support
set -ex
IMGURL=https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
IMGDIR=etc
IMGFILE=$(basename $IMGURL)
@talarczykco
talarczykco / setup-python-logging.py
Last active August 12, 2020 18:22
Setup Python logging
# Created this after googling for:
# - python logging replace handler
# - python logging basicconfig not working
# - python logging getlogger
def get_logger(level='DEBUG'):
loghandler = logging.StreamHandler()
logfmt = logging.Formatter(fmt='%(asctime)s:%(name)s:%(levelname)s:%(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
logger = logging.getLogger() # get root logger, not __name__
loghandler.setFormatter(logfmt)
@talarczykco
talarczykco / install-old-homebrew-formulas.md
Last active March 13, 2023 12:44
How to install old versions of Homebrew formulas and switch between them

This example uses istioctl as the formula, but this may come in handy for kubernetes-cli, kubernetes-helm, etc.

  1. Find the formula for your executable, e.g. istioctl, and click on the link to GitHub:
    brew info istioctl | grep Formula
    
  2. Click "Blame" button ("History" will be too large to display).
  3. Hopefully, you can find an earlier versioned commit message... click on it.
  4. Click ... in upper-right of next page, select "View File" from drop-down.
  5. Right-click "Raw" button, and Copy URL Address.

From your iOS device, go to Photos, then:

  • Select
  • Select All
  • Share (box w/arrow)
  • Save Images
  • Save to Camera Roll
  • ... then plug your iOS device into your Mac and upload the photos to a known location
  • Disable My Photo Stream in settings on all your devices
@talarczykco
talarczykco / create-eks-cluster.md
Last active August 23, 2018 18:14
Create an EKS cluster

Creating an EKS Cluster

Configure aws credentials:

brew install awscli
aws configure

Install eksctl and create cluster:

@talarczykco
talarczykco / elasticsearch.exceptions.ElasticsearchException-fix.md
Last active November 17, 2017 20:12
elasticsearch.exceptions.ElasticsearchException: Unable to create client connection to Elasticsearch. Error: Root certificates are missing for certificate validation. Either pass them in using the ca_certs parameter or install certifi to use it automatically

If you use elasticsearch-curator on AWS (or possibly other hosted or self-hosted Elasticsearch installations that use SSL,) and you get this when curating:

elasticsearch.exceptions.ElasticsearchException: Unable to create client connection to Elasticsearch. Error: Root certificates are missing for certificate validation. Either pass them in using the ca_certs parameter or install certifi to use it automatically.

Then make sure the client.use_ssl key is present and True. This is a non-obvious error that led me down a rathole of Googling. Don't bother specifying root certificates, or installing certifi (it's probably already installed, if you installed elasticsearch-curator with pip.)

---
# https://www.elastic.co/guide/en/elasticsearch/client/curator/current/configfile.html
client:
@talarczykco
talarczykco / Postfix on macOS.md
Last active October 3, 2017 15:53
How to get Postfix sending mail from my MacBook

Postfix on macOS

Sierra - 10.12.6

  1. Create a new app password in Gmail for Postfix (Optional - this is required only if you have 2-Step Verification enabled.)

  2. Edit /etc/postfix/sasl_passwd with your username and app password:

     smtp.gmail.com:587 yourname@gmail.com:CHANGEME
    

rsnapshot on macOS

Install

Run the following:

brew install rsnapshot
sudo perl -MCPAN -e'install Lchown'

Configure

#!/usr/bin/env ruby
# https://github.com/chef/mixlib-cli
# https://github.com/rest-client/rest-client
# https://github.com/sensu-plugins/sensu-plugin
require "json"
require "netrc"
require "rest-client"
require "sensu-plugin/check/cli"
#!/usr/bin/env ruby
# https://gist.github.com/mijit/72d31e53156fe82cecf8dc8c71421280
require 'thor'
module App
class Foo < Thor
desc "bar", "do some bar thing"
def bar