Skip to content

Instantly share code, notes, and snippets.

View huntie's full-sized avatar

Alex Hunt huntie

View GitHub Profile
{
"type": "excalidraw",
"version": 2,
"source": "https://www.internalfb.com",
"elements": [
{
"type": "image",
"version": 94,
"versionNonce": 1580346530,
"isDeleted": false,
@huntie
huntie / start-or-reattach-tmux.sh
Created November 28, 2020 16:31
Start a tmux server if none exists, create a new session if tmux is in use, or reattach if no tmux sessions are connected - and exit after. Useful as the initial command for a terminal profile.
tmux ls | grep attached > /dev/null && tmux || tmux attach || tmux; exit
@huntie
huntie / yarn_licences_md_table.sh
Last active June 16, 2021 20:20 — forked from Radagaisus/ThirdPartyNoticesExample.md
Script to generate a Markdown table from `yarn licenses list`
#!/bin/sh
# Output a dependencies.md file with a table of installed Yarn dependencies
# Requires csvkit, jq
# https://csvkit.readthedocs.io/en/0.9.1/install.html
# https://stedolan.github.io/jq/download/
yarn licenses list --json \
| jq --slurp 'map(select(.type == "table"))' \
@huntie
huntie / aws-environment-concepts.md
Last active July 1, 2020 09:43
Notes outlining concepts for scoping and referring to environments in cloud applications. To accurately answer, "What is an environment?".

AWS environment concepts

Notes outlining concepts for scoping and referring to environments in cloud applications. To accurately answer, "What is an environment?".

Environment type

e.g. dev or prod

The application environment classification. This defines what external environments/services the app should be configured against, and therefore the people and resources who should have access.

@huntie
huntie / metro.config.js
Last active July 10, 2023 01:53
Snippets accompanying my article "A concise guide to configuring React Native with Yarn Workspaces" on Medium
/**
* Metro Bundler configuration
* https://facebook.github.io/metro/docs/en/configuration
*
* eslint-env node, es6
*/
const exclusionList = require('metro-config/src/defaults/exclusionList');
const getWorkspaces = require('get-yarn-workspaces');
const path = require('path');
@huntie
huntie / git-log-changed-files.sh
Created July 8, 2019 16:50
List on individual lines the file paths changed since a given Git revision
git log origin/master.. --name-only --pretty=format:
@huntie
huntie / webpack.config.js
Last active March 25, 2019 10:45
Load environment settings in a JavaScript project from a base .env and optional .env.<build-mode> file, using dotenv.parse (no side-effects)
const dotenv = require('dotenv');
const fs = require('fs');
const { flowRight, partial, unary } = require('lodash');
const path = require('path');
/**
* Load the environment settings for the current mode from `.env.{mode}` merged
* with any private entries defined in `.env` if present.
*
* @param {string} mode
@huntie
huntie / graphqlresource.py
Last active October 7, 2018 10:55
Implementation of a GraphQL HTTP server for Graphene as a Falcon API resource
import falcon
from typing import Tuple
import ujson
from .graphql import schema
class GraphQLNoQueryResolved(falcon.HTTPBadRequest):
"""
An exception indicating that a GraphQL query could not be resolved from the
incoming request. This will create an HTTP 400 response when raised.
"""
@huntie
huntie / unpack_module.py
Created May 31, 2018 10:42
A small reflection utility to access public module members as a dict
def unpack_module(module) -> dict:
"""
Return the members of an imported package or module explicitly exported
using __all__.
"""
return {k: module.__dict__[k] for k in module.__dict__.get('__all__', [])}
@huntie
huntie / certbot.md
Last active March 1, 2018 17:42
Issue and automate renewal of SSL certificates with Let's Encrypt using Certbot

Install Certbot and register Let's Encrypt account:

add-apt-repository ppa:certbot/certbot
apt update
apt install certbot
certbot register

Issue new SSL certificates for each host:

certbot certonly --webroot -w /var/www/alexhunt.io/ -d alexhunt.io -d www.alexhunt.io