Skip to content

Instantly share code, notes, and snippets.

mkows /
Last active Sep 29, 2021
git - extract a directory into a separate repository
# using:
# - git filter-branch OR
# - git filter-repo
# extract folder into a new repo
git clone __LOCAL_ALIAS_DIR__
git co -b main
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 / kill-8080
Last active Oct 13, 2020
Kill process on port (8080)
View kill-8080
if [[ -n $PROCESS_LINE ]]; then
PROCESS_ID=`awk '{print $2}' <<< $PROCESS_LINE`
echo "Killing process id=$PROCESS_ID ('$PROCESS_LINE')"
echo "No matching process found for '$PROCESS_PHRASE'"
mkows /
Last active Jul 6, 2021
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 /
Created Jul 31, 2019
Allow CORS with python Simple HTTP Server – for Python 3
Based on (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 /
Created Apr 11, 2019
MacOS random notes

dyld: Library not loaded


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 / 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 =
try source.mkString finally source.close()
mkows /
Created Jun 22, 2018
Initialize git repository in a current dir (with .gitignore,
# Usage: ./
# NOTE: Run within your project directory
# .gitignore
cat > .gitignore << EOF
mkows / .travis.yml
Created Dec 18, 2017
TravisCI: Specify custom MongoDB version
View .travis.yml
# e.g. for MongoDB 2.6
# Follows MongoDB for Ubuntu installation
# note: `--allow-downgrades` flag for apt-get install may be required
language: scala
scala: 2.11.11
jdk: openjdk8