Skip to content

Instantly share code, notes, and snippets.

int speakerPin = 9;
int length = 15; // the number of notes
char notes[] = "ccggaagffeeddc "; // a space represents a rest
int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 };
int tempo = 300;
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2)
{
digitalWrite(speakerPin, HIGH);
@rdmarsh
rdmarsh / zabbix pop parent groups
Last active June 8, 2021 01:25
iterates over zabbix groups going to each higher parent lever
zc/one/two/three/four
zc/one/two/three
zc/one/two
zc/one
@rdmarsh
rdmarsh / temp-glob.py
Created January 29, 2021 05:24
Raspberry Pi Pico and GLowBit Rainbow
# Raspberry Pi Pico and GLowBit Rainbow
# Combination of sample code from
# GloBit: https://core-electronics.com.au/tutorials/how-to-use-ws2812b-rgb-leds-with-raspberry-pi-pico.html
# Temperature: https://github.com/geerlingguy/baby-safe-temp/blob/master/main.py
import array, utime
from machine import Pin
import rp2
# Get the temperature from the internal RP2040 temperature sensor.
#!//bin/bash
URL_LIST='/home/pi/kids-internet.dat'
case ${1} in
block)
FLAG=''
;;
unblock)
FLAG='--delmode'
@rdmarsh
rdmarsh / make-list-hosts-relations.sh
Last active February 8, 2018 04:41
makes a list of twitter accounts that would be useful (un)following from a third account
#!/usr/bin/env bash
#
# Makes list of twitter accounts that should be (un)followed. To use; Create a
# twitter list, add primary users to it and set primarylist variable to list
# name You will get three lists
#
# * groupies: these accounts follow you, but you don't follow them
#
# * to follow: these accounts have a relation with your primary accounts, but
@rdmarsh
rdmarsh / brew-tree.sh
Created December 28, 2016 01:09
produces a dot graph for homebrew dependencies
#!/usr/bin/env bash
#produces a dot graph for homebrew dependencies
#run using `./brew-tree.sh | dot -Tpdf -o brew-tree.pdf`
set -e #exit immediately if a simple command exits with a non-zero status
set -u #treat unset variables as an error when performing parameter expansion
set -o pipefail #exit status of last non-zero exit code is returned
echo "digraph brew {"
@rdmarsh
rdmarsh / flash-pi-image.md
Created July 22, 2016 07:52
dm - flash pi images from mac

Pi images on mac

On mac, dd needs to be a lowercase 'm'.

prepare disks

diskutil list
sudo diskutil unmount /dev/disk3s1

raspbian

@rdmarsh
rdmarsh / autoshred-disks-inserted.md
Last active July 17, 2016 07:59
autoshred disks inserted

Will automatically shred any inserted disks without warning.

Designed for raspberry pi.

sudo cp 91-shred_usb_device_rule.rules /etc/udev/rules.d/
sudo chmod 644 /etc/udev/rules.d/91-shred_usb_device_rule.rules
sudo cp shred_usb_device.sh /usr/local/bin/shred_usb_device.sh
sudo chmod 755 /usr/local/bin/shred_usb_device.sh
@rdmarsh
rdmarsh / taildisk.md
Last active July 16, 2016 01:09
check data near end of disk

write last 2MB of disk to a file

# tailfile="taildisk-`date "+%Y%m%dT%H%M%S"`.dat"
# dd if=/dev/sda of=${tailfile} bs=512 skip=$(( $(blockdev --getsz /dev/sda) - 4096 ))
4096+0 records in
4096+0 records out
2097152 bytes (2.1 MB, 2.0 MiB) copied, 0.0185222 s, 113 MB/s
# ls -lah ${tailfile}

-rw-r----- 1 root root 2.0M Jul 16 11:08 taildisk-20160716T110821.dat

@rdmarsh
rdmarsh / centertext.pl
Last active June 1, 2016 04:17
simple example to center text on a line
#!/usr/bin/env perl -w
### 2016-06-01:davidm:simple program to center text on a line
use strict;
use warnings;
use POSIX;
#f1: string
#f2: total width