Skip to content

Instantly share code, notes, and snippets.

@mearns
mearns / .gitconfig
Last active March 22, 2023 15:44
Git config
# This is Git's per-user configuration file.
[user]
name = Brian Mearns
email = bmearns@pagerduty.com
[core]
# Don't do paging; if you want to page, pipe the output into less (or your pager of choice).
pager = cat
# These are custom named "pretty formats" for printing information about commits, such as for `git log`.
@mearns
mearns / README.md
Last active October 28, 2021 15:11
Brian's Software Principles

This is a rough sketch of some of my generally-held principles for writing software and designing/implementing software systems. YMMV, and so may mine. I reserve the right to deny ever having said any of this.

Like all the best principles, these are only meant to get you thinking, not as hard and fast rules.

TOC

@mearns
mearns / error-utils.js
Last active November 5, 2020 13:49
Error Utilities for JavaScript (NodeJS)
/*
* Create a new Error to wrap another Error.
*
* @params {Error} cause The error you want to wrap
* @params {string} [name] Optionally specify the `name` property for the error. You can also
* specify a `name` property in the `props` arg. If neither is given, the name of the given `cause` is
* used.
* @params {string} [message] Optionally specify the `message` property for the error. You can also
* specify a `message` property in the `props` arg. If neither is given, the `message` of the given `cause` is
* used.
@mearns
mearns / list-global-binaries.bash
Created November 3, 2020 15:53
View Globally Installed Npm Binaries
(
for f in $( ls -l $( dirname $( which node ) ) | grep -- '->' | sed -e 's/.*-> \(..*\)/\1/' );
do dirname $f;
done
) | sort -u | sed -e 's/\.\.\/lib\/node_modules\///'
@mearns
mearns / README.md
Last active August 3, 2020 14:07
EC2 Get credentials

You can get AWS credentials from your EC2 instance using this script. However, you can't just run this, you need to source it, like:

> . get-creds.sh

And you need to have jq installed.

Use

@mearns
mearns / how-to.md
Last active November 28, 2022 20:25
Some tips for creating useful presentations

How I Create Presentations (sometimes)

I've spent a fair amount of time creating presentations, especially technical and semi-technical presentations in the field of software development. These are some of the strategies I typically employ for doing so.

  1. Start with a narrative. I don't create slides initially, I write it out in prose, often using something like Dropbox Paper. I write it basically like I hope it will sound when I do present it; a presentation should sound natural, it shouldn't sound like you're working your way through slides. Remember, your slides are visual aids: you are the presentation, people came to hear you talk. If you're just going to read off of your slides, you might as well just share the slides and skip the presentation all together. So

Say you have an npm project with a start script in package.json. You can run this and pass commands to it like:

npm start --silent -- ARG1 ARG2 ARG3

(using --silent because you probably don't want to see NPM's boilerplate error message if your script fails).

But that's a little tedious to add all those extra bits, and for people trying to use your tool who aren't real familiar with npm, they might not know to -- before the script arguments. So just drop this bash script into

@mearns
mearns / README.md
Last active October 17, 2019 01:52
Software Ascending Carbon Settings

Carbon config for Software Ascending

Import as config to https://carbon.now.sh/, for creation of code snippets for submissions to Software Ascending

Use full-bleed.json for a header/featured image on your article.

Use in-article-full-width.json for snippets within the article, set the image in Medium to "overflow" width.

@mearns
mearns / template.js
Last active May 25, 2019 02:25
CloudFormation template for API Gateway Hostname Discovery
"Resources": {
"ApiGatewayRestApi": {
"Type": "AWS::ApiGateway::RestApi",
"Properties": { /* ... */ }
},
"ApiHostParam": {
"Type": "AWS::SSM::Parameter",
"Properties": {
"Name": {
"Fn::Sub": "/some/unique/path/probably/including/${App}/${Stage}/hostname",
@mearns
mearns / policy.js
Created May 24, 2019 20:37
Resource Policy for Private API Gateway
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "arn:aws:execute-api:${REGION}:${ACCOUNT_ID}:*/*",
"Condition": {
"StringEquals": {