Skip to content

Instantly share code, notes, and snippets.

View karlhorky's full-sized avatar

Karl Horky karlhorky

View GitHub Profile
@karlhorky
karlhorky / index.ts
Last active March 13, 2021 14:52
Use full Chrome with Puppeteer (instead of Chromium)
// Modified / modernized version of https://github.com/puppeteer/examples/blob/master/lighthouse/chromelauncher_puppeteer.js
/**
* Copyright 2018 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@karlhorky
karlhorky / clear-npx-cache.sh
Last active February 7, 2024 05:16
Clear npx cache
# 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 January 5, 2021 17:04 — forked from troyfontaine/1-setup.md
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 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 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