Skip to content

Instantly share code, notes, and snippets.

View JavadocMD's full-sized avatar

Tyler JavadocMD

View GitHub Profile
@JavadocMD
JavadocMD / api.ts
Created August 24, 2019 22:09
Express handler type constraints.
import { Request, NextFunction } from 'express'
interface JsonResponse<T> {
status(code: number): JsonResponse<T>
json(value: T): JsonResponse<T>
}
type JsonHandler<T> = (
req: Request,
res: JsonResponse<T>,
package com.javadocmd.drawing;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Pixmap;
@JavadocMD
JavadocMD / dedupe.ts
Created August 1, 2020 19:16
Removes repeated lines from the input.
import { Transform } from 'stream'
import { StringDecoder } from 'string_decoder'
const split = (r: RegExp = /\r?\n/) => {
const enc = 'utf8'
const dec = new StringDecoder(enc)
let prev: string = ''
return new Transform({
defaultEncoding: enc,
transform(chunk, e, callback) {
@JavadocMD
JavadocMD / index.js
Created August 3, 2020 22:38
Follow a Blaseball game for the given team and print updates to the console.
import { default as Socket } from 'socket.io-client'
// dependencies: socket.io-client
// Usage example:
// $ node ./dist/index.js "Philly Pies" | espeak-ng -v en-us -s 120
function main() {
const team = process.argv[2] || 'Philly Pies'
const socket = Socket('https://blaseball.com')
@JavadocMD
JavadocMD / UniRxCharacterV2.cs
Last active September 17, 2020 08:43
Developing a first person controller for Unity3D with UniRx: Part 2
using UnityEngine;
using UniRx;
using UniRx.Triggers;
// NOTE: Unity won't actually let you put two MonoBehaviours in one file.
// They're both listed here just for convenience.
namespace Assets.Scripts.v2 {
public class InputsV2 : MonoBehaviour {
@JavadocMD
JavadocMD / chrome_open_bookmark.py
Created November 12, 2016 00:18
A script to open Chrome bookmarks or entire folders of bookmarks by name. (Windows)
#!/usr/bin/env python
import os, subprocess, json
# Get all bookmarks matching the given name(s)
def get_bookmarks(profile_dir, names):
with open(os.path.join(profile_dir, 'Bookmarks')) as f:
j = json.load(f)
results = []
# There are two root-level bookmark folders: one for the bookmark bar and one for all others.
@JavadocMD
JavadocMD / UniRxCharacterV3.cs
Created July 20, 2016 23:22
Developing a first person controller for Unity3D with UniRx: Part 3
using UnityEngine;
using UniRx;
using UniRx.Triggers;
namespace Assets.Scripts.v3 {
public class InputsV3 : MonoBehaviour {
// Singleton.
public static InputsV3 Instance { get; private set; }
@JavadocMD
JavadocMD / Day01AkkaStreams.scala
Last active December 14, 2022 19:52
A solution to Advent of Code 2022 Day 1 using Akka Streams.
/*
Copyright 2022 Tyler Coles (javadocmd.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@JavadocMD
JavadocMD / Day01AkkaActors.scala
Last active December 14, 2022 19:52
A solution to Advent of Code 2022 Day 1 using Akka Actors.
/*
Copyright 2022 Tyler Coles (javadocmd.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@JavadocMD
JavadocMD / Day06Loops.scala
Last active December 14, 2022 19:52
A solution to Advent of Code 2022 Day 6 without sets, only loops (modeled as nested recursive functions).
/*
Copyright 2022 Tyler Coles (javadocmd.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software