Skip to content

Instantly share code, notes, and snippets.

View muescha's full-sized avatar

Muescha muescha

View GitHub Profile
#!/usr/bin/env bash
ask() {
while true ; do
if [[ -z $3 ]] ; then
read -r -p "$1 [$2]: " result
else
read -r -p "$1 ($3) [$2]: " result
fi
if [[ -z $result ]]; then
@muescha
muescha / generate-slim-json-sample.rb
Last active January 9, 2024 10:16 — forked from apainintheneck/generate-slim-json-sample.rb
Testing a slimmer JSON representation for Homebrew Formula.
#!/usr/bin/env brew ruby
# Related to: https://github.com/Homebrew/brew/pull/16433
sample = Homebrew::API::Formula.all_formulae.keys.sample(25)
formulae = sample.map { Formulary.factory(_1) }
json = formulae.map(&:to_hash_with_variations)
json = json.map { Homebrew::API::Formula.slim_hash(_1) }
json_string = JSON.pretty_generate(json)
outfile_path = File.expand_path("~/Desktop/slim-formula-sample.json")
File.write(outfile_path, json_string)
@muescha
muescha / Countdown.java
Last active February 19, 2024 02:13 — forked from JosePaumard/Countdown.java
This is the Countdown class used for the episode 22 of the JEP Café series
import java.time.Duration;
import java.time.Instant;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Gatherer;
import java.util.stream.IntStream;
import java.util.stream.Stream;
/**