Skip to content

Instantly share code, notes, and snippets.

Richard Amarandus

  • Germany
Block or report user

Report or block Amarandus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View libvirt.nix
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.virtualisation.libvirtd;
boolToZeroOne = x: if x then "1" else "0";
aclString = with lib.strings;
concatMapStringsSep ",\n " escapeNixString cfg.deviceACL;
in {
@Amarandus
Amarandus / xmonad.hook
Last active Jun 29, 2018
Automatic recompilation after xmonad or haskell libs update
View xmonad.hook
[Trigger]
Operation=Install
Operation=Upgrade
Type=Package
Target=xmonad
Target=haskell-*
[Action]
Depends=xmonad
When=PostTransaction
@Amarandus
Amarandus / vpnwatch.service
Created Jun 25, 2018
Simple Openvpn Watchdog
View vpnwatch.service
[Unit]
Description=VPN watchdog
After=network.target
[Service]
Type=oneshot
ExecStart=/bin/sh -c 'ping -I tun0 -c 1 8.8.8.8 > /dev/null || systemctl restart openvpn@configname.service'
[Install]
WantedBy=multi-user.target
View shebang.c
#!/usr/bin/env sh
#if 0
TMPFILE=$(mktemp);
tail -n +10 $0 | gcc -march=native -o $TMPFILE -x c -;
$TMPFILE "${@:1}";
RETVAL=$?
rm $TMPFILE;
exit $RETVAL;
#endif
View 42_iPXE
#!/bin/sh
BOOTUUID=`blkid -o value $(df /boot | grep "$MOUNTPOINT\$"| cut -f1 -d" ") | head -n 2 | tail -n1`;
ROOTUUID=`blkid -o value $(df / | grep "$MOUNTPOINT\$"| cut -f1 -d" ") | head -n 2 | tail -n1`;
PREFIX=""
if [ "$BOOTUUID" = "$ROOTUUID" ]; then
PREFIX="/boot"
fi;
View xmonad.hs
-- Define acpi power logger
acpi_power :: String -> [String] -> Logger
acpi_power dev attr =
io $ do
attrOut <- mapM (\x -> liftIO $ readFile $ sysFsPath ++ x) attr
return $ Just $ filter (/= '\n') (intercalate " " attrOut)
where
sysFsPath = "/sys/class/power_supply/" ++ dev ++ "/"
file_reader :: String -> Logger
View .zimrc
#################
# CORE SETTINGS #
#################
#
# Zim settings
#
@Amarandus
Amarandus / acpi_power_snippet.hs
Created Apr 19, 2017
Small snippet for a xmonad acpi logger that does not depend on /usr/bin/acpi or sed
View acpi_power_snippet.hs
-- dev is the device that shall be read (Like "BAT0")
-- attr are the attributes that are going to be read ("status" for charging status, "capacity" for charged capacity, and so on)
acpi_power :: String -> [String] -> Logger
acpi_power dev attr = io $ do
attrOut <- mapM (\x -> liftIO $ readFile $ sysFsPath ++ x) attr
return $ Just $ filter (/= '\n') (intercalate " " attrOut)
where
sysFsPath = "/sys/class/power_supply/" ++ dev ++ "/"
You can’t perform that action at this time.