Skip to content

Instantly share code, notes, and snippets.

View afeld's full-sized avatar

Aidan Feldman afeld

View GitHub Profile
@afeld
afeld / README.md
Created July 9, 2018 06:39
redact IP addresses in output

When running a command with output that will be publicly available, you may not want to show IP addresses. This might come up with output from a freemium continuous integration (CI) service like TravisCI or CircleCI, for example. Pipe output into the following command to redact the first three segments:

sed -E 's/[0-9]+\.[0-9]+\.[0-9]+\.([0-9]+)/███.███.███.\1/g'

The squares are the Unicode "full block" character. Example use:

$ ansible-playbook -i digital_ocean.py --list-hosts playbooks/test.yml | sed -E 's/[0-9]+\.[0-9]+\.[0-9]+\.([0-9]+)/███.███.███.\1/g'
@afeld
afeld / README.md
Last active July 27, 2022 14:24
ways to send me money
@afeld
afeld / mocks.go
Created February 22, 2018 19:46
example mocking in Golang
type APIClientIface interface {
CreateAccountInOrgUnit() bool
}
type RealAPIClient struct {}
func (ac RealAPIClient) CreateAccountInOrgUnit() bool {
// ...
}
@afeld
afeld / README.md
Last active April 20, 2018 15:59
Talk abstract: “Love and agony: containers in government”

This talk chronicles the love story of two star-crossed protagonists, containers and bureaucrats. Root for the pair as they muddle their way through the trials and tribulations of procurement, compliance, and answering the question of “so a container is a VM, right?” Can regulation and policy be overcome to unite the two in glorious harmony? Or will this just end up being another technological missed connection?

Slides

Outline

  • Why containers are desirable in heavily-regulated industries
  • Statistics around container adoption
  • Obstacles to adoption
  • Workstation installation
@afeld
afeld / README.md
Last active August 27, 2019 05:04
archive inactive GitHub repositories in an organization
@afeld
afeld / README.md
Last active March 27, 2017 20:29
get MySQL database connection information from environment variables in Python

While this code is for MySQLdb, it would be similar for most other Python database APIs. The corresponding environment variables, which are all optional:

  • DB_HOST
  • DB_PASSWD
  • DB_PORT
  • DB_USER
  • DB_UNIX_SOCKET

More information about these variables.

@afeld
afeld / README.md
Created November 10, 2016 06:47
attribute lists in Hugo (static site generator)

To create Kramdown-style attribute lists for adding HTML classes around blocks of Markdown, you can leverage Hugo shortcodes.

  1. Add the following to layouts/shortcodes/wrap.html:

    <div class="{{ range .Params }}{{ . }} {{ end }}">
      {{ .Inner }}
    </div>
@afeld
afeld / README.md
Last active March 8, 2022 18:40
automatic virtualenv switching

This script will automatically switch to a Python virtual environment after you cd into a Python project, then deactivate when you leave. Inspired by a similar script from Justin Abrahms.

Installation

  1. Install virtualenvwrapper.

  2. Download the auto_virtualenv.sh script, and put it in your home directory (~/).

  3. Run the following:

chmod a+x ~/auto_virtualenv.sh

@afeld
afeld / vision.rb
Last active December 11, 2016 21:59
face detection using the Google Cloud Vision API in Ruby
# Create a JSON service account key here:
#
# https://console.cloud.google.com/apis/credentials/serviceaccountkey
#
# then run with
#
# GOOGLE_APPLICATION_CREDENTIALS=<file>.json IMG=... ruby google.rb
#
# http://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/VisionV1/VisionService
#
@afeld
afeld / civictech.md
Last active April 2, 2024 15:45
civic tech jobs in NYC (or remote)