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.
Download Shai's corpus for Colemak:
# 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 | |
# |
# convert piped input to args | |
if [[ ! -t 0 ]] && [[ -p /dev/stdin ]] && (( $# == 0 )); then | |
set -- "${(@f)$(cat)}" | |
fi |
// 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 |
;;; 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 |
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.
Guess the Wordle in 6 tries.
#!/bin/sh | |
# Author: mattmc3 | |
# Copyright: 2023 | |
# License: MIT | |
print_err() { | |
printf '%s\n' "$my_name: Error: $1" >&2 | |
exit ${2:-1} | |
} |
clitest
and stdin don't always work well together.
StackOverflow wasn't much help (shocked pikachu)! Buried deep in the interwebs is the bash advice
to check for a TTY and whether stdin was piped with this: if [ ! -t 0 ] && [ -p /dev/stdin ];
.
Using this, I wanted to see how to do something similar in Python to make clitest work. Even
deeper on the internet was this gem, which led me to
the answer - use stat
in Python to test whether stdin is a FIFO (pipe).
Thus, the answer to this hours long search is simply this function:
# Collect args | |
# -- traditional, piped|, <redirected | |
function collect_args { | |
local data args=() | |
if [[ ! -t 0 ]]; then | |
while IFS= read -r data || [[ -n "$data" ]]; do | |
args+=("$data") | |
done | |
fi |
;; https://christiantietze.de/posts/2022/04/emacs-center-window-current-monitor-simplified/ | |
(defun my/frame-recenter (&optional frame) | |
"Center FRAME on the screen. | |
FRAME can be a frame name, a terminal name, or a frame. | |
If FRAME is omitted or nil, use currently selected frame." | |
(interactive) | |
(unless (eq 'maximised (frame-parameter nil 'fullscreen)) | |
(modify-frame-parameters | |
frame '((user-position . t) (top . 0.5) (left . 0.5))))) |