Skip to content

Instantly share code, notes, and snippets.

View smashwilson's full-sized avatar
🤖
HAPPINESS IS MANDATORY

Ash Wilson smashwilson

🤖
HAPPINESS IS MANDATORY
  • GitHub Staff
  • 23:21 (UTC -04:00)
View GitHub Profile
@smashwilson
smashwilson / update-lb.py
Created September 2, 2015 13:34
Update the condition of a load balancer node with libcloud
import os
import time
from libcloud.loadbalancer.types import State, Provider, MemberCondition
from libcloud.loadbalancer.providers import get_driver
username = os.environ['RACKSPACE_USERNAME']
apikey = os.environ['RACKSPACE_APIKEY']
region = os.environ['RACKSPACE_REGION']
@smashwilson
smashwilson / deconst-publish
Last active September 23, 2015 13:35
Manually publish Sphinx repositories to staging.developer.rackspace.com or developer.rackspace.com
#!/bin/bash
set -euo pipefail
help() {
cat <<EOM >&2
Usage: ${0} [-e staging] [-k APIKEY] [-p .]
-e env Choose the environment to submit to. Either "production" or "staging". Default: staging.
-k APIKEY Use the specified API key. Default: \${CONTENT_STORE_APIKEY}.
@smashwilson
smashwilson / nexus-deletion.md
Last active June 3, 2016 13:30
Content enumeration and deletion from Nexus

Prerequisites

Listing content

Before deleting content in production, it's a good idea to make sure you know what you're about to delete. You can list the content IDs that are currently present in Nexus by visiting the /content/ endpoint:

@smashwilson
smashwilson / localhost.py
Last active March 3, 2020 09:10
Dynamic inventory that sets ansible_python_interpreter for localhost correctly, even within a virtualenv
#!/usr/bin/env python
# Generate a "localhost" entry dynamically that uses a local connection and
# the same Python interpreter that's being used to execute this inventory
# script, which will work properly within a virtualenv.
import argparse
import json
import os
import sys
@smashwilson
smashwilson / keybase.md
Created November 17, 2016 16:07
keybase.md

Keybase proof

I hereby claim:

  • I am smashwilson on github.
  • I am smashwilson (https://keybase.io/smashwilson) on keybase.
  • I have a public key ASDLshtqX8WiFOwtiFfYbPxYTGL3C7GyWNdtPDlfPtGBhwo

To claim this, I am signing this object:

@smashwilson
smashwilson / ssh-pinentry.sh
Last active March 14, 2017 18:44
Use the GPG pinentry-mac app for SSH keys
#!/bin/sh
#
# chmod +x this script and set it as SSH_ASKPASS.
set -euo pipefail
urldecode() {
python -c 'import sys, urllib; sys.stdout.write(urllib.unquote(sys.stdin.read()))'
}
@smashwilson
smashwilson / thread-notes.md
Created October 3, 2017 01:45
Brainstorming possible Thread race conditions.

Thread states:

  • STOPPED

No state transitions are possible without the main thread initiating them. Sent messages are handled "offline." Depending on thread implementation, the offline command handler may:

  1. Alter private Thread state directly and acknowledge a command directly by producing an ack message on its output queue.
  2. Enqueue the command on the input queue and transition the Thread to STARTING.
  • STARTING
@smashwilson
smashwilson / init.js
Created February 13, 2018 19:10
Atom init.js
const util = require('util')
const {watchPath} = require('atom')
const commands = {}
function focusTracer (event) {
console.log('window.focus =', event.target)
}
commands['me:trace-focus'] = () => window.addEventListener('focusin', focusTracer)
@smashwilson
smashwilson / init.js
Last active April 29, 2020 17:45
Init script blurb to fold mocha, jasmine, or minitest tests down to the "it" blocks
atom.commands.add('atom-text-editor', 'me:fold-to-it', event => {
const editor = event.target.closest('atom-text-editor').getModel()
const languageMode = editor.getBuffer().getLanguageMode()
if (!languageMode.tree) return
editor.unfoldAll()
const startsWith = (node, text) => {
const startPosition = new Point(node.startPosition.row, node.startPosition.column)
const endPosition = startPosition.traverse([0, text.length])
@smashwilson
smashwilson / init.js
Created May 2, 2018 17:10
Init script to refactor @autoBind to autobind helper calls
atom.commands.add('atom-text-editor', 'me:copy-autobinds', event => {
const editor = event.target.closest('atom-text-editor').getModel()
const text = editor.getText();
const methodNames = [];
const rx = /@autobind\s*(async\s*)?([a-zA-Z_]+)/g
let match = rx.exec(text)
while (match !== null) {
methodNames.push(match[2])