Skip to content

Instantly share code, notes, and snippets.

View semicolonsnet's full-sized avatar

Chase Nordengren semicolonsnet

View GitHub Profile
@semicolonsnet
semicolonsnet / sleeptest.sh
Created March 13, 2022 21:28
Returns a non-zero error code if a macOS machine is asleep. Useful because Macs respond to pings when asleep, so you may need an alternative test.
#!/bin/bash
if [[ $(pmset -g powerstate | grep -E 'AppleDisplay') == "AppleDisplay 3 3 USEABLE" ]]
then
exit 0
else
exit 2
fi
@semicolonsnet
semicolonsnet / ConcatByDate.rb
Created July 26, 2021 04:05
Concatenates text files in a directory with daily date stamps into a single file for last month. The script is designed to be run on the first of the month to concatenate text files (e.g. journal entries) from the previous month.
#!/usr/bin/env ruby
$textdir = ""
$fileprefix = ""
$deletefiles = "false"
require 'time'
today = Time.now
@semicolonsnet
semicolonsnet / pi-optimize.sh
Created January 14, 2021 17:38
Optimizes a headless Raspberry Pi setup to conserve power and reduce SD card wear. Please review commands to make sure you don't need anything that's disabled here before using!
#!/bin/bash
# Processor Throttling - only use if you've got performance headroom!
#echo "arm_freq_min=250" >> /boot/config.txt
#echo "core_freq_min=100" >> /boot/config.txt
#echo "sdram_freq_min=150" >> /boot/config.txt
#echo "over_voltage_min=0" >> /boot/config.txt
# Disable boot splash screen
echo "disable_splash=1" >> /boot/config.txt
@semicolonsnet
semicolonsnet / Background Music.applescript
Created November 30, 2020 19:36
A quick-and-easy AppleScript to 1) loop a background music file, and 2) fade that file out when a dialog button is pressed. I use this when presenting slide decks virtually.
tell application "QuickTime Player"
set theFile to open POSIX file "FILENAME HERE"
set audio volume of theFile to 0.3
set looping of theFile to true
play theFile
end tell
display dialog "Music Control" buttons {"Fade"}
tell application "QuickTime Player"
@semicolonsnet
semicolonsnet / Shairport-buttons.py
Last active November 24, 2020 23:16
Python script for pHAT BEAT buttons to control device connected by Shairport-sync via DBUS. See Shairport-sync for instructions on enabling DBUS.
#!/usr/bin/env python
import signal
import os
import phatbeat
print("""
pHAT BEAT: Shairport Buttons
@semicolonsnet
semicolonsnet / Latin Ligature Find and Replace.csr
Last active November 9, 2020 03:16
Calibre file to assist with broken ligatures. If ligatures are showing up with strange characters (like √ for ff), this find-and-replace set will replace all Latin ligatures with their letter equivalents. Use by checking "Keep Ligatures" and loading this list under the Find and Replace tab in Calibre options.
ff
AA
aa
Æ
@semicolonsnet
semicolonsnet / TestMD.md
Created June 10, 2019 01:33
A document for testing Markdown stylesheets that includes all the basic Markdown elements

Markdown Test

Why are you closed? Tell us why you're closed. Tell us why you're closed. Why, why, why are you closed? I want to go shopping in the East Centre.

Why are you -- why are you closing your doors? Why are you locking your doors to the public? Why? Tell us the reason, why? Why? Why?

Heading 2

Tell us the reason.

@semicolonsnet
semicolonsnet / network-data-conversion.r
Created May 9, 2019 15:20
Various functions for converting social network data into different formats in R
csvtomatrix <- function (Y) {
# Converts CSV into data matrix
Y.m<-data.matrix(Y)
Y.m<-Y.m[,-1]
dimnames(Y.m) <- list (Y[,1],Y[,1])
diag(Y.m)<-NA
# Returns data matrix
Y.m
}
@semicolonsnet
semicolonsnet / Export All Skim.scpt
Created March 14, 2019 15:43
AppleScript to output notes from all PDFs in a directory as "Notes as Markdown", using my template for the Skim PDF editor.
set this_folder to ""
set export_folder to ""
set these_files to every file of folder this_folder whose name extension is "pdf"
end tell
repeat with i from 1 to the count of these_files
set this_file to (item i of these_files as alias)
set fileName to name of item i of these_files
set savePath to export_folder & ":" & fileName & ".md"
tell application "Skim"
open this_file
@semicolonsnet
semicolonsnet / Make List.applescript
Created May 29, 2015 17:13
Makes a Reminders list from a text file template (each line is a new task)
tell application "System Events"
set QueueList to display dialog "List Name" default answer ""
set listName to text returned of result
tell application "Reminders"
set myList to make new list
set name of myList to listName
set myFile to "FILE NAME HERE"
set myText to read myFile
set theList to paragraphs of myText