Skip to content

Instantly share code, notes, and snippets.

@rgarner
rgarner / mandelbrot.js
Last active May 6, 2024 07:30
The Magical Machine: live coding the mandelbrot set in p5.js
// A greyscale Mandelbrot set based on 100 iterations
// with a non-linear pow applied to make it Not Dark
// A complex number with an a (real) and b (imaginary) part.
// It can mutate itself by `add`ing itself to an `other`, or squaring itself in-place.
// It can also compare its own magnitude to an arbitrary given magnitude in `isBiggerThan`.
class Complex {
constructor(a,b) {
this.a = a;
this.b = b;
// It's an old untuned TV screen
function setup() {
createCanvas(400, 400);
pixelDensity(1);
loadPixels();
}
function shadeAt(x,y) {
return random(255);
}
#!/bin/bash
for APP in $(heroku apps -A | awk '{ print $1 }' | grep "[a-z]")
do
echo $APP ':'
heroku addons --app "$APP" | grep '/month'
heroku ps:type --app "$APP" | awk '$4 ~ /[1-9]/'
done
@rgarner
rgarner / masto-routes-jan-2023.txt
Created January 4, 2023 15:25
Mastodon routes Jan 2023
Prefix Verb URI Pattern Controller#Action
root GET / home#index
letter_opener_web /letter_opener LetterOpenerWeb::Engine
health GET /health(.:format) health#show
sidekiq /sidekiq Sidekiq::Web
pghero /pghero PgHero::Engine
native_oauth_authorization GET /oauth/authorize/native(.:format)
@rgarner
rgarner / diagram.rb
Last active August 5, 2022 11:08
Print the small constellation of objects in your integration test and how they relate. `include Diagram`, then `save_and_open_diagram`
# Print the small constellation of objects in your integration test and how they relate.
# Requires Graphviz. Optimised for Mac. YMMV.
module Diagram
def save_and_open_diagram(**args)
DotGenerator.new(**args).open
end
# Collect RSpec `let`s for a given example and all her parents
class RSpecLets
def initialize(example)
@rgarner
rgarner / assets.rake
Last active July 21, 2022 13:20
A rake-based approach to integrate jsbundling-rails into RSpec runs that only rebuilds when JS has changed.
# lib/tasks/asset.rake
#
# Hook up to jsbundling-rails by making spec:prepare dependent
# on app/assets/builds/application.js, a file-based equivalent to
# javascript:build. Will only rebuild when JS files have changed
if Rails.env.test?
ASSET_SOURCE_DIR = 'app/javascript'.freeze
ASSET_BUILDS_DIR = 'app/assets/builds'.freeze
JS_SOURCE = FileList["#{ASSET_SOURCE_DIR}/**/*"]
/*
Reference - not used directly, see PluginParameters, each of
which has a sendCC property
const PortamentoON_OFF=65;
const PortamentoValue=5;
const ArpON_OFF=117;
const ArpType=119;
const LegatoControl=118;
@rgarner
rgarner / gist:d6b9714f821629aea62535ee7a96e9a9
Last active June 1, 2020 07:32
ADPH Presidential Blog

ADPH Presidential Blog: A time for steady leadership, careful preparation and measured steps

May 31, 2020 in ADPH Updates, Covid-19, Health Protection, President's Blog by Campbell Findlay

COVID-19 has already taken a huge social and economic toll on our nation – and the reality is that it will continue to do so for some time.

We are at a critical moment. We need to weigh up the balance of risks between easing restrictions, to enable more pupils to return to school, more businesses to open and more social connections to happen, with the risk of causing a resurgence of infections.

Directors of Public Health are increasingly concerned that the Government is misjudging this balancing act and lifting too many restrictions, too quickly.

psql DataSubmissionServiceApi_development on [local] as russ
=> EXPLAIN ANALYZE
SELECT submissions.*,
COUNT(DISTINCT (orders.id)) AS _order_entry_count,
COUNT(DISTINCT (invoices.id)) AS _invoice_entry_count,
MIN(blobs.filename)::text AS _first_filename
FROM "submissions"
LEFT JOIN submission_entries orders
ON (
orders.submission_id = submissions.id
@rgarner
rgarner / extract.js
Created September 19, 2018 07:54
Pullng people out of a Twitter thread with jQuery
let people = {};
$('.ThreadedConversation--loneTweet .account-group').each(function(a, acc) {
let b = $(acc).find('.username b');
let name = b.text()
people[name] = { handle: '@' + name, name: $(acc).find('.fullname').text() };
}
);
console.log(JSON.stringify(people));