This file contains 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/zsh | |
# Author: Russell Harmon | |
setopt err_exit err_return | |
setopt function_argzero no_unset warn_create_global | |
declare -a flag_help flag_idle_percent_mode flag_user flag_password flag_fan_speed_percent flag_verbose | |
zparseopts -D -F -K -- \ | |
{h,-help}=flag_help \ | |
-idle_percent_mode=flag_idle_percent_mode \ | |
{u,-user}:=flag_user \ |
This file contains 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 | |
set -e | |
set -o pipefail | |
statefile="$(mktemp --tmpdir=/run spark-dirty-pages.XXXXX)" | |
trap 'rm -f $statefile' INT HUP QUIT | |
function watch_iter { | |
declare -a dirty | |
readarray -t dirty < "$statefile" |
This file contains 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
/** | |
* Create a generator that yields all hostnames. | |
* | |
* @param {NS} ns | |
* @param {String} hostname the host to start traversal at | |
* @param {Set} seen used for internal recursion | |
* @yields {String} a hostname | |
*/ | |
export function* getAllHostnames(ns, hostname = "home", seen = new Set()) { | |
seen.add(hostname); |
This file contains 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
/** | |
* Pathto finds the path of servers between a source and destination. | |
* | |
* @param {NS} ns | |
* @param {String} dest the hostname to try to find a path to | |
* @param {String} src the hostname to start at | |
* @param {Array} tosrc used for internal recursion | |
* @param {Set} seen used for internal recursion | |
* @returns {Array} the path from src to dest, or null if no path exists | |
*/ |
This file contains 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
#define _GNU_SOURCE | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <signal.h> | |
#include <time.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
#include <sys/syscall.h> | |
#include <stdbool.h> | |
#include <limits.h> |
This file contains 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
<source> | |
type tail | |
path /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs/*.log | |
pos_file /var/lib/google-fluentd/pos/plex.pos | |
read_from_head true | |
tag plex | |
format multiline | |
format_firstline /^[^ ]+ \d{1,2}, \d{4} \d{2}:\d{2}:\d{2}/ | |
format1 /^(?<time>^[^ ]+ \d{1,2}, \d{4} \d{2}:\d{2}:\d{2}) [^ ]+ (?<severity>[^ ]+) - (?<message>(?:(?:Request|Completed): \[(?<remotehost>[^:]+):[^\]]+\] (?<method>[^ ]+) (?<path>[^? ]+)(?:\?(?<querystring>[^ ]+))? \([^\)]+\)(?: (?:TLS|GZIP))*(?: [0-9]+ms (?<bytes>[0-9]+) bytes (?<status>[0-9]+))?.*|.+))$/ | |
</source> |
This file contains 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
/* | |
* Copyright (c) 2023 Russell Harmon | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* |
This file contains 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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(void) { | |
for (char *s = "good ", l = strlen(s), z = 2 * l, d[z], *p = d; p == d + z ? *--p = 0, !puts(d) : 1; p = memcpy(p, s, l) + l); | |
} |
This file contains 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 <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main(void) { | |
int wins = 2; | |
char *s = "good "; | |
char *p = malloc(wins * strlen(s) + 1); | |
for (int i = 0; i < wins; i++) p = strcat(p, s); | |
printf("%s\n", p); |
NewerOlder