Skip to content

Instantly share code, notes, and snippets.

View mattmc3's full-sized avatar
🐍
Python!

mattmc3 mattmc3

🐍
Python!
View GitHub Profile
@mattmc3
mattmc3 / ignore_markdown_dollar.sh
Created October 3, 2024 15:16
Bash + ble.sh - fix markdown copy/paste commands by stripping leading dollar sign '$'
# Strip leading dollar signs. Fixes commands pasted from markdown.
# Requires ble.sh: https://github.com/akinomyoga/ble.sh
# shellcheck disable=SC2016
ble/function#advice around ble/widget/default/accept-line '
if [[ "${_ble_edit_str:0:2}" == "$ " ]]; then
ble/widget/beginning-of-logical-line
ble/widget/insert-string "${_ble_edit_str:2}"
ble/widget/kill-forward-logical-line
fi
ble/function#advice/do
@mattmc3
mattmc3 / README.md
Last active September 23, 2024 19:00
colorschemes

colorschemes

Description

Simplistic theme fuzzy finder using themes from iterm2colorschemes.com, jq, and fzf.

Usage

$ colorschemes -h
@mattmc3
mattmc3 / dollarzero.zsh
Last active September 14, 2024 23:05
Zsh dollar zero $0
# Use %N in a file
0=${(%):-%N}
echo "dollar zero: $0"
# Use :a to get the absolute path
echo "dollar zero abs path: ${0:a}"
# Use :A to get the absolute path resolving symlinks
echo "dollar zero abs path: ${0:A}"
@mattmc3
mattmc3 / contains.sh
Last active August 8, 2024 18:05
POSIX helper functions
# Fish-like contains (https://fishshell.com/docs/current/cmds/contains.html)
contains() {(
while getopts "i" opt; do
case "$opt" in
i) o_index=1 ;;
*) return 1 ;;
esac
done
shift $(( OPTIND - 1 ))
@mattmc3
mattmc3 / instant-zsh.zsh
Created May 21, 2024 15:11 — forked from romkatv/instant-zsh.zsh
Make zsh start INSTANTLY with this one weird trick
# Make zsh start INSTANTLY with this one weird trick.
#
# https://asciinema.org/a/274255
#
# HOW TO USE
#
# 1. Download this script.
#
# curl -fsSL -o ~/instant-zsh.zsh https://gist.github.com/romkatv/8b318a610dc302bdbe1487bb1847ad99/raw
#
@mattmc3
mattmc3 / stdin2args.zsh
Created January 3, 2024 03:15
convert piped input to args
# convert piped input to args
if [[ ! -t 0 ]] && [[ -p /dev/stdin ]] && (( $# == 0 )); then
set -- "${(@f)$(cat)}"
fi
@mattmc3
mattmc3 / find_bigrams.md
Last active December 1, 2023 14:35
Find common bigrams

Find common bigrams

Bigrams are 2-letter combos. When designing a keyboard layout, it's common to optimize for comfort and speed by analyzing bigrams. Here's a simple shell script to do a quick-and-dirty bigram analysis.

Instructions

Download Shai's corpus for Colemak:

@mattmc3
mattmc3 / IOrderedDictionary.cs
Last active September 4, 2023 14:06
OrderedDictionary
// https://stackoverflow.com/questions/2629027/no-generic-implementation-of-ordereddictionary/9844528?noredirect=1#comment135796623_9844528
// https://choosealicense.com/licenses/mit
// or https://choosealicense.com/licenses/unlicense
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace mattmc3.Common.Collections.Generic
{
public interface IOrderedDictionary<TKey, TValue> : IDictionary<TKey, TValue>, IOrderedDictionary
@mattmc3
mattmc3 / better-defaults.el
Created July 25, 2023 17:37
Emacs better-defaults
;;; better-defaults.el --- Fixing weird quirks and poor defaults
;; Copyright © 2013-2020 Phil Hagelberg and contributors
;; Author: Phil Hagelberg
;; URL: https://git.sr.ht/~technomancy/better-defaults
;; Version: 0.1.4
;; Package-Requires: ((emacs "25.1"))
;; Created: 2013-04-16
;; Keywords: convenience
@mattmc3
mattmc3 / readme.md
Last active May 9, 2023 16:54
Fish Shell - Wordle Helper

Fish Wordle Helper

Wordle is a simple word game where you try to guess a 5-letter word each day. This gist contains a small Fish function to help you narrow down the list of possible answers based on the scores from each guess.

How To Play

Guess the Wordle in 6 tries.

  • Each guess must be a valid 5-letter word.
  • The color of the tiles will change to show how close your guess was to the word.