Skip to content

Instantly share code, notes, and snippets.

View letsbreelhere's full-sized avatar

Bree Elle Gardner letsbreelhere

  • Academia, Inc.
  • Oakland, CA
View GitHub Profile
@letsbreelhere
letsbreelhere / rolling_output_buffer.rb
Last active July 22, 2025 16:44
Rolling output window in a terminal - a little snippet for command line tools
class RollingOutputBuffer
def initialize(max_lines = 10)
@max_lines = max_lines
@lines = []
@last_printed = 0
end
def <<(line)
@lines << line
shift if @lines.size > @max_lines
{"Baojun Tian":{"Baojun_Tian_1":{"works":["https://openalex.org/W2019946865","https://openalex.org/W2047378840","https://openalex.org/W2053935835","https://openalex.org/W2139918432","https://openalex.org/W2361050333","https://openalex.org/W2382782442","https://openalex.org/W2576565288","https://openalex.org/W4383333704","https://openalex.org/W4391429274","https://openalex.org/W4401416251"],"institutions":["Inner Mongolia University of Technology","Inner Mongolia University of Technology","Inner Mongolia University of Technology","Inner Mongolia University of Technology"],"subject":"Web service composition, Timed Colored Petri Net, Performance analysis, Computer Science, Software Engineering","titles":"The Performance Analysis of Web Service Composition Based on Timed Colored Petri Net; Formal Modeling and Verification for Web Service Composition; The research of formalizing UML diagram based on HCPNs; Formal modelling and validation for software process based on CPN; Programming thinking of STL based on C; Th
{"Adrien Nougarède":{"adrien-nougarede-1":{"works":["https://openalex.org/W2035075323","https://openalex.org/W2590552425","https://openalex.org/W2783142785","https://openalex.org/W2886260233","https://openalex.org/W2897249717","https://openalex.org/W3006173183","https://openalex.org/W3169142157","https://openalex.org/W3172197942","https://openalex.org/W3185390703","https://openalex.org/W3194982446","https://openalex.org/W4220927123","https://openalex.org/W4224240037","https://openalex.org/W4318245017","https://openalex.org/W4361234916","https://openalex.org/W4361234936","https://openalex.org/W4361235002","https://openalex.org/W4361235035","https://openalex.org/W4361235045","https://openalex.org/W4361235067","https://openalex.org/W4361235080","https://openalex.org/W4361235107","https://openalex.org/W4361235131","https://openalex.org/W4361235154","https://openalex.org/W4361235155","https://openalex.org/W4361235169","https://openalex.org/W4361235183","https://openalex.org/W4361235203","https://openalex.org/W4361
@letsbreelhere
letsbreelhere / scrollback.py
Created April 16, 2024 17:15
Print stdin, but only scroll the most recent n lines to avoid clutter
#! /usr/bin/env python3
import sys
import time
n = 5
if len(sys.argv) > 1:
n = int(sys.argv[1])
# Save the cursor position
@letsbreelhere
letsbreelhere / jarchive_parser.js
Created February 9, 2022 06:44
J! Archive Parser
import { parse } from 'node-html-parser';
const parseRound = (clueRoot, responseRoot) => {
const categories: Array<string> = clueRoot.querySelectorAll('td.category_name').map(c => c.rawText);
const clues = clueRoot.querySelectorAll('td.clue');
let result: Object<string, object> = {};
categories.forEach(category => {
result[category] = [];
})
@letsbreelhere
letsbreelhere / wordle.ijs
Last active January 11, 2022 22:51
Wordle autoplayer
letters =: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
allWords =: > (#~ (5&=@>@(# each))) }: each cutLF fread 'scrabble.txt'
NB. Letters are scored by their frequency's nearness to 50%
NB. and duplicates are counted once, since they provide less information.
bestWord =: monad define
freqs =. (#y) %~ <: #/.~ letters , ,y
scores =. ((1 = freqs) * %10) + 0.5 - | 0.5 - freqs
score =. [: +/ {&scores@(letters&i.)@~.
{. y \: > score"1 y
)
@letsbreelhere
letsbreelhere / hoogle_flow.rb
Last active December 17, 2019 18:03
Hoogle Alfred flow
require 'nokogiri'
require 'json'
require 'net/http'
require 'cgi'
def sanitize(text)
CGI.unescapeHTML(Nokogiri::HTML(text).xpath('//text()').to_s)
end
query_str = URI.escape("{query}")
@letsbreelhere
letsbreelhere / Knights.hs
Last active July 19, 2017 22:51
Uncrossed Knight's Tours
module Knights where
import Control.Monad (guard)
import Data.Tree
type Point = (Int, Int)
prune :: Int -> Tree a -> Tree a
prune n _ | n < 1 = error "Can't prune to height < 1"
prune 1 (Node x _) = Node x []
@letsbreelhere
letsbreelhere / Element.hs
Last active July 6, 2017 21:44
Element spelling solution
module Element where
import Data.List (isPrefixOf, (\\), intercalate)
import Control.Monad (guard)
import Data.Char (toLower)
elements :: [(String, String)]
elements =
[ ("Ac", "Actinium")
, ("Ag", "Silver")
@letsbreelhere
letsbreelhere / LambdaToSki.hs
Last active May 29, 2022 20:16
Lambda Calculus -> SKI Calculus
{-# LANGUAGE DeriveFunctor, FlexibleInstances, UndecidableInstances #-}
{-
A fun exercise: read lambda calculus expressions and convert them to
pointfree form in the SKI-calculus (see http://www.madore.org/~david/programs/unlambda/#lambda_elim).
Parsing (and output via Show) are written using the conventions at
the link above:
* Lambda-abstraction is written "^v.E" (equivalent to Haskell "\v -> E")
* Application is written "`lr" (equivalent to "l r")
Also, note that the conversion function gives binding priority to the