Skip to content

Instantly share code, notes, and snippets.


Will Leinweber will

View GitHub Profile
will / init.lua
Created Apr 12, 2022
Neovim require all Lua files in directory
View init.lua
local fd = vim.loop.fs_scandir(vim.fn.stdpath('config') .. '/lua/user/')
for name in
function() return vim.loop.fs_scandir_next(fd) end
do require('user.' .. name:gsub('.lua\z', '')) end
will / mode.swift
Last active Mar 9, 2022
print light mode dark mode changes
View mode.swift
import Foundation
import AppKit
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
forName: Notification.Name("AppleInterfaceThemeChangedNotification"),
object: nil, queue: nil,
using: self.themeChanged(notification:)
will / query_collations.sql
Created Sep 2, 2020
check collation for all public text columns postgres
View query_collations.sql
n.nspname as "Schema",
c.relname as "Name",
pg_catalog.format_type(a.atttypid, a.atttypmod),
a.attrelid as table_id,
(SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t
WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
will / forward.rb
Created Aug 3, 2020
net::ssh remote port to local socket
View forward.rb
# on remote machine
# nc -l -p 1212
# on local machine
ssh = Net::SSH.start(remote.ip, "centos", keys_only: true, key_data: [remote.ssh_key])
tempfile ="net_ssh_forward_test")
path = tempfile.path
View gist:428b67c8e2afd14d6097a42748ff9d44
/t/test> cat
def go
a = 0
10.times do
a += 1
p a
will /
Created Jun 8, 2020
exponentially smoothed moving average and variance
class ExpMovingStats
def initialize(@alpha : Float32)
@mean = 0.0
@variance = 0.0
def update(n)
n = n.to_f32
beta = 1.0 - @alpha
View age encryption example
~> ./Downloads/age/age-keygen > key
Warning: writing to a world-readable file.
Consider setting the umask to 066 and trying again.
Public key: age1gnf3ahtvwhtpdc47jtec6t7nn2n2rrxla7wfk9kswvep66ypk5sqgz6f04
~> cat key
# created: 2020-05-29T23:02:29-07:00
# public key: age1gnf3ahtvwhtpdc47jtec6t7nn2n2rrxla7wfk9kswvep66ypk5sqgz6f04
will /
Last active Feb 24, 2020
fuzzing postgres
  • Fuzzing finds bugs feeding malformed or semi-maifomred data into a program.

  • This unexpected input can hopefully find bugs before they are found by attackers.

  • coverage guided or not

  • greg stark 2016

  • problems coverage guided and postgres

  • sqlsmith

will / gdb.rb
Created Dec 5, 2019
parse postgres core dumps
View gdb.rb
require "fileutils"
require "tmpdir"
class PGCoreDump
attr_reader :file, :term, :bt, :query, :basename, :sha256
def initialize(file, basename)
@basename = basename
@file = file