Skip to content

Instantly share code, notes, and snippets.

View b0o's full-sized avatar
👻

Maddison Hellstrom b0o

👻
View GitHub Profile
function! MoveWindow(dir)
let l:orig_win = winnr()
let l:orig_buf = bufnr()
exe 'wincmd ' . a:dir
let l:dest_win = winnr()
let l:dest_buf = bufnr()
exe l:orig_win . 'windo hide buf' l:dest_buf
exe l:dest_win . 'windo hide buf' l:orig_buf
endfunction
nnoremap <M-S-h> :call MoveWindow('h')<Cr>
#compdef git-tag-version
# zsh completion for git-tag-version
_git-tag-version () {
_arguments -S -s "-h[usage]" "1:version-name" "2:from:__git_commits" "3:to:__git_commits"
}
@b0o
b0o / ttop
Created August 12, 2021 23:26
#!/usr/bin/env bash
set -euo pipefail
shopt -s inherit_errexit
function main() {
local -i row_width=${1:-990}
local -i total_height=${2:-500}
local -i row_height=$((total_height / 4))
local mods=".w${row_width}.h${row_height}.d"
#!/bin/bash
# Helper for yglu to assist with importing yaml files into the document
# root.
#
# Depends: yglu - https://github.com/lbovet/yglu/
#
# Copyright (c) 2020-2021 Maddison Hellstrom <github.com/b0o>, MIT License.
set -euo pipefail
@b0o
b0o / setops.js
Created August 6, 2021 02:36
Operations over sets
const union = (...sets) => new Set(sets.flatMap(s => [...s]))
const intersection = (a, b, ...rest) => (rest.length ? intersection : (s => new Set(s)))([...a].reduce((acc, e) => b.has(e) ? [...acc, e] : acc, []), ...rest)
const difference = (...sets) => [...intersection(...sets)].reduce((acc, e) => !acc.delete(e) || acc, union(...sets))
const leftDifference = (left, ...rights) => difference(left, intersection(left, union(...rights)))
const rightDifference = (...sets) => leftDifference(...sets.reverse())
@b0o
b0o / README.md
Last active September 29, 2022 02:37
Wikipedia/MediaWiki Sidebar Table of Contents User Style

@b0o
b0o / auto-darkmode.user.js
Last active March 22, 2021 03:28
auto-darkmode.user.js
// ==UserScript==
// @name Auto darkmode
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Toggle darkmode on supported sites based on your OS's darkmode setting
// @author You
// @match https://www.tradingview.com/chart/*
// @match https://www.coinex.com/*
// @exclude https://www.coinex.com/assets/trading_chart/*
// @grant none
#!/bin/bash
# rqrcp is a wrapper around 'qrcp receive' which improves desktop integration
# by adding support for copying file paths or contents to the clipboard,
# opening files in the default application, sending notifications, and using a
# GUI window to display the QR code.
#
# Copyright (C) 2021 Maddison Hellstrom <https://github.com/b0o>
#
# This program is free software: you can redistribute it and/or modify
@b0o
b0o / fun.zsh
Last active February 14, 2021 04:33
some fun zsh zle widgets
# Assorted zsh zle widgets that I've made over the years
# (c) 2017-2021 Maddison Hellstrom (github.com/b0o)
# License: GPL v3.0 or later
## smartie-hands
function _smart_l() {
local cmd="${1:-l}"
local p=""
if [[ -n "$BUFFER" ]]; then
zmodload -e zsh/pcre || zmodload zsh/pcre
@b0o
b0o / smart-fzf.zsh
Last active February 14, 2021 04:25
# fzf path finding filesystem navigation thing by maddy (github.com/b0o)
#
# key bindings:
# - return: accept final
# - alt-return: accept final (absolute)
# - esc: escape
# - ctrl-g: escape (absolute)
# - alt-o: accept query
# - alt-P append query
# - ctrl-o: replace query