Skip to content

Instantly share code, notes, and snippets.

View rhwood's full-sized avatar

Randall Wood rhwood

View GitHub Profile
@rhwood
rhwood / collectd-notify.py
Created August 4, 2021 19:42
Simple python script to send a collectd notification from the command line.
#!/usr/bin/python
#-*- coding: ISO-8859-1 -*-
# collectd-notify: send notifications to collectd from the command line
#
# Requires collectd to be configured with the unixsock plugin, like so:
#
# LoadPlugin unixsock
# <Plugin unixsock>
# SocketFile "/var/run/collectd-unixsock"
# SocketPerms "0775"
@rhwood
rhwood / # ant - 2020-02-10_06-01-06.txt
Created February 10, 2020 11:15
ant on macOS 10.15.3 - Homebrew build logs
Homebrew build logs for ant on macOS 10.15.3
Build date: 2020-02-10 06:01:06
@rhwood
rhwood / rpi3-wireless-drivers.sh
Last active August 2, 2017 12:39
CentOS 7 Raspberry Pi 3 Wireless Drivers
#!/bin/bash
curl --location https://github.com/raspberrypi/firmware/raw/master/boot/bcm2710-rpi-3-b.dtb > /boot/bcm2710-rpi-3-b.dtb
curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/54bab3d6a6d43239c71d26464e6e10e5067ffea7/brcm80211/brcm/brcmfmac43430-sdio.bin > /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin
curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/54bab3d6a6d43239c71d26464e6e10e5067ffea7/brcm80211/brcm/brcmfmac43430-sdio.txt > /usr/lib/firmware/brcm/brcmfmac43430-sdio.txt
echo "Reboot to ensure the dtb is initialized and kernel knows about the hardware in place."
echo
@rhwood
rhwood / jmri-4_2-osx-quick-fix.sh
Created December 26, 2015 20:02
Quick fix for JMRI 4.2 on OS X inability to edit serial connections
#!/bin/sh
sudo find / -name StartJMRI -type f -exec sed -i "" -e 's/\/dev\/tty\\\.\*//' -e 's/\/dev\/cu\\\.\*//' {} \;
@rhwood
rhwood / get-vi-answer.sh
Created December 1, 2015 17:47
Editor completion in bash (defaulting to using vi)
#!/bin/sh
INSTRUCTIONS="-- This line, and those below, will be ignored. --
Add a business case. The business case should be described briefly in a single
line on the first line, followed by a more detailed description on the
following lines."
CONTENT=""
@rhwood
rhwood / embedGist.js
Last active December 26, 2015 12:49
Javascript to display Gist in tumblr that specifies an individual file. The Gist URLs for single files need to be slightly different than the per-file permalink. It needs to be in the form https://gist.github.com/{gistId}?file={filename}#file-{filename-with-dashes-for-dots}
$(document).ready(function() {
$('.gist').each(function(i) {
var gistUrl = $(this).text();
var fileStart = gistUrl.indexOf('?');
if (fileStart != -1) {
var file = gistUrl.substring(fileStart + 1);
var fileEnd = file.indexOf('#');
if (fileEnd != -1) {
file = file.substring(0, fileEnd);
}
@rhwood
rhwood / get-vi-answer
Created August 8, 2013 19:04
Sample bash/sh code to prompt a user for a complex answer using vi.
#!/bin/sh
INSTRUCTIONS="-- This line, and those below, will be ignored. --
Add a business case. The business case should be described briefly in a single
line on the first line, followed by a more detailed description on the
following lines."
CONTENT=""
### Starting from a Fresh CentOS 6.2 Linode
### Enable the native kernel to boot from pvgrub
### It will autoconfigure itself with each yum update.
### This is adapted from a previous script for CentOS 5.5 found here:
### http://library.linode.com/assets/542-centos5-native-kernel-selinux-enforcing.sh
### Provided via the linode wiki
### http://library.linode.com/linode-platform/custom-instances/pv-grub-howto#sph_centos-5
### Provided without warranty, although since it should only be run
### on first box build if your box gets broken simply rebuild it
@rhwood
rhwood / install.sh
Last active December 10, 2015 15:20
OS X LaunchDaemon for a Jenkins Java Web Start slave. This is now maintained at https://github.com/rhwood/jenkins-slave-osx Please refer to that version instead.
#!/bin/sh
# create jenkins group
NEXT_GID=$((`dscl /Local/Default list /Groups gid | awk '{ print $2 }' | sort -n | grep -v ^[5-9] | tail -n1` + 1))
sudo dscl /Local/Default create /Groups/jenkins
sudo dscl /Local/Default create /Groups/jenkins PrimaryGroupID $NEXT_GID
sudo dscl /Local/Default create /Groups/jenkins Password \*
sudo dscl /Local/Default create /Groups/jenkins RealName 'Jenkins Node Service'
# create jenkins user
NEXT_UID=$((`dscl /Local/Default list /Users uid | awk '{ print $2 }' | sort -n | grep -v ^[5-9] | tail -n1` + 1))
sudo dscl /Local/Default create /Users/jenkins
@rhwood
rhwood / gist:4124251
Created November 21, 2012 10:50
ORSSerialPortManager:shouldAddSerialPort: sample
- (BOOL)serialPortManager:(ORSSerialPortManager *)manager shouldAddSerialPort:(ORSSerialPort *)serialPort {
CFMutableDictionaryRef usbProperties = 0;
io_object_t device = 0;
io_iterator_t iterator = 0;
BOOL add = NO;
if (KERN_SUCCESS == IORegistryEntryCreateIterator(serialPort.device, kIOServicePlane, kIORegistryIterateRecursively + kIORegistryIterateParents, &iterator)) {
while ((device = IOIteratorNext(iterator))) {
if (KERN_SUCCESS == IORegistryEntryCreateCFProperties(device, &usbProperties, kCFAllocatorDefault, kNilOptions)) {
NSUInteger vendorId = 0, productId = 0;
CFTypeRef reference;