Skip to content

Instantly share code, notes, and snippets.

View notbrain's full-sized avatar

Brian Ross notbrain

View GitHub Profile
@notbrain
notbrain / BeforeExitListener.js
Created August 23, 2020 19:11
Lambda NodeJS 12.18 Default Runtime JavaScript
/** Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
"use strict";
/**
* The runtime has a single beforeExit function which is stored in the global
* object with a symbol key.
* The symbol is not exported.
* The process.beforeExit listener is setup in index.js along with all other
* top-level process event listeners.
OLD_BRANCH=$(git rev-parse --abbrev-ref HEAD)
NEW_BRANCH=$1
git branch -m $OLD_BRANCH $NEW_BRANCH # Rename branch locally
git push origin :$OLD_BRANCH # Delete the old branch
git push --set-upstream origin $NEW_BRANCH # Push the new branch, set local branch to track the new remote
@notbrain
notbrain / apigw-logging-sam-template.yaml
Created July 14, 2019 14:52
Simple Chat App: Attempt to add APIGatewayV2 logging
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Regional API Gateway Logging Role Setup
Resources:
APIGatewayLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: 'apigw-log-group'
RetentionInDays: 7
@notbrain
notbrain / plist_daemon_ctl
Last active December 27, 2017 22:08
control script for stopping and restarting macOS launchctl agents
#!/bin/bash -e
# Why is there no launchtl restart or reload? Tsk.
#
cmd=$1
plistfile="$HOME/Library/LaunchAgents/homebrew.mxcl.mariadb.plist";
ps_grep_string="mysql";
function ps_grep() {
ps aux | grep -e $ps_grep_string | grep -v 'grep';
}
@notbrain
notbrain / pm2-pm2user.conf
Last active April 18, 2017 20:34
plist file to run pm2 as pm2user on macOS with environment variables, linux systemd override.conf
[Service]
Environment="MYSQL_CONN=-h mydb.domain.com -u dbadmin -pnotastrongpassword database_name"
Environment="SLACK_TOKEN=xoxb-94849484948-jfhJSdlobYIFfeFBFYHckiUUJHW19v0F"
@notbrain
notbrain / keybase.md
Created December 16, 2016 21:42
keybase.io github ownership

Keybase proof

I hereby claim:

  • I am notbrain on github.
  • I am notbrain (https://keybase.io/notbrain) on keybase.
  • I have a public key whose fingerprint is 3804 0DD4 4509 5CED B78B 2299 0974 D0AB 6B05 3450

To claim this, I am signing this object:

[
{
"featureType": "water",
"stylers": [
{ "color": "#333333" }
]
},{
"featureType": "landscape.natural.landcover",
"stylers": [
{ "color": "#c6c8fa" }
@notbrain
notbrain / selfie-cert.sh
Last active November 5, 2015 03:24
Quick script for making self-signed certificates
#!/bin/sh
APP_NAME=$1
APPSSLPATH=/usr/local/etc/nginx/$APP_NAME;
sudo mkdir -p $APPSSLPATH && cd $APPSSLPATH;
sudo openssl req -new -newkey rsa:2048 -nodes -out $APP_NAME.csr -keyout $APP_NAME.key -subj "/C=US/ST=California/L=San Francisco/O=Engineering Inc./CN=$APP_NAME" && \
sudo /usr/bin/openssl x509 -req -days 1365 -in $APP_NAME.csr -signkey $APP_NAME.key -out $APP_NAME.crt;
@notbrain
notbrain / installinone.sh
Last active September 25, 2017 01:19
ubuntu 16.04 LTS mongodb_3.2 mariadb_10.1 nginx_ppa-stable nodejs_6 git build-essential all in one installer
#!/bin/bash
# all in one non-interactive runner
export DEBIAN_FRONTEND=noninteractive;
sudo DEBIAN_FRONTEND=noninteractive apt-get update -y;
sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y;
# build-essential
sudo apt-get install -y build-essential;
@notbrain
notbrain / mongod.conf.yml
Last active August 29, 2015 14:21
mongod yaml config file
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
systemLog:
destination: file
path: /var/log/mongodb/mongod.log
logAppend: true
logRotate: rename