Skip to content

Instantly share code, notes, and snippets.

@joshenders
joshenders / pling.sh
Created March 4, 2011 07:31
Silly little script to detect when WWAN is being flakey
#!/bin/bash
# WWAN can be flakey. This script pings your ISP's gateway. After 5 missed
# responses, this script produces an audible bell until the host starts
# responding again.
if [[ "$#" -ne '0' ]]; then
echo "Usage: $0" >&2
exit 1
fi
for vmhost in $(get-hosts oak-dev-vmhost); do
echo "$vmhost"
ssh root@$vmhost "virsh list --all" | \
sed -e '
/^\ I.*/d; # Id Name State
/^-.*/d; # ----------------------------------
/^$/d; # <blank lines>
' | \
tr -s ' ' | \
cut -d' ' -f3 | \
@joshenders
joshenders / partscan.sh
Created August 31, 2011 10:24
NTFS partition scanner
#!/bin/bash
start=1048576 # decimal offset of data on drive (past MBR, 1MB)
end=10485760 # decimal offset of data on drive (well past weird '...U...N.b..' structures, 10MB)
image=/mnt/seagate/wd_backup.img
mount=/mnt/wd
for ((offset=$start; offset<=$end; offset++)); do
echo "trying offset: $offset"
status="$(mount -o ro,offset=$offset,loop -t ntfs $image $mount >/dev/null 2>&1; echo $?)"
@joshenders
joshenders / history
Created May 15, 2012 01:54
environment variables relating to .bash_history
# Unset bounds on history file. Disk is cheap, unlimited is fine until it's not
# and then rotate
export HISTFILESIZE=
export HISTSIZE=
# Add timestamps to .bash_history
# TODO: find someway to store the current working directory for forensics
export HISTTIMEFORMAT="%d/%m/%y %T "
# The "ignoreboth" setting ignores repeated lines as well as silently discards
@joshenders
joshenders / mdsetup.md
Last active November 19, 2023 19:04
Create mdraid mirror from an existing Wheezy installation

Create mdraid mirror from an existing Debian installation

Throughout this guide, /dev/sda will be referred to as the old drive and /dev/sdb will be referred to as the new drive. If possible, I suggest disconnecting all other disks attached to the system while performing this maintenance.

Prerequisite software

apt-get install mdadm rsync

1. Partition the new drive.

sfdisk -d /dev/sda | sfdisk /dev/sdb 

sfdisk --change-id /dev/sdb 1 DA # change partition-type to, "0xDA" aka "non-fs data" as "linux raid auto" is deprecated

@joshenders
joshenders / gist:3976698
Last active November 7, 2015 07:15 — forked from vena/gist:2856490
How to install Netatalk 3.1.6 under Debian Wheezy

1. Install dependencies

apt-get install automake avahi-daemon build-essential checkinstall db5.1-util db-util git-core libacl1-dev libavahi-client-dev libdb5.1-dev libgcrypt11 libgcrypt11-dev libpam0g-dev libtool pkg-config

2. Download and unpack source

cd /usr/src/
wget http://prdownloads.sourceforge.net/netatalk/netatalk-3.1.6.tar.gz
tar -xvzf netatalk-3.1.6.tar.gz
@joshenders
joshenders / gist:3977873
Last active March 9, 2016 21:35
Install Unreal 2004 on Mac from Demo
@joshenders
joshenders / sabnzbdplus.default
Last active December 8, 2017 19:50
Installing sabnzbdplus on Debian Wheezy from source
# This file is sourced by /etc/init.d/sabnzbdplus
#
# When SABnzbd+ is started using the init script, the
# --daemon option is always used, and the program is
# started under the account of $USER, as set below.
#
# Each setting is marked either "required" or "optional";
# leaving any required setting unconfigured will cause
# the service to not start.
@joshenders
joshenders / virtual_box_hdd.md
Last active December 10, 2015 03:48
How to solve a "used exclusively by host" error in VirtualBox

Yanked, from here: https://forums.virtualbox.org/viewtopic.php?f=2&t=24748

1. First, I used 'VBoxManage list usbhost' to get info on the device

VBoxManage list usbhost

VirtualBox Command Line Management Interface Version 3.0.10
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Host USB Devices: