Skip to content

Instantly share code, notes, and snippets.

View aquila12's full-sized avatar

Lissa Moriarty aquila12

View GitHub Profile
@aquila12
aquila12 / chargeplot
Last active April 13, 2022 11:58
Battery charging plotter for Roomba 400 serial logs in gnuplot
#!/usr/bin/gnuplot -c
# Plot battery charge graph
logfile=ARG1
tmp=system("mktemp")
logname=system("basename '" .logfile. "'")
set terminal qt persist noraise size 400,600
set datafile separator ' '
@aquila12
aquila12 / Dockerfile
Created February 14, 2022 01:32
Dragonruby Wrapper, so that dragonruby-publish can work outside of the dragonruby install dir (so your repo doesn't need the runtime)
FROM ubuntu:latest
ENV PATH=/drb:${PATH}
RUN apt update; apt -y install libcurl4
@aquila12
aquila12 / wcag-contrast.scm
Last active May 1, 2024 08:07
WCAG Contrast checker for GIMP
; WCAG contrast checker
; aquila12 (Lissa Moriarty)
; (c) 2022
; Provided under the MIT license
; Select FG + BG colours to check
; Colours > Check WCAG Contrast Ratio
; Check status bar for report
; Based on the WCAG specifications
@aquila12
aquila12 / main.rb
Created August 19, 2021 17:45
A dragonruby example showing some vector maths for line intersection
def tick(args)
if args.tick_count.zero?
args.state.r10 ||= [100, 200]
args.state.r11 ||= [200, 100]
args.state.r20 ||= [100, 100]
args.state.r21 ||= [200, 200]
args.state.current_index = 0
args.state.items = [args.state.r10, args.state.r11, args.state.r20, args.state.r21]
end
# In-browser demo of static solids ("retained mode")
$points = 1000.times.map do |n|
[rand*1280, rand*720, 3, 3, rand*255, rand*255, rand*255, 255]
end
def move_points
50.times do |p|
p = $points[rand * $points.length]
p[0] += rand * 4 - 2
# In-browser test of tick rate when FPS is drooping
SOLIDS = 1000.times.map do |n|
[rand*1280, rand*720, 1, 1, rand*255, rand*255, rand*255, 255]
end
def tick args
@calls ||= 0
@t0 ||= Time.now
@calls += 1
# DragonRuby example showing save/load losing references
# Note how the ender-chests share an inventory, but on save/load they are separated
def empty_inventory
Hash.new { |h,k| h[k]=0 }
end
ITEMS = %i[books wood bricks leaves]
def defaults args
@aquila12
aquila12 / sumofcubes.rb
Last active April 5, 2020 10:05
Search for the largest number up to a limit that is the sum of two integers
#!/usr/bin/env ruby
# Find the largest number below N which can be expressed as the sum of two cubes
TARGET = ARGV.shift&.to_i || 1_000_000_000
class Numeric
def cubed
self ** 3
end
@aquila12
aquila12 / emotegen.scm
Last active May 1, 2024 08:07
Emote generator for GIMP
; Emote test page generator
; aquila12 (Lissa Moriarty)
; (c) 2022
; Provided under the MIT license
;
; for Scheherazade
(define AUTHOR_MAIL "Lissa Moriarty <h9e72r38k@mozmail.com>")
(define AUTHOR_NAME "Lissa Moriarty")
(define AUTHOR_DATE "17 Mar 2019")
@aquila12
aquila12 / aggressive-update
Last active February 20, 2022 20:25
An automatable update script for apt-based distros, designed for Ubuntu. Does basically what I'd do, but logs it.
#!/bin/sh
# Aggressive update script for apt-based distributions
DPKG_OPTIONS=--force-confold
LOG=/var/log/aggressive-update
error()
{
echo "$@" 1>&2
exit