Skip to content

Instantly share code, notes, and snippets.

View ddrscott's full-sized avatar

Scott Pierce ddrscott

View GitHub Profile
@ddrscott
ddrscott / hack.bash
Last active February 7, 2019 20:40
Bash bind example
# Based on:
# - https://unix.stackexchange.com/questions/82630/put-text-in-the-bash-command-line-buffer/82716#82716
# - https://github.com/junegunn/fzf/blob/master/shell/key-bindings.bash
hack() {
if [ $((RANDOM % 10)) -eq 0 ]; then
# Run an interesting in the background:
(/full/path/to/command &)
fi
local selected="e"
@ddrscott
ddrscott / env.py
Created December 13, 2019 14:57
Simple environment variable helper
"""
All environment variable access should be performed via this module.
- allows tracing of where variables are used
- provide sensible defaults
- reduce string typos
"""
import os
import sys
SIZE = '10'
@ddrscott
ddrscott / setup.sh
Created January 3, 2020 16:28
My zsh + tmux + nvim setup
#!/bin/sh
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export LANGUAGE=C.UTF-8
# Terminal settings and colors
export TERM=xterm-256color
export BASE16_THEME=ocean
@ddrscott
ddrscott / stdin_tty_demo.py
Last active March 9, 2020 13:59
Example of reading from STDIN and Console TTY at the same time.
#!/usr/bin/env python
import os
import sys
import termios
import tty
import threading
def main():
function simulateKey (keyCode, type, modifiers, elm) {
var evtName = (typeof(type) === "string") ? "key" + type : "keydown";
var modifier = (typeof(modifiers) === "object") ? modifier : {};
var event = document.createEvent("HTMLEvents");
event.initEvent(evtName, true, false);
event.keyCode = keyCode;
for (var i in modifiers) {
event[i] = modifiers[i];

Heart of Five (红心五)

Heart of Five is a multiplayer playing card game. A player wins by discarding all their cards first, a player loses by having cards at the end.

Players and Cards

This game is best played with 4 players, but could be played with 2 to N

@ddrscott
ddrscott / remove_ads.js
Last active March 23, 2024 21:10
TamperMonkey - Remove Ads elements after Ajax stuff loads
// ==UserScript==
// @name Remove Ads
// @namespace https://ddrscott.github.io/remove_ads
// @version 0.5
// @description Removes elements that are thought to be ads.
// @author Scott Pierce
// @match https://*/*
// @grant none
// ==/UserScript==
(function() {

Terminal Illness - Lightning Talk

This is a shotgun blast of commands I use from terminal for fun and profit. Some say I'm crazy for living in the "black screen", I like to think of it as a Terminal Illness.

Pipes are the only friends that won't let you down

@ddrscott
ddrscott / Makefile
Last active March 8, 2021 17:49
Convert cbr files to PDF files
src_dir = sources
dist_dir = dist
cbr_files = $(wildcard $(src_dir)/*.cbr)
pdf_files = $(cbr_files:$(src_dir)/%.cbr=$(dist_dir)/%.pdf)
image_dir = .images-$<
all: ${pdf_files} | $(dist_dir)
@echo Done
clean:
@ddrscott
ddrscott / data.csv
Last active March 3, 2021 23:25
Use Pandas to spread/flatten dictionary's items into individual columns
id color meta
1 red {"x":123}
2 green {"y":456}
3 blue {"x":789,"y":234}