Skip to content

Instantly share code, notes, and snippets.

@ahobson
ahobson / keybase.md
Created September 23, 2014 20:23
keybase

Keybase proof

I hereby claim:

  • I am ahobson on github.
  • I am ahobson (https://keybase.io/ahobson) on keybase.
  • I have a public key whose fingerprint is 59BA F6E0 F475 E91C 7761 C7E8 6CFD 6304 4BA3 F92C

To claim this, I am signing this object:

#!/bin/bash
#
# This script will mount /Users in the boot2docker VM using NFS (instead of the
# default vboxsf). It's probably not a good idea to run it while there are
# Docker containers running in boot2docker.
#
# Usage: sudo ./boot2docker-use-nfs.sh
#
#!/bin/bash
#
# This script will mount /Users in the boot2docker VM using NFS (instead of the
# default vboxsf). It's probably not a good idea to run it while there are
# Docker containers running in boot2docker.
#
# Usage: sudo ./boot2docker-use-nfs.sh
#
@ahobson
ahobson / pre-commit
Created May 15, 2019 14:33
pre-commit
#!/bin/bash
set -euo pipefail
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
rootdir="$(cd $scriptdir/../.. > /dev/null 2>&1 && pwd)"
circleconfig="${rootdir}/.circleci/config.yml"
image=$(ruby -ryaml -e 'puts YAML.load_file(ARGV.last).dig("jobs","build","docker", 0, "image")' $circleconfig)
@ahobson
ahobson / docker_commands.txt
Last active July 15, 2020 20:56
Dockerfile show interaction between entrypoint and cmd
# This is what the Dockerfile looks like
$ cat Dockerfile
FROM bash
ENTRYPOINT ["/bin/ls"]
CMD ["-l"]
# Build the image so we can experiment
$ docker build -t mybashls .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM bash
version: 2
jobs:
build:
docker:
- image: circleci/node:12.16.2
working_directory: ~/react-uswds
steps:
- checkout
- restore_cache:
keys:
import accessabilityNewSprite from 'uswds/src/img/sprite.svg#accessibility_new'
export const icons = {
accessibilityNew: accessabilityNewSprite,
}
@ahobson
ahobson / makefile_not_for_me.md
Created August 12, 2021 20:53
Makefiles are not for me

I'm not a big fan of Makefiles as entrypoints for a project.

  1. There's no way to pass command line arguments other than environment variables and there's no way to report per subcommand options
  2. There's no code reuse. If you have common functionality that you want to share (e.g. starting a dev db vs a test db) but with some parameters slightly different, there's no good way to do that in a Makefile
  3. The syntax is inscrutable. How do you run a shell command sending it a multi line command (for readability)? I tried for about an hour before giving up and writing an external shell script. MilMove has an entire directory of scripts for this reason. Even better, on MilMove those scripts call back out the the Makefile.
  4. Makefiles were needed for C/C++ because you recompiled individual files. There's even a command $(CC) $(CFLAGS) -MM that generates Makefile compatible syntax so that only necessary files are rebuilt. Modern languages don't work that way: they provide a single command that recompiles all n
@ahobson
ahobson / cra-uswds-sccs-test.sh
Last active April 8, 2022 15:29
cra 5.0 + sass + uswds = ???
$ npx create-react-app uswds-sccs-test
$ yarn add sass uswds nprogress
$ mv src/App.css src/App.scss
# edit App.js to change App.css to App.scss
$ yarn build
# everything is ok
$ echo "@import '~nprogress/nprogress';" >> src/App.scss
$ yarn build
# everything is ok
$ echo "@import '~uswds/src/stylesheets/theme/_uswds-theme-general.scss';" >> src/App.scss
@ahobson
ahobson / spa_handler.go
Created October 4, 2022 14:34
SPA Handler with neutered filesystem to not show directory listings
package handlers
import (
"net/http"
"os"
"path/filepath"
"github.com/transcom/mymove/pkg/logging"
)