Skip to content

Instantly share code, notes, and snippets.

View karlhorky's full-sized avatar

Karl Horky karlhorky

View GitHub Profile
@karlhorky
karlhorky / index.mdx
Created September 9, 2020 08:34
Prettier MDX Bug with React Components with Blank Lines

Heading

Markdown

@karlhorky
karlhorky / prettier-runkit-html-runkit.js
Created August 28, 2020 16:23
Prettify Runkit HTML Output with Prettier
// 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 June 13, 2020 11:17
Find React Child in Children Recursively Using a Find Function
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);
}
@karlhorky
karlhorky / .bash_profile
Last active May 5, 2023 14:10 — forked from SherryQueen/.bash_profile
git-bash
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 January 30, 2020 13:10 — forked from pspi/analyzequotes.sh
Calculate ratio of single quotes to double quotes in .js and .ts files
#!/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))
@karlhorky
karlhorky / authentication_with_express_postgres.md
Created October 22, 2019 18:52 — forked from laurenfazah/authentication_with_express_postgres.md
Authentication with an Express API and Postgres

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:

    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
@karlhorky
karlhorky / test.md
Last active September 21, 2019 08:55
Table Row Width
@karlhorky
karlhorky / .bashrc
Created September 3, 2019 19:37
Bash Git Aliases
# Git Aliases (sorted alphabetically with some inculsive functions)
# Adapted from oh-my-zsh git alias plugin. "compdef" is a Z shell autocompletion function, disabled throughout where applicable.
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
alias gb='git branch'