Skip to content

Instantly share code, notes, and snippets.

View qubyte's full-sized avatar

Mark S. Everitt qubyte

View GitHub Profile
@qubyte
qubyte / Cargo.toml
Last active August 18, 2022 12:10
My revised solution to Advent of code 2018 day 10 (both parts) in Rust, this time using recap.
[package]
name = "task-1"
version = "0.1.0"
authors = ["Mark S. Everitt <mark.s.everitt@gmail.com>"]
edition = "2018"
[dependencies]
recap = "0.1"
serde = "1.0.90"
@qubyte
qubyte / uint8-array-to-base64.js
Created November 15, 2021 09:59
Convert a Uint8Array to base64.
/**
* There's no real reason to use this. Buffer is available in node:
*
* Buffer.from(typedArray.buffer).toString('base64');
*
* and the browser has atob/btoa (which are fine to use for the ascii
* characters used to represent bytes.
*/
function byteToBin(byte) {
@qubyte
qubyte / walker.py
Created September 23, 2012 04:45
Simple quantum random walk
"""
Requires matplotlib for plotting. Tested with python 27. If you want to try this
without plotting, remove the final two lines and the pylab import. The guts only
depends on math and will work with vanilla python.
"""
import math
import pylab
def probabilities(posn):
@qubyte
qubyte / arcade.ino
Last active July 4, 2021 13:10
Arduino Leonardo code to behave as a keyboard with pins set to MAME-ish key bindings.
#include <Keyboard.h>
// MAMEish. An array of pin-key pairs.
struct { int pin; int key; } pinsToKeys[] = {
{ 2, KEY_LEFT_ARROW },
{ 3, KEY_UP_ARROW },
{ 4, KEY_RIGHT_ARROW },
{ 5, KEY_DOWN_ARROW },
{ 6, KEY_LEFT_CTRL }, // Fire 1
{ 7, KEY_LEFT_ALT }, // Fire 2
@qubyte
qubyte / StandardDeviation.js
Created November 13, 2012 08:51
Calculate a running standard deviation.
// A standard deviation object constructor. Running deviation (avoid growing arrays) which
// is round-off error resistant. Based on an algorithm found in a Knuth book.
function StandardDeviation(firstMeasurement) {
this.workData = firstMeasurement;
this.lastWorkData = null;
this.S = 0;
this.count = 1;
}
// Add a measurement. Also calculates updates to stepwise parameters which are later used
@qubyte
qubyte / gyoza.md
Last active August 25, 2020 15:21

Miya's famous gyoza

Miya makes gyoza on the fly, and doesn't work to exact quantities. However, this recipe is what she used the last time we made some.

Step 1

For the first step you will need:

  • 3 cloves of garlic, finely diced or minced
  • 2 tbsp ginger, finely diced or minced
@qubyte
qubyte / .eslintrc.json
Created March 26, 2020 10:10
Disallow .only in mocha test files.
{
"env": {
"mocha": true
},
"rules": {
"max-nested-callbacks": ["error", 7],
"no-restricted-properties": [
"error",
{ "object": "describe", "property": "only" },
{ "object": "context", "property": "only" },
@qubyte
qubyte / index.html
Created November 13, 2019 12:35
Conway's Game of Life. I put this together quickly as something to iterate on as a generative art project.
<!DOCTYPE html>
<html lang="en">
<head>
<script type="module" src="index.js"></script>
<title>Game of Life</title>
<meta charset="utf-8">
</head>
<body>
<h1>Game of Life</h1>
<canvas width="600" height="600"></canvas>
@qubyte
qubyte / Cargo.toml
Last active January 1, 2019 13:03
My solution to Advent of code 2018 day 10 (both parts) in Rust.
[package]
name = "task-1"
version = "0.1.0"
authors = ["Mark S. Everitt <mark.s.everitt@gmail.com>"]
edition = "2018"
[dependencies]
regex = "1"
lazy_static = "1.2.0"
@qubyte
qubyte / d08-t2.rs
Last active December 9, 2018 11:59
Advent of Code 2018 day 8 task 2.
use std::io::{self, BufRead};
use std::str;
struct Node {
children: Vec<Box<Node>>,
metadata: Vec<usize>
}
impl Node {
fn evaluate(&self) -> usize {