Skip to content

Instantly share code, notes, and snippets.

View jfhbrook's full-sized avatar
💭
KNEE DEEP IN THE HOOPLA

Josh Holbrook jfhbrook

💭
KNEE DEEP IN THE HOOPLA
View GitHub Profile
@jfhbrook
jfhbrook / plusdeck.py
Created February 10, 2024 18:06
Three suggested APIs
import asyncio
from plusdeck import Command, State, Side, PlusDeckProtocol, create_connection
PORT = '/dev/ttyUSB0'
# event emitter
async def main():
client = await create_connection(PORT)
@jfhbrook
jfhbrook / main.tf
Created December 27, 2023 21:43
Sketch of the Writing Interactive Compilers and Interpreters architecture
import { ConsoleHost } from './host';
import { Translator } from './translator';
import { Commander } from './commander';
import { Editor } from './editor';
import { Runtime } from './runtime';
import { Errors } from './errors';
export async function main() {
// TODO: where do global variables live? Especially if global variables
// can be accessed by the Commander as well as the Runtime...
@jfhbrook
jfhbrook / points.md
Last active September 10, 2022 21:27

POINTS

DRIVER’S LICENSE POINT ASSIGNMENT

If you are convicted of, or forfeit bail for, a moving traffic violation occurring in this, or any other State, points will be entered on your Alaska driving record. Assigned points are based on the following schedule:

Type of Violation // Point Value

  • Operating a motor vehicle while privilege to do so is suspended or revoked or in violation of limited license......................................................................................... 10
  • Driving while intoxicated / under the influence ............................................................. 10
  • Reckless driving ........................................................................................................... 10
use std::os::unix::net::UnixStream;
use std::net::Shutdown;
use std::io::{BufRead, BufReader,BufWriter, Write};
use std::thread;
use anyhow::{Result, Error};
use clap::{Parser, Subcommand};
// use miette::{Diagnostic, SourceSpan};
// use thiserror::Error;
use rustyline::error::ReadlineError;
@jfhbrook
jfhbrook / test.ts
Created March 27, 2022 05:08
aghast test handler using shot^H^H^H^Hpickleback
import { IncomingMessage, ServerResponse } from 'http';
import { inject, RequestOptions } from 'pickleback';
import { Opts, defaults } from '../opts';
export interface TestHarness<R> {
(reqOpts: RequestOptions, opts?: Opts): Promise<R>
}
export interface TestHandler<R> {
@jfhbrook
jfhbrook / mlp.js
Created March 23, 2022 17:55
Sketch of an API for a javascript proxy layer
module.exports = ({ forward, listen, match, proxy, whenever }) => {
// dokuwiki
listen(80, () => {
whenever(match('/'),
forward('localhost', 8080)
);
});
// pulp
listen(24816, () => {

I was trying to build the yq PyPI package on COPR and I got an error. Here's the relevant snippet:

+ /usr/bin/python3 setup.py test
running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
running egg_info
writing yq.egg-info/PKG-INFO
writing dependency_links to yq.egg-info/dependency_links.txt
writing entry points to yq.egg-info/entry_points.txt
@jfhbrook
jfhbrook / record-scratch-freeze-frame.js
Created December 21, 2021 07:07
*record scratch* *freeze frame* yup, that's me. you're probably wondering how I got in this situation
// I wanted to use https://npm.im/terminal-image in kitty. Kitty supports
// inline image functionality similar to iTerm2, and while I was too lazy
// to look up whether they're the same I *wasn't* too lazy to try and make
// terminal-image think it's running in iTerm2.
//
// So you dig down the dependency tree. terminal-image is by @sindresorhus,
// who is known for two things:
//
// 1. Going hard on es modules without support for require
// 2. Going hard on micro-modules with deep dependency trees
#!/usr/bin/env bash
FILE="${1}"
EXTENSION="${FILE##*.}"
case $EXTENSION in
pdf)
pdftotext -layout -eol unix -nopgbrk "${FILE}" -
;;
jpg|jpeg|gif|png)
@jfhbrook
jfhbrook / loader.js
Last active August 16, 2021 23:30
Is there a module that does this already?
var fs = require('fs'),
ejs = require('ejs');l
module.exports = function(root) {
var templates = {};
fs.readdirSync(root).forEach(function (filename) {
templates[path.basename(filename)] = ejs.compile(
fs.readFileSync(path.join(root, filename))
);