Skip to content

Instantly share code, notes, and snippets.

View modern_sql_style_guide.md
layout author title revision version description
default
mattmc3
Modern SQL Style Guide
2019-01-17
1.0.1
A guide to writing clean, clear, and consistent SQL.

Modern SQL Style Guide

@mkows
mkows / cloudbuild.yaml
Last active Dec 20, 2021
Cloudbuild - docker detached (ping) - attempt
View cloudbuild.yaml
# Connect to GCP Cloud Build docker (or docker compose) container from outside of docker from the subsequent step
#
# (For some reason, the below code requires "dockerize - wait" to work)
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['run', '--name', 'ping_svc', '--network', 'cloudbuild', '-d', 'jonmorehouse/ping-pong']
- name: 'jwilder/dockerize:0.6.1'
args: ['dockerize', '-timeout=60s', '-wait=http://ping_svc:8080']
- name: 'gcr.io/cloud-builders/curl'
@mkows
mkows / git-extract-dir-notes.sh
Last active Sep 29, 2021
git - extract a directory into a separate repository
View git-extract-dir-notes.sh
# using:
# - git filter-branch OR
# - git filter-repo
# extract folder into a new repo
git clone git@github.com:__ORG__/__PROJECT__.git __LOCAL_ALIAS_DIR__
cd __LOCAL_ALIAS_DIR__
git co -b main
@mkows
mkows / gist:60203538829f52f43834940c19f492f4
Created Oct 30, 2020
Handle jsonc (json with comments) with jq
View gist:60203538829f52f43834940c19f492f4
# brew install jsmin
cat file-with-comments.jsonc | jsmin | jq 'keys'
@mkows
mkows / kill-8080
Last active Oct 13, 2020
Kill process on port (8080)
View kill-8080
PROCESS_PHRASE="*:8080 (LISTEN)"
PROCESS_LINE=`lsof -Pn | grep "$PROCESS_PHRASE"`
if [[ -n $PROCESS_LINE ]]; then
PROCESS_ID=`awk '{print $2}' <<< $PROCESS_LINE`
echo "Killing process id=$PROCESS_ID ('$PROCESS_LINE')"
else
echo "No matching process found for '$PROCESS_PHRASE'"
fi
@mkows
mkows / py-on-mac.md
Last active Jul 6, 2021
Using python3 on MacOS
View py-on-mac.md

Prioritize Homebrew's python3 over default MacOS python2:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Install python3 with Homebrew:

brew install python
@mkows
mkows / server-cors.py
Created Jul 31, 2019
Allow CORS with python Simple HTTP Server – for Python 3
View server-cors.py
'''
Based on https://gist.github.com/enjalot/2904124 (in Python 2) -> quick-migrated to Python 3
Usage: python server-cors
'''
import http.server as httpserver
class CORSHTTPRequestHandler(httpserver.SimpleHTTPRequestHandler):
def send_head(self):
"""Common code for GET and HEAD commands.
@mkows
mkows / macos-random.md
Created Apr 11, 2019
MacOS random notes
View macos-random.md

dyld: Library not loaded

Problem

When running tig

$ tig
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
  Referenced from: /usr/local/bin/tig
  Reason: image not found
View gist:d6a6726b1cbea64574746366290506ce
echo '{"yo":"boo", "so":"no"}' | python -m json.tool
{
"so": "no",
"yo": "boo"
}
@mkows
mkows / load-resource.scala
Created Nov 5, 2018 — forked from banjeremy/load-resource.scala
scala: load files from resources directory
View load-resource.scala
def loadResource(filename: String) = {
val source = scala.io.Source.fromURL(getClass.getResource(filename))
try source.mkString finally source.close()
}