Skip to content

Instantly share code, notes, and snippets.

🤔
pondering

Mark S. Everitt qubyte

🤔
pondering
Block or report user

Report or block qubyte

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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',
@qubyte
qubyte / observe-key.js
Created May 27, 2017
A module which returns an observable for a key. It streams `pressed` and `released` observations. Also has a getter for the pressed state of a key.
View observe-key.js
import Observable from 'zen-observable';
export default function observeKey(key) {
let pressed = false;
const observable = new Observable(observer => {
function downHandler(e) {
if (e.key === key && !pressed) {
pressed = true;
observer.next('pressed');
@qubyte
qubyte / arcade.ino
Last active May 2, 2017
Arduino Leonardo code to behave as a keyboard with pins set to MAME-ish key bindings.
View arcade.ino
#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
You can’t perform that action at this time.