Skip to content

Instantly share code, notes, and snippets.

View dsanson's full-sized avatar

David Sanson dsanson

View GitHub Profile
@dsanson
dsanson / noise
Last active May 29, 2024 21:12
cli activation of built-in white noise on macos
#!/usr/bin/env bash
declare -A noises
# to get these hashes, using the system to select the sound, then run:
#
# defaults export com.apple.ComfortSounds -
#
# Convert the base64 data field to hex.
{
"1": {
"light": "https://images.unsplash.com/photo-1600266573467-16ab6cb278ec?w=2000&q=100",
"dark": "https://images.unsplash.com/photo-1506296933720-1a0ce9bed41d?w=2000&q=100"
},
"2": {
"light": "https://images.unsplash.com/photo-1498234611539-1cfb1e28fa6f?w=2000&q=100",
"dark": "https://images.unsplash.com/photo-1584351583369-6baf055b51a7?w=2000&q=100"
},
"3": {
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -103,7 +103,7 @@ static relaxed_atomic_t<pid_t> initial_fg_process_group{-1};
/// This struct maintains the current state of the terminal size. It is updated on demand after
/// receiving a SIGWINCH. Use common_get_width()/common_get_height() to read it lazily.
static constexpr struct winsize k_invalid_termsize = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
-static owning_lock<struct winsize> s_termsize{k_invalid_termsize};
+static relaxed_atomic_t<struct winsize> s_termsize(k_invalid_termsize);
static relaxed_atomic_bool_t s_termsize_valid{false};
@dsanson
dsanson / fish-kitty-terminal-dimensions.diff
Created May 25, 2020 21:16
Patch to fix bug in fish that causes incorrect terminal size reporting
https://github.com/fish-shell/fish-shell/issues/6994#issuecomment-633303722
diff --git a/src/common.cpp b/src/common.cpp
index f76445fc0..57d66695a 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -103,7 +103,7 @@ static relaxed_atomic_t<pid_t> initial_fg_process_group{-1};
/// This struct maintains the current state of the terminal size. It is updated on demand after
/// receiving a SIGWINCH. Use common_get_width()/common_get_height() to read it lazily.
static constexpr struct winsize k_invalid_termsize = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX};
-static owning_lock<struct winsize> s_termsize{k_invalid_termsize};
@dsanson
dsanson / gist:e541f0b72c9066768fd5
Last active February 15, 2017 22:34
My cvimrc
set autoupdategist
set noautofocus
set nocncpcompletion
set smoothscroll
set hud
set noregex
set noinsertmappings
set typelinkhints
set defaultnewtabpage
#!/bin/bash
#
# Get A Phil Papers Item (gappi); version 0.3
# by Kevin C. Klement (klement@philos.umass.edu)
# Feel free to email Kevin with suggestions or questions
# License: GPLv3
#
# get the name of the script
SCRIPTNAME="$(basename "$0")"
@dsanson
dsanson / gist:9289a3f15c25b7ba82ed
Created December 23, 2014 18:37
How Can I Craft This Again Chords
C G Am F
You get online and the world forms 'round you
C G Dm F
It's been a while, haven't played since point 2!
C G Am F
You break a smile, 'cause you've almost forgot to mine
C G Dm F C G
It's just been such a long time! And every time you're denied
Am F C G
@dsanson
dsanson / gist:1919205
Created February 26, 2012 22:00
Vim Folding for RIS files
" Some folding functions for using Vim with RIS files...
" Lines starting with 'TY -' trigger folds
set foldexpr=RIS_Fold()
set foldmethod=expr
fun! RIS_Fold()
let thisline = getline(v:lnum)
if thisline =~ '^TY -.*'
return '>1'
@dsanson
dsanson / extract_bib.rb
Created November 21, 2011 16:25
Generate a bibtex file containing works cited in a given pandoc extended markdown file
#!/usr/bin/env ruby
bibfile = "~/.pandoc/default.bib"
matches = ARGF.read.scan(/@(.*?)[\.,:;\] ]/)
reg = "\\(" + matches.join("\\)\\|\\(") + "\\)"
system 'bibtool -X \'' + reg + '\' ' + bibfile
@dsanson
dsanson / odt2pandoc.py
Created September 20, 2011 21:44
a slight tweak of odt2txt.py
#!/usr/bin/env python
"""
ODT2PANDOC
==========
ODT2PANDOC is a slight variant of ODT2TXT. Right now, the only differences are that it generates ATX style headers and uses *asterisks* for italics, neither of which is in any way specific to pandoc's extended markdown.
ODT2TXT
=======