Skip to content

Instantly share code, notes, and snippets.

View pj's full-sized avatar

Paul Johnson pj

  • San Francisco, CA
View GitHub Profile
pj / debug.log
Created April 22, 2023 04:24
Terraform docker error when using gcloud cred helpers.
2023-04-21T21:23:38.734-0700 [INFO] Terraform version: 1.4.5
2023-04-21T21:23:38.734-0700 [DEBUG] using v1.18.0
2023-04-21T21:23:38.734-0700 [DEBUG] using v2.16.2
2023-04-21T21:23:38.734-0700 [DEBUG] using v0.0.0-20210209133302-4fd17a0faac2
2023-04-21T21:23:38.734-0700 [DEBUG] using v0.1.0
2023-04-21T21:23:38.734-0700 [DEBUG] using v1.12.1
2023-04-21T21:23:38.734-0700 [INFO] Go runtime version: go1.19.6
2023-04-21T21:23:38.734-0700 [INFO] CLI args: []string{"./terraform", "plan"}
2023-04-21T21:23:38.734-0700 [DEBUG] Attempting to open CLI config file: /Users/pauljohnson/.terraformrc
2023-04-21T21:23:38.735-0700 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
pj / generate_terraform.go
Created August 25, 2022 02:57
Simple go program for generating terraform files from cue definitions.
// Apply @generate_terraform_variables(filename="") to a definition you want to output as a variables file.
package main
import (
pj / disable_local_ssd_formatting.ts
Created February 16, 2022 16:19
Script to stop GKE formatting local SSDs when initializing a node.
import compute, { protos } from '@google-cloud/compute';
import axios from 'axios';
import util from 'util';
import * as child_process from 'child-process-promise'
import { ZoneOperationsClient } from '@google-cloud/compute/build/src/v1';
import { sleep } from '../utils';
import { hasUncaughtExceptionCaptureCallback } from 'process';
type InstanceTemplate =;
type InstanceGroupManager =;
# Unlike MutableMapping, dict has it's own implementation of get() that doesn't use __getitem__ underneath. This will cause your subclass to return None unexpectedly, unless you don't implement get() as well. Probably better to just subclass MutableMapping :-).
# example code:
def test_dict_subclass_get_method():
import collections
# WORKS: class Hello(collections.MutableMapping):
class Hello(dict):
def __init__(self, underlying):
super(Hello, self).__init__()
self._underlying = underlying
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Define our MAAS instance
config.vm.define "controller", primary: true do |maas| = "bento/ubuntu-16.04"
maas.vm.hostname = "controller" :private_network, ip: '' :forwarded_port, guest: 5240, host: 5240
var NUMBER_CHARS = "0123456789";
var WHITESPACE_CHARS = ' \r\n\t';
function lex(input) {
var i = 0;
var tokens = [];
while(i < input.length) {
var c = input[i];
pj / x_ray_element_properties.js
Created February 24, 2016 08:44
node js x-ray accessing selected element properties
var html = `<html>
<div id="someId">
<a href="">Page 1</a>
<a href="">Page 2</a>
// If you have html like the above and you want to access properties of the links that
2015-08-24 - NAB - If you are running Kibana in windows and have a proxy set in your environment variables and try to run kibana it will try to go through the proxy to connect to elastic search, to fix this unset the variable in the kibana.bat file:
@echo off
set http_proxy=
set https_proxy=
pj / gist:b3daace52dfa218cd444
Created May 5, 2015 22:36
Scala Future example
Yep Futures/Promises are monads, in scala you'll often see code like:
val foo = for {
someResult <- doSomethingAsync(someArgument);
someOtherResult <- doAnotherThingAsync(someResult);
finalResult <- yetAnotherAsyncThing(someOtherResult);
} yield (finalResult)
foo.recover {
case SomeException e => "Something Went Wrong!"
pj / gist:9d226b62b7f138802954
Created October 18, 2014 16:08
Order of BeforeAndAfterAll and OneAppPerSuite in scalatest with play and reactive couchbase
// To use PlayCouchbase in before or after methods the traits have to be in this order...
class FacebookServiceSpec extends PlaySpec with BeforeAndAfterAll with OneAppPerSuite {
override def beforeAll = {
val bucket = PlayCouchbase.bucket("default")
// ... Not like this
class FacebookServiceSpec extends PlaySpec with OneAppPerSuite with BeforeAndAfterAll {
override def beforeAll = {