Skip to content

Instantly share code, notes, and snippets.

Aidan Feldman afeld

View GitHub Profile
@afeld
afeld / README.md
Last active Mar 19, 2020
running SQL against Google Sheets
View README.md

Google Sheets has a QUERY function that can be used for writing SQL queries. It uses the Google Visualization API Query Language, which is unfortunately a pretty limited SQL dialect. A few options for writing more complex SQL queries:

  • Export to CSV and load into a database somewhere
    • Pros: Use whatever database you want
    • Cons: Have to re-export every time the data is updated
  • Load into BigTable
    • Pros: Automatically updates
    • Cons: Requires some Google Cloud setup
  • Load into Google Colaboratory ("Colab")
    • Pros: Very flexible, as you can use SQL, Pandas, or any other Python code/packages
@afeld
afeld / domains.sh
Created Mar 9, 2020
get all domains (record sets) from all zones in an account in AWS Route53
View domains.sh
#!/bin/bash
set -eo pipefail
aws route53 list-hosted-zones --query 'HostedZones[].Id' | \
jq -r '.[]' | sed 's/\/hostedzone\///' \
| \
xargs -I zone_id \
aws route53 list-resource-record-sets \
--hosted-zone-id zone_id \
@afeld
afeld / README.md
Last active Mar 28, 2019
run SAS script from UNIX command line
View README.md

To use, put the script in a file on the machine you want to run SAS, then make it executable.

chmod +x run_sas.sh

After that, you can use it to run SAS scripts:

./run_sas.sh myscript.sas
@afeld
afeld / MY_Exceptions.php
Created Feb 10, 2019
StackDriver reporting for PHP CodeIgniter
View MY_Exceptions.php
<?php
use Google\Cloud\ErrorReporting\Bootstrap;
use Google\Cloud\Logging\LoggingClient;
use Google\Cloud\Core\Report\SimpleMetadataProvider;
// application/core/MY_Exceptions.php
class MY_Exceptions extends CI_Exceptions {
public function __construct()
@afeld
afeld / README.md
Created Sep 17, 2018
get list of properties from a JSON Schema
View README.md

Uses jq.

cat schema.json | \
  jq -r '[paths | join(".")] | .[]' | \
  grep 'properties\.\w\+$' | \
  sed 's/properties\.//g'

Example with this file:

@afeld
afeld / README.md
Created Jul 9, 2018
redact IP addresses in output
View README.md

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 Aug 22, 2018
ways to send me money
View README.md
@afeld
afeld / mocks.go
Created Feb 22, 2018
example mocking in Golang
View mocks.go
type APIClientIface interface {
CreateAccountInOrgUnit() bool
}
type RealAPIClient struct {}
func (ac RealAPIClient) CreateAccountInOrgUnit() bool {
// ...
}
@afeld
afeld / README.md
Last active Apr 20, 2018
Talk abstract: “Love and agony: containers in government”
View README.md

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 Aug 27, 2019
archive inactive GitHub repositories in an organization
You can’t perform that action at this time.