Skip to content

Instantly share code, notes, and snippets.

Avatar

Karl Horky karlhorky

View GitHub Profile
View clear-npx-cache.sh
# First, remove all the folders in the npx cache location
# https://github.com/npm/cli/issues/1935#issuecomment-745561262
rm -rf $(npm get cache)/_npx/*
@karlhorky
karlhorky / 1-setup.md
Created Jan 5, 2021 — forked from troyfontaine/1-setup.md
Signing your Git Commits using GPG on MacOS Sierra/High Sierra
View 1-setup.md

Methods of Signing with GPG

There are now two ways to approach this:

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

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 Krypt.co.

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

Heading

Markdown

@karlhorky
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>' +
prettier
.format(html, {parser: 'html', htmlWhitespaceSensitivity: 'ignore'})
.replace(/</g, '&lt;') +
'</pre>';
@karlhorky
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) {
findReactChildRecursively(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
karlhorky / analyzequotes.sh
Created Jan 30, 2020 — forked from pspi/analyzequotes.sh
Calculate ratio of single quotes to double quotes in .js and .ts files
View analyzequotes.sh
#!/usr/bin/env bash
# TODO:
# - 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))
View authentication_with_express_postgres.md

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
View _windows-10-home-docker-toolbox-wordpress-mysql-with-volume.md
  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:

    Capture

  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/:

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