Skip to content

Instantly share code, notes, and snippets.

Aidan Feldman afeld

Block or report user

Report or block afeld

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 Apr 5, 2019
archive inactive GitHub repositories in an organization
View README.md
  1. Install Ruby.

  2. Create a token.

  3. Install the dependencies.

    gem install activesupport octokit
  4. Run the script.

@afeld
afeld / README.md
Last active Mar 27, 2017
get MySQL database connection information from environment variables in Python
View README.md

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 Nov 10, 2016
attribute lists in Hugo (static site generator)
View README.md

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>
You can’t perform that action at this time.