Skip to content

Instantly share code, notes, and snippets.


Karl Horky karlhorky

View GitHub Profile
# First, remove all the folders in the npx cache location
rm -rf $(npm get cache)/_npx/*
karlhorky /
Created Jan 5, 2021 — forked from troyfontaine/
Signing your Git Commits using GPG on MacOS Sierra/High Sierra

Methods of Signing with GPG

There are now two ways to approach this:

  1. Using gpg and generating keys
  2. Using Kryptonite by

This Gist explains how to do this using gpg in a step-by-step fashion. Kryptonite is actually wickedly easy to use-but you will still need to follow the instructions

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing with either GPG or

karlhorky / index.mdx
Created Sep 9, 2020
Prettier MDX Bug with React Components with Blank Lines
View index.mdx



karlhorky / prettier-runkit-html-runkit.js
Created Aug 28, 2020
Prettify Runkit HTML Output with Prettier
View prettier-runkit-html-runkit.js
// Prettify Runkit HTML
// (Not relevant for demo)
const html = '<div id="a">asdf</div>';
const prettier = require("prettier");
'<pre>' +
.format(html, {parser: 'html', htmlWhitespaceSensitivity: 'ignore'})
.replace(/</g, '&lt;') +
karlhorky / find-react-child-recursively.js
Created Jun 13, 2020
Find React Child in Children Recursively Using a Find Function
View find-react-child-recursively.js
import React from 'react';
export function findReactChildRecursively(children, findFunction) {
const found = React.Children.toArray(children).find(findFunction);
if (found) {
return true;
} else if (children?.props?.children) {
View .bash_profile
alias ...=../..
alias ....=../../..
alias .....=../../../..
alias ......=../../../../..
alias 1='cd -'
alias 2='cd -2'
alias 3='cd -3'
alias 4='cd -4'
alias 5='cd -5'
alias 6='cd -6'
karlhorky /
Created Jan 30, 2020 — forked from pspi/
Calculate ratio of single quotes to double quotes in .js and .ts files
#!/usr/bin/env bash
# - DRY relevant parts
singlequotes=`find -type f \( -iname \*.js -o -iname \*.ts \) -not -path '*node_modules/*' -exec cat \{\} \; | tr -cd \' | wc -c`
doublequotes=`find -type f \( -iname \*.js -o -iname \*.ts \) -not -path '*node_modules/*' -exec cat \{\} \; | tr -cd '"' | wc -c`
total=$(($singlequotes + $doublequotes))

Authentication with an Express API and Postgres

Setting Up

Let's make sure our Express app has the required base modules:

# within root of API
npm install --save express pg knex bcrypt
npm install --save-dev nodemon
  1. Set up a docker-compose.yaml file (file content at the bottom of this page).

  2. Also create a data/mysql folder in your project.

  3. In order to set up a volume for MySQL in Docker Toolbox, we will need a VirtualBox Shared Folder, just like mentioned in Fixing Volumes in Docker Toolbox.

    VirtualBox by default has a c/Users Shared Folder that we can use for this (as long as your project is within C:\Users. Verify that this shared folder is set up properly:


  4. Add a new volume to the mydatabase service in the docker-compose.yaml for the database files. Because we are using docker-toolbox and VirtualBox, we need an absolute path, starting with //c/:

       - //c/Users/your_username/projects/wordpress-docker-stack/data/mysql:/var/lib/mysql