Skip to content

Instantly share code, notes, and snippets.

Avatar

Frederick Zhang Frederick888

View GitHub Profile
@Frederick888
Frederick888 / 1-diff-from-neovim-0.4.3.diff
Created Apr 26, 2020
Simplified NeoVim man.vim for GNU Linux
View 1-diff-from-neovim-0.4.3.diff
--- /usr/share/nvim/runtime/autoload/man.vim 2020-03-31 21:23:02.000000000 +1100
+++ ./man.vim 2020-04-27 01:04:54.716553901 +1000
@@ -8,31 +8,8 @@
let s:find_arg = '-w'
let s:localfile_arg = v:true " Always use -l if possible. #6683
let s:section_arg = '-s'
-function! s:init_section_flag()
- call system(['env', 'MANPAGER=cat', 'man', s:section_arg, '1', 'man'])
- if v:shell_error
@Frederick888
Frederick888 / 10-snapshot.hook
Last active Aug 28, 2020
Simple pacman hook to take ZFS snapshots
View 10-snapshot.hook
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=*
[Action]
When=PreTransaction
Exec=/usr/local/bin/pacman-snapshots.sh
@Frederick888
Frederick888 / control.sh
Last active Apr 21, 2020
Bash script to pull latest Docker container, (re)start container if needed, and clean up dangling images
View control.sh
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
IMAGE=
TAG='latest'
CONTAINER=
function printf() {
format="\e[1;31m$1\e[m"
shift
@Frederick888
Frederick888 / #Usage.md
Created Jan 28, 2020
Offloading XDG cache home to tmpfs
View #Usage.md
  1. Configure /tmp as per fstab, adjust size if needed
  2. Copy xdg-cache.service to /etc/systemd/user/xdg-cache.service
  3. Copy xdg-cache.sh to /usr/local/bin/xdg-cache.sh and then chmod +x /usr/local/bin/xdg-cache.sh
  4. Run systemctl --user enable xdg-cache.service as the user that needs this service
@Frederick888
Frederick888 / update_jbrsdk.sh
Last active Sep 7, 2020
JetBrains Java SDK Management Scripts
View update_jbrsdk.sh
#!/usr/bin/env bash
# shellcheck disable=SC2001
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
OS=$(uname)
case "$OS" in
Linux)
OS="${OS,,}"
@Frederick888
Frederick888 / mysql-diff.csv
Created Aug 18, 2019
Difference of files between AUR and Ubuntu packages
View mysql-diff.csv
AUR Package AUR File Ubuntu Package Ubuntu File src Path Common File
mysql-community-server /etc/apparmor.d/usr.sbin.mysqld
mysql /etc/conf.d/mysql.conf
mysql /etc/ld.so.conf.d/mysql.conf
mysql-common /etc/mysql/conf.d/mysql.cnf ./mysql/src/mysql-8.0.17/packaging/deb-in/extra/conf.d/mysql.cnf,./mysql/src/mysql-8.0.17/packaging/deb-in/extra/mysql.cnf
mysql /etc/mysql/my.cnf
libmysqlclient /etc/mysql/my.cnf.default
mysql-common /etc/mysql/my.cnf.fallback ./mysql/src/mysql-8.0.17/packaging/deb-in/extra/my.cnf.fallback
mysql-community-server /etc/mysql/mysql.cnf ./mysql/src/mysql-8.0.17/packaging/deb-in/extra/conf.d/mysql.cnf,./mysql/src/mysql-8.0.17/packaging/deb-in/extra/mysql.cnf
mysql-community-server /etc/mysql/mysql.conf.d/mysqld.cnf ./mysql/src/mysql-8.0.17/packaging/deb-in/extra/mysqld.cnf
View gist:7a8fce9aad441bd24c895e6b39457a77
[2019-07-07T11:14:35.233593+00:00] mongoc: TRACE > ENTRY: _mongoc_linux_distro_scanner_get_distro():389
[2019-07-07T11:14:35.233614+00:00] mongoc: TRACE > ENTRY: _mongoc_linux_distro_scanner_read_key_value_file():154
[2019-07-07T11:14:35.233631+00:00] mongoc: TRACE > ENTRY: _process_line():93
[2019-07-07T11:14:35.233637+00:00] mongoc: TRACE > TRACE: _process_line():121 Found name: Arch Linux
[2019-07-07T11:14:35.233640+00:00] mongoc: TRACE > EXIT: _process_line():128
[2019-07-07T11:14:35.233643+00:00] mongoc: TRACE > ENTRY: _process_line():93
[2019-07-07T11:14:35.233646+00:00] mongoc: TRACE > EXIT: _process_line():128
[2019-07-07T11:14:35.233649+00:00] mongoc: TRACE > ENTRY: _process_line():93
[2019-07-07T11:14:35.233653+00:00] mongoc: TRACE > EXIT: _process_line():128
[2019-07-07T11:14:35.233657+00:00] mongoc: TRACE > ENTRY: _process_line():93
@Frederick888
Frederick888 / dkim_rotation.sh
Last active Jun 26, 2020
Automatic DKIM key rotation with CloudFlare
View dkim_rotation.sh
#!/usr/bin/env bash
# Read https://www.linode.com/docs/email/postfix/configure-spf-and-dkim-in-postfix-on-debian-8 first!
# Run this script at the beginning of each month
# (Optional) Email notification if the script is interrupted
#function notify() {
# printf 'Refer to the logs for further info.\n' | mail -s 'DKIM rotation process was interrupted' 'admin@example.com'
#}
#
@Frederick888
Frederick888 / ycm.log
Created Feb 6, 2019
YCM compliation error: failed to initialized index git repository
View ycm.log
-- The C compiler identification is AppleClang 10.0.0.10001145
-- The CXX compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
@Frederick888
Frederick888 / gnupg-refresh@.service
Created Jan 24, 2019
Simple systemd timer to refresh GnuPG public keys
View gnupg-refresh@.service
[Unit]
Description=Refreshes GnuPG keys for %I
Requires=network.target network-online.target
After=network.target network-online.target
[Service]
Type=oneshot
User=%i
ExecStart=/usr/bin/gpg --refresh-keys
StandardOutput=journal
You can’t perform that action at this time.