Skip to content

Instantly share code, notes, and snippets.

Avatar
😐

Matt Keranen kmatt

😐
  • Central FL US
View GitHub Profile
@kmatt
kmatt / MacOSLogoutHook.txt
Last active Nov 23, 2022 — forked from RxDx/MacOSLogoutHook.txt
MacOS: Run script before shutdown
View MacOSLogoutHook.txt
Create a file:
$ vim /Users/Shared/logoutHook.sh
File content:
#!/bin/bash
say 'Hasta la vista baby!'
Set execution permission:
$ sudo chmod +x /Users/Shared/logoutHook.sh
@kmatt
kmatt / void-wsl.sh
Last active Nov 15, 2022
Install Void Linux on WSL2
View void-wsl.sh
# Based on https://gist.github.com/kmatt/71603170556ef8ffd14984af77ff10c5
# prompt ">" indicates Powershell commands
# https://docs.microsoft.com/en-us/windows/wsl/install-win10
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# install https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
@kmatt
kmatt / pv_dump.sh
Created May 24, 2012
Monitoring dump and restore with pv
View pv_dump.sh
# dump
pg_dump testdb | pv -c -s $(psql -tc "SELECT pg_database_size('testdb')") -N dump | gzip > testdb.sql.gz
# restore
pv testdb_20120501.sql.gz | zcat | psql testdb
@kmatt
kmatt / slugify.postgres.sql
Last active Jul 6, 2022 — forked from abn/slugify.postgres.sql
A slugify function for postgres
View slugify.postgres.sql
-- original source: https://medium.com/adhawk-engineering/using-postgresql-to-generate-slugs-5ec9dd759e88
-- https://www.postgresql.org/docs/9.6/unaccent.html
CREATE EXTENSION IF NOT EXISTS unaccent;
CREATE OR REPLACE FUNCTION public.slugify(v TEXT) RETURNS TEXT
LANGUAGE plpgsql
STRICT IMMUTABLE AS
$function$
BEGIN
@kmatt
kmatt / delay_pg_restore_matviews
Last active Jun 28, 2022
Delay materialized view refresh during pg_restore
View delay_pg_restore_matviews
pg_dump database -Fc backup.dump
pg_restore -l backup.dump | sed '/MATERIALIZED VIEW DATA/d' > restore.lst
pg_restore -L restore.lst -d database backup.dump
pg_restore -l backup.dump | grep 'MATERIALIZED VIEW DATA' > refresh.lst
pg_restore -L refresh.lst -d database backup.dump
View gist:6ef2450eba640d477e253cc2242d57ea
# brew install unixodbc
export CPPFLAGS="-I/opt/homebrew/Cellar/unixodbc/2.3.9_1/include"
export LDFLAGS="-L/opt/homebrew/Cellar/unixodbc/2.3.9_1/lib -liodbc -liodbcinst"
export PKG_CONFIG_PATH="/opt/homebrew/Cellar/unixodbc/2.3.9_1/lib/pkgconfig $PKG_CONFIG_PATH"
pip install --no-binary pyodbc pyodbc
@kmatt
kmatt / .zshrc
Created Feb 18, 2022 — forked from aiqc/.zshrc
zsh_prompt.txt
View .zshrc
# ========= PROMPT =========
# Version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats ' %b '
# Render the prompt
setopt PROMPT_SUBST
View gist:e6e077783346bfbade0f21830417dc86
#### Issue description
#### Steps to reproduce the issue
1.
2.
3.
View wombat.vim
" Maintainer: Lars Nielsen (dengmao@gmail.com)
" Last Change: January 22 2007
" https://dengmao.wordpress.com/2007/01/22/vim-color-scheme-wombat/
set background=dark
hi clear
if exists("syntax_on")
syntax reset
@kmatt
kmatt / fedora-wsl.sh
Last active Apr 27, 2021
Fedora on WSL2
View fedora-wsl.sh
# From https://fedoramagazine.org/wsl-fedora-33/
# prompt ">" indicates Powershell commands
# https://docs.microsoft.com/en-us/windows/wsl/install-win10
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# install https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi