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
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))
);

Word Search

Prompt

This one came from Naomi K, who I was chatting with on IRC in the neighborhood of 2013:

Given a list of words, find all the orthogonal words in set string of characters. Lazy cracker asses need not apply.

Verbtionary

A problem I run into a lot while working with PowerShell is trying to find the right verb to use for a function. PowerShell functions are by convention named with the form {Verb}-{Noun}, and while the Noun can vary wildly (and is in fact often more "the rest of the sentence" than a noun per se), the Verb is supposed to conform to a list of approved PowerShell verbs. Sometimes finding the right verb is easy, especially if the verb you're looking for is already in the list, but sometimes it can be a challenge!

I hacked up an Azure function that hits the Merriam-Webster thesaurus API to look up synonyms for a given search and then sees which of them are included in the output of [Get-Verb](https://docs.microsoft.com/en-us/powershell/modul

@jfhbrook
jfhbrook / lmaowhat.org
Created March 8, 2020 19:01
This FUCKING WILD quote from Happier - Tal Ben-Shahar

When I was growing up, my favorite cartoon was Richie Rich: The Poor Little Rich Boy, about the struggles of a child, who, seemingly, had it all. The oxymoron in the title, of being poor and rich simultaneously, makes perfect sense if we invoke the ultimate currency: in our relatively to-do society, we see an increasing number of wealthy children - and adults - who are unhappy. Some refer to this phenomena as a form of “affluenza”; I have come to think of it as the underprivilege of privilege.