Skip to content

Instantly share code, notes, and snippets.

@mkows
mkows / modern_sql_style_guide.md
Created May 12, 2022 09:23 — forked from mattmc3/modern_sql_style_guide.md
Modern SQL Style Guide
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 December 20, 2021 21:21
Cloudbuild - docker detached (ping) - attempt
# 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 September 29, 2021 06:59
git - extract a directory into a separate repository
# 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 October 30, 2020 09:26
Handle jsonc (json with comments) with jq
# brew install jsmin
cat file-with-comments.jsonc | jsmin | jq 'keys'
@mkows
mkows / kill-8080
Last active October 13, 2020 11:01
Kill process on port (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 July 6, 2021 04:02
Using python3 on MacOS

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 July 31, 2019 15:16
Allow CORS with python Simple HTTP Server – for Python 3
'''
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 April 11, 2019 09:17
MacOS random notes

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
@mkows
mkows / gist:d6a6726b1cbea64574746366290506ce
Created November 13, 2018 17:21
pretty json in command line
echo '{"yo":"boo", "so":"no"}' | python -m json.tool
{
"so": "no",
"yo": "boo"
}
@mkows
mkows / load-resource.scala
Created November 5, 2018 16:57 — forked from banjeremy/load-resource.scala
scala: load files from resources directory
def loadResource(filename: String) = {
val source = scala.io.Source.fromURL(getClass.getResource(filename))
try source.mkString finally source.close()
}