Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeremy Forsythe jdforsythe

View GitHub Profile
@jdforsythe
jdforsythe / local-https-domains-dev-mac.sh
Last active Aug 10, 2020
Develop With Local HTTPs Domains
View local-https-domains-dev-mac.sh
#!/bin/bash
## https://gist.github.com/jdforsythe/09e9fd0dc7f75e7468fc48c9bc8b1598
##
## This will:
##
## 1. Install `mkcert` and create a self-signed CA and certificates for fake domains and trust them
## with the system's trust store. This allows you to develop using the same SSL/TLS techniques you
## would in production, bringing dev-prod parity and allowing things like cross-sub-domain secure
@jdforsythe
jdforsythe / find-parent.sh
Created Dec 5, 2019
Git find parent branch
View find-parent.sh
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//'
View config.yml
version: 2.1
orbs:
docker-publish: circleci/docker-publish@0.1.6
workflows:
build:
jobs:
- docker-publish/publish:
deploy: false
@jdforsythe
jdforsythe / join-json.sql
Created Jul 31, 2019
PostgreSQL JOINs as nested JSON objects
View join-json.sql
-- returns a child object with single parent as nested JSON object
--
-- {
-- "id": 155,
-- "name": "Stephen King",
-- "publisher": {
-- "id": 13,
-- "name": "Paladin Books"
-- }
-- }
@jdforsythe
jdforsythe / commit-siggy.sh
Last active Aug 3, 2020
Commit Signatures with GPG
View commit-siggy.sh
#!/usr/bin/env bash
## make sure /usr/local/sbin exists - it *should* be created by homebrew on install
if [ ! -d /usr/local/sbin ]; then
echo "Homebrew didn't create /usr/local/sbin - creating now..."
sudo mkdir /usr/local/sbin
sudo chown $(whoami):admin /usr/local/sbin
chmod 775 /usr/local/sbin
fi
@jdforsythe
jdforsythe / istio.sh
Last active Apr 11, 2019
Kubernetes on Minikube
View istio.sh
#!/usr/bin/env bash
##
## download minikube, kubectl, and istio and add istioctl to path
##
## these steps only need performed one time
##
brew install kubernetes-cli
brew cask install minikube
kubectl version
@jdforsythe
jdforsythe / .gitconfig
Created Mar 13, 2019
Git rename stash alias
View .gitconfig
[alias]
rename-stash = "!_() { if [ -z \"$1\" ] || [ -z \"$2\" ]; then echo \"git rename-stash 0 NewName\" && echo \"\" && git stash list && exit 1; else stash=\"stash@{$1}\"; rev=$(git rev-parse \"${stash}\"); git stash drop \"${stash}\" || exit 1; git stash store -m \"$2\" \"$rev\" || exit 1; git stash list; fi }; _"
@jdforsythe
jdforsythe / mac-build-pgmodeler.md
Last active Apr 2, 2020
Build pgmodeler on Mac with Homebrew-installed pg and openssl
View mac-build-pgmodeler.md

Building pgmodeler for Mac

Check requirements at https://pgmodeler.io/installation.

You will need Qt 5.9.x installed, full XCode installed, and homebrew installation of postgres and openssl.

The example below is v10.5 of PG and v5.9.6 of Qt, modify accordingly. Also, replace {{USERNAME}} with you Mac username.

The installation is the same as the instructions at the link above. There are a few path differences due to homebrew installation locations.

View encrypt-shell-script.sh
#!/bin/bash
scrypt(){
[ -n "$1" ] && {
echo '. <(echo "$(tail -n+2 $0 | base64 -d | mcrypt -dq)"); exit;' > $1.scrypt
cat $1 | mcrypt | base64 >> $1.scrypt
chmod +x $1.scrypt
}
}
View dd-tricks-copy-only-allocated-space.sh
#!/bin/bash
sudo fdisk -lu /dev/sdb
# Disk /dev/sdb: 14.9Gib, 1593153946 bytes, 31116288 sectors
# Units: sectors of 1 * 512 = 512 bytes
# Secor size (logical/physical): 512 bytes / 512 bytes
# I/O size (minimum/optimal): 512 bytes / 512 bytes
# Disklabel type: dos
# Disk identifier: 0x9c4e41cd
You can’t perform that action at this time.