Skip to content

Instantly share code, notes, and snippets.

@dnut
dnut / scoped-logging.zig
Created August 23, 2024 18:24
zig scoped logging poc using the type system
const std = @import("std");
pub fn main() void {
const logger: Logger = .{};
logger.log("starting the app");
const stuff = Stuff.init(logger);
stuff.doStuff();
}
const Stuff = struct {
{
"editor.fontFamily": "hack",
"explorer.confirmDragAndDrop": false,
"workbench.tree.indent": 20,
"security.workspace.trust.enabled": false,
"window.openFoldersInNewWindow": "on",
"window.openFilesInNewWindow": "default",
"editor.minimap.enabled": false,
"workbench.editor.limit.enabled": true,
"workbench.editor.limit.value": 6,
@dnut
dnut / logging.sh
Last active April 6, 2022 02:48
Logging library for bash to configure the current script to log to console and a file with timestamp and log level
# Reads from stdin and prefixes each line with a timestamp (if true) and default log level (if missing)
prefix_log() { local default_level=$1
while read -r line; do
local timestamp=''
local level=''
if ! [[ $line =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2} ]]; then
timestamp="$(date +"%Y-%m-%d %T.%3N") - "
if ! [[ $line =~ ^(TRACE|DEBUG|INFO|WARN|ERROR) ]]; then
level="$default_level - "
fi
@dnut
dnut / aurbox.sh
Last active December 17, 2020 00:46
aurbox - Create a fresh chroot for clean AUR package builds in Arch Linux.
direc=$(mktemp -d /mnt/aur.XXX)
mount -t tmpfs -o size=8G $direc $direc
pacstrap $direc base base-devel git vim
arch-chroot $direc <<"EOF"
cpu_core_count=$(getconf _NPROCESSORS_ONLN)
useradd -m aur
echo 'aur ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
echo "MAKEFLAGS=\"-j${cpu_core_count}\"" >> /etc/makepkg.conf
echo -e '[multilib]\nInclude = /etc/pacman.d/mirrorlist' >> /etc/pacman.conf
################################################################################
# Build a dockerfile for Prosody XMPP server
# Based on debian
################################################################################
FROM debian:stretch
RUN apt-get update
RUN apt-get install -y gnupg curl
admins = { "[email protected]" }
privileged_entities = {
["[email protected]"] = {
roster = "both";
message = "outgoing";
presence = "roster";
},
}
plugin_paths = { "/etc/prosody/prosody-modules" }
modules_enabled = {
@dnut
dnut / sgffixed.js
Created March 21, 2016 15:04
Soft Gray Facebook stylesheet Tampermonkey script, fixed for messages page
// ==UserScript==
// @name Soft Gray Facebook - fixed
// @namespace http://userstyles.org
// @description Facebook but softer, better, smoother! - fixed for messages
// @author pierO'nMu
// @homepage https://userstyles.org/styles/118898
// @run-at document-start
// @version 0.20160319054314
// ==/UserScript==
(function() {var css = "";