Skip to content

Instantly share code, notes, and snippets.

View duck57's full-sized avatar
🐚
Testing the status field and probably never touching it again

Chris J.M. duck57

🐚
Testing the status field and probably never touching it again
View GitHub Profile
@duck57
duck57 / fbppb.ex
Created October 29, 2021 22:24
A more generic FizzBuzz implementation
defmodule FizzBuzz do
def fizzbuzz(words \\ [{3, "Fizz"}, {5, "Buzz"}], min \\ 1, max \\ 100) do
min..max |> Enum.map(&_fizznum(&1, words))
end
def _fizznum(n, words) do
w = words |> Enum.map(&_checkword(&1, n)) |> Enum.join("")
case w do
"" -> n
_ -> w
@duck57
duck57 / probability.ex
Created October 17, 2021 00:49
Weighted random in Elixir
defmodule ProbabilityWeight do
@moduledoc """
A collection of functions for randomly choosing from a weighted list
"""
@doc """
Transforms a list of {item, weight} tuples into two lists: items and weights
Items with weights less than 1 or non-integer weights are skipped
"""
@duck57
duck57 / fbppb.py
Last active September 22, 2021 01:56
User-configurable Fizz Buzz
#!/usr/bin/env python3
import click
from typing import *
"""
Fizz Buzz Pow Pop Bang
Like your classic FizzBuzz but with more interactivity and control
of which numbers get replaced
@duck57
duck57 / mac_chime.sh
Created November 8, 2016 03:28
Restores the Mac's boot chime
sudo nvram BootAudio=%01
@duck57
duck57 / PDFreduce.sh
Created October 2, 2016 03:07
PDF size reducer
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=<your-smaller-file>.pdf <yourfile>.pdf
@duck57
duck57 / Pokémon.csv
Last active August 22, 2016 04:05
Improved Version of the Pokémon GO spreadsheet
Level XP required Total XP Unlocked items Ball Balls Potion Potions Max? Revives Razz Berries Incense Lucky Eggs Incubators Lure Modules
1 0 0
2 1,000 1,000 Poké 10
3 2,000 3,000 Poké 15
4 3,000 6,000 Poké 15
5 4,000 10,000 Gyms, Potions, Revives Poké 20 Normal 10 10 1
6 5,000 15,000 Poké 15 Normal 10 5 1
7 6,000 21,000 Poké 15 Normal 10 5 1
8 7,000 28,000 Razz Berry Poké 15 Normal 10 5 10 1
9 8,000 36,000 Poké 15 Normal 10 5 3 1
@duck57
duck57 / pogo.tsv
Last active August 20, 2016 05:22
TSV of the XP required and rewards for each level in Pokémon go
Level XP required Total XP Unlocked items Rewards
1 0 0
2 1,000 1,000 Poke Ball x10
3 2,000 3,000 Poke Ball x15
4 3,000 6,000 Poke Ball x15
5 4,000 10,000 Gyms, Potions, Revives Poke Ball x20, Potion x10, Revive x10, Incense x1
6 5,000 15,000 Poke Ball x15, Potion x10, Revive x5, Incubator x1
7 6,000 21,000 Poke Ball x15, Potion x10, Revive x5, Incense x1
8 7,000 28,000 Razz Berry Poke Ball x15, Potion x10, Revive x5, Razz Berry x10, Lure Module
9 8,000 36,000 Poke Ball x15, Potion x10, Revive x5, Razz Berry x3, Lucky Egg x1
@duck57
duck57 / DeadOfTheMUMPS.rou
Last active March 20, 2020 22:48
A self-reproducing ANSI MUMPS (a.k.a. M, furthermore known as Caché) one-liner
S Y=$C(34),X="W ""S Y=$C(34),X=""_Y X ""F %=1:1:6 W $P(X,Y,%),Y,Y"" W Y,"" X X""" X X