Skip to content

Instantly share code, notes, and snippets.

/*
setxattrs - bubbaATbubba.org
Properly sets sparse bundle extended attributes lost when rsyncing
sparse bundle data to a platform that does not support extended
attributes. This is only need when restoring/retrieving the
bundle.
To use, sync/copy all bundle files, then run this tool on the
sparse bundle:
@joshenders
joshenders / libhttpd.c.patch
Created February 8, 2015 06:51
X-Forwarded-For patch for thttpd-2.26
--- libhttpd.c 2014-12-10 12:53:07.000000000 -0800
+++ libhttpd.c.patched 2015-02-07 22:44:59.183663432 -0800
@@ -2231,6 +2231,12 @@
if ( strcasecmp( cp, "keep-alive" ) == 0 )
hc->keep_alive = 1;
}
+ else if ( strncasecmp( buf, "X-Forwarded-For:", 16 ) == 0 )
+ { // Use real IP if available
+ cp = &buf[16];
+ cp += strspn( cp, " \t" );
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define CANARY "in_the_coal_mine"
struct {
char buffer[1024];
@joshenders
joshenders / hdparm
Created December 21, 2014 02:13
/etc/default/hdparm
# To set the same options for a block of harddisks, do so with something
# like the following example options:
# harddisks="/dev/hda /dev/hdb"
# hdparm_opts="-d1 -X66"
# This is run before the configuration in hdparm.conf. Do not use
# this arrangement if you need modules loaded for your hard disks,
# or need udev to create the nodes, or have some other local quirk
# These are better addressed with the options in /etc/hdparm.conf
#
@joshenders
joshenders / shell_test.sh
Created December 19, 2014 06:39
shell_test
#!/bin/bash
# by Dennis Williamson
# 2010-10-06, revised 2010-11-10
# for http://stackoverflow.com/questions/3869072/test-for-non-zero-length-string-in-bash-n-var-or-var
# designed to fit an 80 character terminal
dw=5 # description column width
w=6 # table column width
t () { printf "%-${w}s" "true"; }
function npr() {
# Usage: npr
# autoplays NPR radio stream
local day="$(date '+%A')"
local date="$(date '+%m-%d-%Y')"
case ${day} in
Sunday)
local program='10'
;;
#!/bin/sh
#
# Originally found here: http://jenders.vox.com/library/post/macports-workaround-for-installing-distcc-31-on-an-intel-mac.html
#
makefile=/opt/local/var/macports/sources/rsync.macports.org/release/ports/devel/distcc/work/distcc-3.1/Makefile
if test -e $makefile; then # user has a half completed installation
break
@joshenders
joshenders / zfs
Last active November 12, 2017 18:58
/etc/sudoers.d/zfs
# Allow read-only ZoL commands to be called through sudo without a password.
# Cmnd alias specification
Cmnd_Alias RO_ZFS = \
/sbin/zfs "", /sbin/zfs help *, \
/sbin/zfs get, /sbin/zfs get *, \
/sbin/zfs list, /sbin/zfs list *, \
/sbin/zpool "", /sbin/zpool help *, \
/sbin/zpool iostat, /sbin/zpool iostat *, \
/sbin/zpool list, /sbin/zpool list *, \
@joshenders
joshenders / 02periodic
Last active August 29, 2015 14:01
/etc/apt/apt.conf.d/02periodic
// This file sets apt configuration variables for /etc/cron.daily/apt
// Values here are the default
// RootDir for all configuration files
// Dir "/";
// Set apt package cache directory
// Dir::Cache "var/cache/apt/";
// Set package archive directory
@joshenders
joshenders / ddns-update.sh
Last active August 29, 2015 14:01
afraid.org DDNS updater
#/bin/bash
# Cron every 10 minutes:
# 0,10,20,30,40,50 * * * * /usr/local/sbin/ddns-update
#
# For logging:
# $ mkdir /var/log/ddns-update
# $ cat << EOF > /etc/logrotate.d/ddns-update
# /var/log/ddns-update.log {
# rotate 3