Skip to content

Instantly share code, notes, and snippets.

View harto's full-sized avatar
🍕
🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕

Stuart Campbell harto

🍕
🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕🍕
View GitHub Profile
@harto
harto / validate-mapbox-expression
Last active April 12, 2023 12:01
Validate a partial Mapbox style expression
#!/usr/bin/env bash
set -euo pipefail
# Check a partial Mapbox style expression using gl-style-validate
# (https://github.com/mapbox/mapbox-gl-js/tree/master/src/style-spec).
#
# To install gl-style-validate:
# $ npm install @mapbox/mapbox-gl-style-spec --global
#
# Usage:
@harto
harto / before.js
Created April 20, 2016 17:33
Mocha before() & beforeEach() execution order with nested describe()
'use strict';
describe('mocha before hooks', function () {
before(() => console.log('*** top-level before()'));
beforeEach(() => console.log('*** top-level beforeEach()'));
describe('nesting', function () {
before(() => console.log('*** nested before()'));
beforeEach(() => console.log('*** nested beforeEach()'));
it('is a nested spec', () => true);
});
@harto
harto / find-deps.sh
Created April 1, 2016 02:12
List local JS module dependencies
#!/usr/bin/env bash
set -euo pipefail
absolutize() {
local path=$1
if [[ -d $path ]]; then
(cd $path; pwd -P)
else
echo $(cd $(dirname $path); pwd -P)/$(basename $path)
fi
@harto
harto / npm-project-path.bash
Last active August 29, 2015 14:16
$PATH manager for npm projects
npm-activate() {
npm-deactivate
export __NPM_PROJECT_BINS=$(__npm-project-bins $1)
export PATH=$__NPM_PROJECT_BINS:$PATH
}
npm-deactivate() {
if [[ -n $__NPM_PROJECT_BINS ]]; then
export PATH=${PATH#$__NPM_PROJECT_BINS:}
fi
@harto
harto / profiles.bash
Last active August 29, 2015 14:15
Ghetto AWS credential management
PROFILES_DIR="$HOME/.aws/profiles.d"
CREDENTIALS="$HOME/.aws/credentials"
aws-profile() {
local profile="$1"
if [[ -z $profile ]]; then
__aws-profile-usage >&2
else
__aws-switch-profile $profile
@harto
harto / reproduce-bundler-issue.sh
Last active August 29, 2015 14:15
Reproduce apparent Bundler issue
#!/bin/bash
set -euo pipefail
ISSUE=bundler-path-source-conflict
TMPDIR="/tmp/${ISSUE}"
mkdir -p "$TMPDIR"
cd "$TMPDIR"

Keybase proof

I hereby claim:

  • I am harto on github.
  • I am harto (https://keybase.io/harto) on keybase.
  • I have a public key whose fingerprint is C7BB 1865 8EFF 2331 E11F CE59 35D0 32C6 F5E4 0AC2

To claim this, I am signing this object:

@harto
harto / make-dockerfile.sh
Created April 14, 2014 01:38
42 layer image test
#!/bin/bash
# Test 42-layer image on EC2.
#
# Relevant info:
#
# ubuntu@domU-12-31-38-04-C2-78:~/layer-test$ docker info
# Containers: 145
# Images: 798
# Storage Driver: aufs
@harto
harto / install-buildbox.sh
Last active August 29, 2015 13:56
Install Buildbox agent
#!/bin/bash
set -e
set -x
# Install Buildbox Ruby agent as a service
if [ -z "$BUILDBOX_API_TOKEN" ]; then
echo "Must specify BUILDBOX_API_TOKEN env"
exit 1
@harto
harto / install-docker.sh
Last active August 29, 2015 13:56
Install Docker
#!/bin/bash
set -e
set -x
# Install Docker package
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sh -c 'echo deb https://get.docker.io/ubuntu docker main >/etc/apt/sources.list.d/docker.list'
apt-get -y update