Skip to content

Instantly share code, notes, and snippets.

View sixtyfive's full-sized avatar
🐯
Rawrrr.

J. R. Schmid sixtyfive

🐯
Rawrrr.
View GitHub Profile
@sixtyfive
sixtyfive / Rakefile
Last active May 28, 2019 11:38
Two variants of doing the same thing (also cf. https://rubular.com/r/WHXrCmrKPfQMAx)
REGEX = /([ -]+)\[{2}([^\]]*)\]\([^\]]*\]\(([^\)]*)\)/
SUBST = '\1[\2](\3)'
task :fix_toc_regex do
string = STDIN.read
puts string.gsub(REGEX, SUBST)
end
task :fix_toc_loop_plus_regex do
unless STDIN.tty?
@sixtyfive
sixtyfive / module_access.rb
Last active May 21, 2019 14:37
For future reference
#!/usr/bin/env ruby
module MyModule
module MyHelper
module_function def helpermethod
puts "helpermethod"
end
end
private_constant :MyHelper
@sixtyfive
sixtyfive / update-signal-desktop.sh
Created January 22, 2019 17:10
Simple bash script to download the latest version of Signal Desktop
#!/bin/bash
# Public domain. Use and abuse and tell me if you make it prettier,
# like, add a "--prefix" option or figure out where to put .desktop
# files or link the binary to...
echo -n "Looking up latest version, "
verurl="https://github.com/signalapp/Signal-Desktop/releases"
pkgver=$(curl -s "${verurl}" | grep "/signalapp/Signal-Desktop/releases/tag/" -m 1 | grep -oP '[\d\.]*')
#include <math.h>
unsigned const int led_count = 5;
int led_pin[led_count] = {10, 9, 6, 5, 3};
const unsigned int min_val = 25; // never go dark completely
const unsigned int max_val = 255; // don't kill the LEDs (atm there are no resistors)
void setup()
{
Serial.begin(9600);
@sixtyfive
sixtyfive / backup.sh
Created November 23, 2018 14:10
Simple backup script
#!/bin/bash
LOCS="/a /couple /of /paths"
DEST="/some/path"
HOST="user@host" # assuming pubkey auth
AORB="$((`date +%m` % 2))"
[[ $AORB = 1 ]] && AORB="a" || AORB="b"
set -x
#!/bin/sh
cut -d':' -f'1,6' /etc/passwd | while IFS=: read username userhome; do
rcfile="$userhome/.rc"
if case $rcfile in "/home"*) true;; *) false;; esac; then
if test -x "$rcfile"; then
su -c "$rcfile" "$username"
fi
fi
done
@sixtyfive
sixtyfive / hello_world_for_shri.ino
Last active November 12, 2018 23:45
Measure brightness with an ESP32 for fun but not for profit
#include <limits.h> // allow use of ranges in switch-case statements (1 ... 2, etc.)
#include "RunningAverage.h"
#define POWER_SUPPLY 3.3 // volts
#define ADC_MAX_VAL 4095 // 12 bits of resolution
#define ADC_MAX_V POWER_SUPPLY // some docs say not to go higher than 1V, some say 3V3 is fine
#define LED0 2
#define LED1 19
#define LED2 21
@sixtyfive
sixtyfive / LNDW.rb
Last active July 6, 2018 14:31
Tiny Ruby/Nokogiri script to extract event data for Halle's Long Night of the Sciences into a more usable form than it is given in on their website
#!/usr/bin/env ruby
require 'nokogiri'
require 'csv'
CSV.open('LNDW.csv', 'a+') do |csv|
Dir.glob('html/*.html') do |filename|
puts "Processing #{filename}..."
doc = Nokogiri::HTML(File.read(filename))
@font-face {
font-family: "Serto Jerusalem";
src: url("/assets/SertoJerusalem.eot?#iefix") format("embedded-opentype"), url("/assets/SertoJerusalem.woff2") format("woff2"), url("/assets/SertoJerusalem.woff") format("woff"), url("/assets/SertoJerusalem.ttf") format("truetype"); }
@font-face {
font-family: "Serto Jerusalem";
src: url("/assets/SertoJerusalemBold.eot?#iefix") format("embedded-opentype"), url("/assets/SertoJerusalemBold.woff2") format("woff2"), url("/assets/SertoJerusalemBold.woff") format("woff"), url("/assets/SertoJerusalemBold.ttf") format("truetype");
font-weight: bold; }
@font-face {
font-family: "Serto Jerusalem";
src: url("/assets/SertoJerusalemItalic.eot?#iefix") format("embedded-opentype"), url("/assets/SertoJerusalemItalic.woff2") format("woff2"), url("/assets/SertoJerusalemItalic.woff") format("woff"), url("/assets/SertoJerusalemItalic.ttf") format("truetype");
#define F_CPU 1000000UL // keep internal clock at 1 MHz, should be sufficient
#include <TinyWireM.h> // required by TinyDS1307
#include <USI_TWI_Master.h> // using I2C via the chip's USI
#include <TinyDS1307.h> // using the RTC - ATTN: the header needed changing to set the RTCs
// memory size to 0 because setting it to its actual value (56 bytes)
// grows the sketch beyond bounds!
#include <PinChangeInterrupt.h> // using PCINTs instead of INTs
#include <avr/io.h> // direct port manipulation
#include <util/delay.h> // to have a substitute for delay()