Skip to content

Instantly share code, notes, and snippets.

View jemmyw's full-sized avatar

Jeremy Wells jemmyw

View GitHub Profile
#!/usr/bin/env ruby
require "open3"
ANSI_REGEX = Regexp.new('\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
SPEC_EXT = "_spec.rb"
BRANCHED_FROM = "master"
RSPEC_ENV = {
"FULL_CHROME" => "0",
"DISABLE_SPRING" => "",

Keybase proof

I hereby claim:

  • I am jemmyw on github.
  • I am jemmyw (https://keybase.io/jemmyw) on keybase.
  • I have a public key ASBv7S6w-_e4616-DSba-JcAaEbvo6xfO40yikIxN8jB5wo

To claim this, I am signing this object:

@jemmyw
jemmyw / useSubscription.ts
Created May 6, 2019 21:26
useSubscription
import { useEffect, useState } from 'react';
import { Observable, Subscription } from 'rxjs';
export const useSubscription = (fn: () => Subscription, inputs: any[]) => {
return useEffect(() => {
const subscription = fn();
return () => subscription.unsubscribe();
}, inputs);
};
@jemmyw
jemmyw / 16.ts
Created December 22, 2018 01:59
import * as fs from 'fs';
interface Opcodes {
[index: string]: (registers: number[], a: number, b: number) => number;
}
type Sample = [number[], number[], number[]];
const opcodes: Opcodes = {
addr: (r, a, b) => r[a] + r[b],
@jemmyw
jemmyw / 15.ts
Created December 21, 2018 10:57
import * as fs from 'fs';
interface Player {
label: 'G' | 'E';
hp: number;
power: number;
coord: Coord;
}
type Coord = [number, number];
@jemmyw
jemmyw / 14.ts
Created December 18, 2018 09:16
let recipeScores: number[], i1: number, i2: number, serialized: string;
function reset() {
recipeScores = [3, 7];
i1 = 0;
i2 = 1;
serialized = '37';
}
function updateScores() {
@jemmyw
jemmyw / 13.ts
Created December 17, 2018 22:35
import * as fs from 'fs';
type Coord = [number, number];
type Direction = 'l' | 'r' | 'u' | 'd';
type Turn = 'l' | 'r' | 's';
type Curve = '\\' | '/';
interface Cart {
id: number;
direction: Direction
coord: Coord;
@jemmyw
jemmyw / 11.ts
Created December 15, 2018 10:54
const gs = 300;
const serial = 4151;
function value(x: number, y: number) {
const rackId = x + 10;
const s2 = rackId * y;
const s3 = s2 + serial;
const s4 = s3 * rackId;
const s5 = s4 < 100 ? 0 : Number(String(s4).slice(-3, -2));
const s6 = s5 - 5;
@jemmyw
jemmyw / 10.ts
Created December 15, 2018 05:28
import * as fs from 'fs';
type Point = [number, number]
interface PointInput {
p: Point
v: Point
}
const pointInput = fs.readFileSync('10.txt').toString()
@jemmyw
jemmyw / 8.exs
Created December 13, 2018 06:20
defmodule Tree do
def parse(str) when is_bitstring(str) do
str |> String.split() |> Enum.map(&String.to_integer/1)
end
def nodes_metadata(list)
def nodes_metadata([]) do
{[], []}
end