Skip to content

Instantly share code, notes, and snippets.

@jcarley
jcarley / jsonmin
Created December 17, 2020 19:25
Minifies and escapes a json file. I use this for minifying json key files from GCP
#!/usr/bin/env bash
usage() {
echo "./jsonmin <INFILE> <OUTFILE>"
echo " INFILE: File to be minified"
echo " OUTIFLE: File to save minified json as"
}
INFILE=$1
OUTFILE=$2
@jcarley
jcarley / postman-pre-request01.js
Last active December 5, 2020 15:53
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse. Two approaches.
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
@jcarley
jcarley / .rubocop.yml
Last active December 4, 2020 04:41
Boilerplate Rubocopy yaml file
# The behavior of RuboCop can be controlled via the .rubocop.yml
# configuration file. It makes it possible to enable/disable
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
# See https://docs.rubocop.org/rubocop/configuration
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
},
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
service salt-minion stop
rm -f /etc/salt/pki/minion/minion_master.pub
echo "master: salt" > /etc/salt/minion
service salt-minion start
@jcarley
jcarley / assume-role-policy.json
Created February 28, 2018 15:00 — forked from clstokes/assume-role-policy.json
Example: Terraform IAM Role
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
@jcarley
jcarley / generate_docker_cert.sh
Created January 19, 2018 13:34 — forked from bradrydzewski/generate_docker_cert.sh
Generate trusted CA certificates for running Docker with HTTPS
#!/bin/bash
#
# Generates client and server certificates used to enable HTTPS
# remote authentication to a Docker daemon.
#
# See http://docs.docker.com/articles/https/
#
# To start the Docker Daemon:
#
# sudo docker -d \
@jcarley
jcarley / le-install.sh
Created January 17, 2018 17:59 — forked from hisnameisjimmy/le-install.sh
Unifi Controller one-shot install script for Ubuntu 16.04 with Lets Encrypt
#!/bin/sh
#
# This script stands on the shoulders of giants.
#
# It is written and tested for Ubuntu 16.04 on Digital Ocean using a 1GB droplet.
# Anything less than 1GB of memory may cause issues with anything memory intensive
# like imports/exports.
#
# It does the following:
# 1) Opens the appropriate ports for Unifi, SSH, Web/SSL traffic via iptables
FROM ruby:2.4.2
ENV DEBIAN_FRONTEND noninteractive
ENV TERM xterm
ADD bashrc /root/.bashrc
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" >> /etc/apt/sources.list.d/pgdg.list && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get -qqy update && \
@jcarley
jcarley / .babelrc
Created August 10, 2017 21:14 — forked from fdietz/.babelrc
Phoenix Framework Webpack Integration (replacing Brunch)
{
"presets": ["es2015", "react", "babel-preset-stage-0"]
}