Skip to content

Instantly share code, notes, and snippets.

View nickcharlton's full-sized avatar

Nick Charlton nickcharlton

View GitHub Profile
@nickcharlton
nickcharlton / blocking-request.js
Created April 19, 2018 09:54
Node: Synchronous/Blocking HTTP Request
// In the rare case you actually want a syncronous request
// this will wait until the data arrives before continuing
// down the file.
//
// The service where this is used fetches configuration data
// from an external service in order to run.
const axios = require('axios')
let done = false
@nickcharlton
nickcharlton / validate_method.rb
Created March 16, 2018 11:58
Validate attributes have a value
class Resource
def validate
missing = self.class.required_attributes[self.class.name].select do |key|
instance_variable_get("@#{key}").nil?
end
if missing.any?
raise StandardError, "Missing attributes: #{missing.join(', ')}"
end
end
@nickcharlton
nickcharlton / README.md
Created January 14, 2018 20:48
Find disk images (*.vmdk files) as stored on VMware ESXi

This is a particularly knarly problem, as assuming you just want to write a shell script that operates on the local system, it's very difficult to achieve.

This gives the following output when run:

/vmfs/volumes/5a551f9a-fc78330f-f85f-000c290b7d1b/debian-9-x64/debian-9-x64.vmdk
/vmfs/volumes/5a551f9a-fc78330f-f85f-000c290b7d1b/ubuntu-1604-x64/ubuntu-1604-x64.vmdk

/vmfs/volumes/5a551f9a-fc78330f-f85f-000c290b7d1b/ubuntu-1604-x64/ubuntu-1604-x64-000002.vmdk
@nickcharlton
nickcharlton / README.md
Last active December 6, 2017 09:52
Installing postgis valid for PostgreSQL 9.6.2 w/Homebrew

Installing PostGIS valid for PostgreSQL 9.6.2

PostGIS marks PostgreSQL as a dependency. As I write this Postgres 10 has just been released, but we don't yet want that as it'd be far ahead of Heroku Postgres.

To be able to install a valid PostGIS for 9.6.2 we need to do something like this:

% cd $(brew --repo homebrew/core)

netcalc

netcalc is an extraction of Terraform's string interpolation methods for handling CIDR network strings. It uses [go-cidr][] so that the output would be exactly the same as the original.

I threw this together to allow me to understand the kinds of network a [few][example1] [examples][example2] of [Kubernetes][] ended up constructing.

@nickcharlton
nickcharlton / Gemfile
Created November 1, 2016 14:22
Base Fastlane Example (which I base most implementations on).
source "https://rubygems.org"
gem "fastlane"
@nickcharlton
nickcharlton / debian.cfg
Created September 22, 2016 11:20
Preseed file for Debian 8
#
# Based upon: https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt
#
# localisation
d-i debian-installer/locale string en_US.utf8
d-i console-keymaps-at/keymap select us
# networking
d-i netcfg/choose_interface select auto
@nickcharlton
nickcharlton / resolve_jenkins_dependencies.sh
Created September 8, 2016 04:31
Recursively resolve Jenkins dependencies.
#!/bin/bash
set -e
plugin_dir=~/.jenkins/plugins
installed=()
discovered_dependencies=()
dependencies_to_install=()
mkdir -p $plugin_dir
@nickcharlton
nickcharlton / new_bamboo_github_accounts.rb
Last active May 5, 2016 11:31
A quick script to write out a list of New Bamboo GitHub accounts.
require "octokit"
require "csv"
Octokit.configure do |c|
c.login = "nickcharlton"
c.password = ENV["HOMEBREW_GITHUB_API_TOKEN"]
end
Octokit.auto_paginate = true
@nickcharlton
nickcharlton / mysql.sh
Created April 11, 2016 15:54
Create a local instance of MySQL for Vagrant which allows external connections.
#!/bin/bash
# set a root password of "vagrant"
debconf-set-selections <<< "mysql-server mysql-server/root_password password vagrant"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password vagrant"
apt-get install -qy libmysqlclient-dev mysql-server-5.5
# enable listening on all addresses
sed -i.bak "s/bind-address\s*= 127.0.0.1/bind-address = 0.0.0.0/g" /etc/mysql/my.cnf