Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark S. Everitt qubyte

View GitHub Profile
@qubyte
qubyte / .eslintrc.json
Created Mar 26, 2020
Disallow .only in mocha test files.
View .eslintrc.json
{
"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 Nov 13, 2019
Conway's Game of Life. I put this together quickly as something to iterate on as a generative art project.
View index.html
<!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 Apr 22, 2019
My revised solution to Advent of code 2018 day 10 (both parts) in Rust, this time using recap.
View Cargo.toml
[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 / Cargo.toml
Last active Jan 1, 2019
My solution to Advent of code 2018 day 10 (both parts) in Rust.
View Cargo.toml
[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 Dec 9, 2018
Advent of Code 2018 day 8 task 2.
View d08-t2.rs
use std::io::{self, BufRead};
use std::str;
struct Node {
children: Vec<Box<Node>>,
metadata: Vec<usize>
}
impl Node {
fn evaluate(&self) -> usize {
@qubyte
qubyte / d06-t2.rs
Created Dec 7, 2018
Advent of Code day 06 task 2
View d06-t2.rs
use regex::Regex;
use std::io::{stdin, BufRead};
use std::cmp::{max};
#[macro_use]
extern crate lazy_static;
const MAX_TOTAL_DIST: usize = 10000;
fn abs_diff(a: &usize, b: &usize) -> usize {
@qubyte
qubyte / advent-of-code-2018-day-01-task-2.rs
Last active Dec 2, 2018
Advent of Code 2018 day 01 task 2.
View advent-of-code-2018-day-01-task-2.rs
use std::io::{stdin, BufRead};
use std::collections::BTreeSet;
fn main() {
let shifts: Vec<i32> = stdin().lock()
.lines()
.filter_map(|line| line.unwrap().parse().ok())
.collect();
let mut frequency = 0;
@qubyte
qubyte / d20p2.js
Created Jan 2, 2018
Advent of Code day 20 part 2
View d20p2.js
'use strict';
const rawInput = require('fs').readFileSync(process.argv[2], 'utf8').trim().split('\n');
const input = rawInput.map(line => {
const [p, v, a] = line.split(', ').map(part => part.slice(3, -1).split(',').map(n => parseInt(n, 10)));
return { p, v, a };
});
function isNaturalNumber(num) {
View advent-of-code-2017-d04p2-boring.js
// Usage: node advent-of-code-2017-d04p2-boring.js /path/to/input.txt
// This boring version works by lexicographically sorting the characters
// in each word of the pass phrase, and then adding them all to a set.
// If the size of the set is less than the number of words in the
// passphrase, then at least one pair of words were anagrams of each
// other and the passphrase invalid.
'use strict';
@qubyte
qubyte / json.js
Last active Sep 3, 2017
rollup plugin for wrapping a JSON file in a module with a default export only. This avoids the issue of fields being invalid names.
View json.js
// An as-simple-as-possible JSON plugin for rollup. This plugin turns a JSON
// file into a module with a default export. No named exports are given since
// field names are not always valid names.
// Originally drawn from the official JSON plugin.
function buildAst(code) {
return {
type: 'Program',
sourceType: 'module',
You can’t perform that action at this time.