Skip to content

Instantly share code, notes, and snippets.

Avatar

John Karahalis openjck

View GitHub Profile
@openjck
openjck / eslint-health.js
Last active Aug 7, 2020
Node script which fails with an error message if this project has too many ESLint problems. Use this gradually reduce the number of problems to zero. https://medium.com/reflections-on-building-software/gradually-reduce-the-number-of-eslint-problems-in-your-codebase-fe503d4f2716
View eslint-health.js
#!/usr/bin/env node
/**
* Fail with an error message if this project has too many ESLint problems.
*
* Configuration options:
*
* config.maxProblems: The maximum number of problems that should be allowed.
* If the number of problems exceeds this value, the
* script will fail with an error message. Consider
@openjck
openjck / overwrite-with-github-template
Last active Aug 3, 2020
Bash script which overwrites files in the current directory with files from a GitHub template. This can be useful when changes have been made to the template and you'd like to use those changes in a project which was originally based on the template.
View overwrite-with-github-template
#!/usr/bin/env bash
# Overwrite files in the current directory with files from a GitHub template.
# This can be useful when changes have been made to the template and you'd like
# to use those changes in a project which was originally based on the template.
#
# rsync will make backups of all overwritten files in case you had made edits to
# them which you'd like to merge back in.
if [[ "$#" -ne 1 ]]; then
@openjck
openjck / LICENSE
Created Jul 23, 2020
This license applies to all of my public Gists
View LICENSE
Copyright 2020 John Karahalis
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@openjck
openjck / eslint-health
Last active Jul 27, 2020
Bash script which exits with an error if there are too many ESLint problems. Use this gradually reduce the number of problems to zero. https://medium.com/reflections-on-building-software/gradually-reduce-the-number-of-eslint-problems-in-your-codebase-fe503d4f2716
View eslint-health
#!/usr/bin/env bash
# Fail if there are too many ESLint problems. The definition of "too many" is
# hardcoded. The number can be manually lowered over time as problems are fixed
# to prevent regressions.
#
# This is a copy of the following Gist:
# https://gist.github.com/openjck/ab1a435e249580861afbc5b93465e611
#
# More information:
@openjck
openjck / .bashrc
Created May 7, 2020
reuse-completions: Use Bash auto-completions for custom commands
View .bashrc
# Use auto-completions of the first command as auto-completions for the second
# command. For example, if we were to do the following:
#
# alias g="git"
# reuse-completions git g
#
# ...then we would be able to type "g b<tab>" and "branch" would be among the
# suggestions.
function reuse-completions() {
local ORIGINAL_COMMAND=$1
@openjck
openjck / .bashrc
Last active Apr 21, 2020
cdv: Like cd, but immediately runs ls after being called
View .bashrc
# cdv: cd with visibility
#
# Change the shell working directory and immediately list directory contents.
# Takes the same arguments as cd.
#
# This would not work properly if it were a shell script. Shell scripts are
# executed in subshells, where "cd" does not affect the shell that called the
# script.
function cdv() {
if cd "$@"; then
@openjck
openjck / .bashrc
Last active Apr 19, 2020
Bash function to cd to the root of a Git project, if possible
View .bashrc
# If we are in a project, cd to the root of the project.
#
# This would not work properly if it were a shell script. Scripts are executed
# in subshells, where "cd" does not effect the shell that called the script.
#
# https://stackoverflow.com/a/957978/4297741
function cd-project-root() {
local PROJECT_ROOT
PROJECT_ROOT=$(git rev-parse --show-toplevel 2> /dev/null)
@openjck
openjck / .bashrc
Created Apr 11, 2020
Always use a pager with rg
View .bashrc
# Drop this into ~/.bashrc to always use a pager with rg.
function rg() {
command rg --pretty "$@" | less --RAW-CONTROL-CHARS
}
@openjck
openjck / .gitconfig
Last active Apr 7, 2020 — forked from huytd/.gitconfig
Configure Git to use Neovim as the difftool and mergetool
View .gitconfig
# Configure Git to use Neovim as the difftool and mergetool. This is a simpler
# version of the following recommendation:
#
# https://gist.github.com/huytd/78c676a797f81eb08cdedf5400e1b6a3
#
# The [diff] section is not required. If it's omitted, Git will use the
# mergetool as the difftool. I like to include the [diff] section to be
# explicit.
#
# If you prefer, you can replace all instances of "vimdiff" with "vimdiff2" or
View keybase.md

Keybase proof

I hereby claim:

  • I am openjck on github.
  • I am johnkarahalis (https://keybase.io/johnkarahalis) on keybase.
  • I have a public key whose fingerprint is F941 FEA9 729E 1040 6829 CE96 357D 0C1B 6454 146A

To claim this, I am signing this object:

You can’t perform that action at this time.