Skip to content

Instantly share code, notes, and snippets.

@oxinabox
oxinabox / thomas_tests.jl
Last active May 23, 2021 12:16
Why are so many implementations of the Thomas algorithm wrong?
using LinearAlgebra
# Wikipedia non-preserving version (transcribed from VB)
# https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm
# this one is wrong (found this in use in the wild 😢)
function thomas_algorithm!(a, b, c, r, ::Val{1})
n = length(b)
for i in 2:(n-1)
m = a[i]/b[i-1];
b[i] = b[i] - m * c[i - 1];
@pfitzseb
pfitzseb / tmuxedit.jl
Last active February 22, 2021 15:38
edit in existing tmux pane that runs `vim`
# put this in your startup.jl
using InteractiveUtils
let
tmuxsession = nothing
sessions = split(String(read(`tmux list-panes -a -F '#{pane_tty} #{session_name}'`)), '\n')
io = IOBuffer()
run(pipeline(`tty`, stdout=io))
tty = chomp(String(take!(io)))
for session in sessions
if occursin(tty, session)