Skip to content

Instantly share code, notes, and snippets.

View snowfag's full-sized avatar

Yukikaze snowfag

View GitHub Profile
@snowfag
snowfag / dfree.sh
Created June 1, 2023 15:00
A samba dfree script I wrote a while back for correctly reporting the total and free space on zfs pools and any other fs if not zfs (read: it doesn't break on non zfs filesystems)
#!/usr/bin/env zsh
maybe_pool="$(df ${1} | awk -F'[\t/ ]' 'END{print $1}')"
if (zfs list -Hp "${maybe_pool}" >/dev/null 2>&1); then
pool_name="$(zfs list -Hp "${maybe_pool}" | awk -F"[\t/]" '{print $1}')"
zpool list -Hp "${pool_name}" | cut -f 2-4 | read total used zpoolfree
realfree="$(zfs list -Hp "${pool_name}" | cut -f 3)"
python3 -c "import bigfloat; print(f'{int(bigfloat.div(${total}, 1024))} {int(bigfloat.div(${realfree}, 1024))}')"
else
df "${1}" | tail -1 | awk '{print $2" "$4}'
fi
@snowfag
snowfag / keymap.c
Created November 18, 2021 10:32
keyboards/ploopyco/trackball/keymaps/snowfag/keymap.c
/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
* Copyright 2019 Sunjun Kim
* Copyright 2020 Ploopy Corporation
* Copyright 2020 snowfag <yuki@lolicon.eu>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
tee /usr/local/bin/cloudflare-update >/dev/null << EOF
#!/usr/bin/env bash
curl -s "https://www.cloudflare.com/ips-v{4,6}" | tee >(awk '{print "set_real_ip_from " \$0 ";"} END {print "real_ip_header CF-Connecting-IP;\nproxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;\nproxy_set_header X-Real-IP \$http_cf_connecting_ip;"}' >/etc/nginx/snippets/cf-realip.conf) >(awk '{print "allow " \$0 ";"} END {print "deny all;"}' >/etc/nginx/snippets/cf-restrict.conf) >/dev/null 2>&1
EOF
chown root:root /usr/local/bin/cloudflare-update
chmod 775 /usr/local/bin/cloudflare-update
tee /etc/systemd/system/cf-updater.service >/dev/null << EOF
[Unit]
Description=updates nginx's snippets using cloudflare ips
#!/usr/bin/env zsh
if [[ -d ${HOME}/.cfg ]]; then
if read -q "choice?${HOME}/.cfg exists would you like to delete it? Y/n: "; then
rm -rf "${HOME}/.cfg"
else
exit 1
fi
fi
git clone --bare git@github.com:snowfag/dotfiles.git ${HOME}/.cfg
config() git --git-dir=${HOME}/.cfg/ --work-tree=${HOME} $@
### Keybase proof
I hereby claim:
* I am snowfag on github.
* I am yukikazeq (https://keybase.io/yukikazeq) on keybase.
* I have a public key ASCBsf_tUqBUZiHSRe9IEukpHn-mn283sJA2kF2Kxm9nRAo
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am snowfag on github.
* I am snowfag (https://keybase.io/snowfag) on keybase.
* I have a public key ASDHTbZPm0bWcdZh130yf_hrtOQvS8Q3ZP2xymV1v14ktQo
To claim this, I am signing this object:
'''
# Nyaa categories only for now, but api still works for sukebei
Anime
Anime - AMV : '1_1'
Anime - English : '1_2'
Anime - Non-English : '1_3'
Anime - Raw : '1_4'
Audio
Lossless : '2_1'