This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
ENV PATH=/drb:${PATH} | |
RUN apt update; apt -y install libcurl4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Aggressive update script for apt-based distributions | |
DPKG_OPTIONS=--force-confold | |
LOG=/var/log/aggressive-update | |
error() | |
{ | |
echo "$@" 1>&2 | |
exit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 ' ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Checks whether passwords have been pwned | |
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'excon' | |
end |
OlderNewer