sudo machinectl status «machine» >> /dev/null 2>&1 \
&& sudo machinectl shell «user»@«machine» /bin/bash \
|| sudo systemd-nspawn \
--bind=«source»:«target» \
--property DeviceAllow='/dev/fuse rwm' \
--machine=«machine»
-bD «root» "$@"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro checkbox_tree(roles, level = 0) %} | |
{% import _self as macros %} | |
<ul{% if level == 0 %} class="roles"{% endif %}> | |
{% for role, child_roles in roles %} | |
<li class="role"> | |
<div class="custom-control custom-checkbox"> | |
<input class="custom-control-input" id="{{ role|lower }}" type="checkbox" name="role[{{ role }}]" | |
data-level="{{ level }}"> | |
<label class="custom-control-label" for="{{ role|lower }}">{{ role }}</label> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(f => (g => g(g))(g => f(x => g(g)(x))))((x) => ([a, b, c = 1]) => a === b ? [a] : [a, ...x([a + c, b, c])])([1, 10]) | |
// [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] | |
// Note: Functional programmers and mathematicians have known this trick | |
// for decades under the name of a Y combinator. I did not invent this. | |
// I recommend deciphering this thing on your own, though. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\newcommand\rating[1]{% | |
\let\N=\pgfmathresult% | |
\foreach \n in {1,...,#1}{% | |
\FilledStar% | |
}% | |
\foreach \n in {1,...,\N}{% | |
\Star% | |
}% | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
typedef long long int cardinal; | |
template<cardinal N, cardinal K> | |
struct binomial_coefficient { | |
static constexpr cardinal value = | |
binomial_coefficient<N - 1, K - 1>::value + binomial_coefficient<N - 1, K>::value; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- $HOME/.config/devilspie2/devilspie2.lua | |
if string.match(get_window_class(), "Code") or string.match(get_window_class(), "jetbrains") then | |
os.execute("xprop -id " .. get_window_xid() .. " -f _GTK_THEME_VARIANT 8u -set _GTK_THEME_VARIANT 'dark'") | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function match(value) { | |
const branches = []; | |
let otherwiseBranch = (value) => { | |
// TODO better message | |
throw new Error(`${value} not matched`); | |
}; | |
const publicApi = { get, when, otherwise }; | |
function get() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> { }; | |
stdenv.mkDerivation { | |
name = "binutils-2.29-x86_64-elf"; | |
builder = ./build-binutils.sh; | |
src = fetchurl { | |
url = https://ftp.gnu.org/gnu/binutils/binutils-2.29.tar.xz; | |
sha256 = "118ybdwcx3dbfzfqav9h0nill8jd7ca74kr6z1208qjc3hkix1qb"; | |
}; | |
platform = "x86_64-elf"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# sane_chroot: sanity-preserving chroot(1) | |
set -e | |
finish() { | |
prefix="$(realpath "$prefix")" | |
if [ "x$(unlock)" != "x0" ]; then | |
return 0 | |
else | |
echo "Shutting down..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
email=overlord@localhost | |
free_threshold=20 | |
next_reminder=$((60*60*24*3)) | |
disks=(/dev/sda1 ...) | |
for disk in ${disks[*]}; do | |
total=$(df $disk -P | tail -n 1 | awk '{print $2}') | |
free=$(df $disk -P | tail -n 1 | awk '{print $4}') |
NewerOlder