Skip to content

Instantly share code, notes, and snippets.

View aquila12's full-sized avatar

Lissa Moriarty aquila12

View GitHub Profile
@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
# 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
# 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
# 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
@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
@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 / 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
@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 / yhs-lulzbot-ao100-prusaslicer-config-bundle.ini
Last active November 26, 2022 23:34
Slice and print settings for YHS LulzBot AO-100
# generated by PrusaSlicer 2.5.0 on 2022-11-26 at 23:28:32 UTC
[print:Normal print 0.2mm]
avoid_crossing_perimeters = 0
avoid_crossing_perimeters_max_detour = 0
bottom_fill_pattern = monotonic
bottom_solid_layers = 3
bottom_solid_min_thickness = 0
bridge_acceleration = 0
bridge_angle = 0
@aquila12
aquila12 / pwned
Last active January 7, 2024 17:36
A really simple Ruby script to check password pwnage (because https://github.com/philnash/pwned isn't simple enough)
#!/usr/bin/env ruby
# Checks whether passwords have been pwned
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'excon'
end