Skip to content

Instantly share code, notes, and snippets.

View Functional.java
public interface Functional {
void consume(String value);
String supply();
String operate(String value);
}
@Frederick888
Frederick888 / Counting.java
Created May 11, 2023 03:34
Counting Java
View Counting.java
public class Counting {
private int counter;
public int increaseCounter() {
counter = counter + 1;
return counter;
}
}
@Frederick888
Frederick888 / gpghub.sh
Created December 31, 2021 13:31
Import PGP keys in a Git repository from GitHub
View gpghub.sh
#!/usr/bin/env bash
OWNER="$1"
REPO="$2"
declare -A PROCESSED
function import_github_pgp() {
local github_login="$1"
printf 'Importing PGP key of GitHub user %s\n' "$github_login"
@Frederick888
Frederick888 / 1-diff-from-neovim-0.4.3.diff
Created April 26, 2020 15:19
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 November 9, 2023 22:41
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 April 21, 2020 09:31
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 January 28, 2020 04:02
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 September 7, 2020 10:48
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 August 18, 2019 12:29
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