Skip to content

Instantly share code, notes, and snippets.

View pmarreck's full-sized avatar

Peter Marreck pmarreck

  • formerly senior engineer @ desk.com, chief engineer @ thredup.com, software engineer @ lifebooker.com. Director of Engineering @ addigence.com, currently available
  • Long Island, NY
  • 13:53 (UTC -04:00)
View GitHub Profile
#!/usr/bin/env bash
# OK, why tabs? Why resurrect this age-old nerd debate again?
# Very simple: It's an accessibility issue:
# https://adamtuttle.codes/blog/2021/tabs-vs-spaces-its-an-accessibility-issue/
# To set the default tab width on your terminal (which unfortunately defaults to 8),
# run: `tabs -2` (or whatever width you want), possibly in your dotfiles.
# is AWK set to anything? If not, prefer frawk, then gawk, then awk
[ -z "${AWK}" ] && export AWK=$(command -v frawk || command -v gawk || command -v awk)
@pmarreck
pmarreck / comparison-of-shells.md
Last active August 21, 2024 17:10
Comparison of Bash, Elvish, NuShell, Murex, es-shell, fish, xonsh, PowerShell, Oil and Ion shells

(generated by chatgpt 4o and reviewed/edited by claude 3.5 sonnet, YMMV)

| Feature | Bash | Elvish | NuShell | Murex | Es Shell | Fish | Xonsh | PowerShell | Oil | Ion | |----------------------------------|-----------------------------------------------|-----------------------------------------------|----------------------------------------------|----------------------------------------------|----------------------------------------------|----------------------------------------------|----------------------------------------------|----------------------------------------------|-------------------------

@pmarreck
pmarreck / github_issues_to_markdown.sh
Created August 20, 2024 20:19
Bash one-liner to turn a complete Github Issues thread into pretty-printed Markdown in the terminal
# requires curl, jq and glow
# example
curl -s "https://api.github.com/repos/simonw/shot-scraper/issues/1/comments" | jq -r '.[] | "## Comment by \(.user.login) on \(.created_at)\n\n\(.body)\n"' | glow -
@pmarreck
pmarreck / cobalt.json
Created June 5, 2024 22:04
Cobalt theme (the original one from TextMate) for the Zed editor
{
"$schema": "https://zed.dev/schema/themes/v0.1.0.json",
"name": "Cobalt",
"author": "Jacob Rus",
"theme.translator": "Peter Marreck",
"themes": [
{
"name": "Cobalt",
"appearance": "dark",
"style": {
@pmarreck
pmarreck / holidays.ex
Created May 23, 2024 19:13
Computing holidays with a DSL in Elixir
defmodule Addigence.Holidays do
use Timex
@holidays [
{:new_years_day, [:fixed, 1, :January]},
{:new_years_day_observed, [:nearest_weekday_to, 1, :January]},
{:martin_luther_king_jr_day, [:third, :monday, :January]},
{:washingtons_birthday, [:third, :monday, :February]},
{:good_friday, &Addigence.Holidays.compute_good_friday/1},
{:memorial_day, [:last, :monday, :May]},
@pmarreck
pmarreck / compact_datetime_ms.exs
Created May 22, 2024 22:52
Compact datetime format for Elixir use
# requires the Timex library though
Timex.format!(Timex.now(), "%Y%m%d%H%M%S.%L", :strftime)
@pmarreck
pmarreck / simple_llm_question.md
Last active April 20, 2024 19:32
gpt4 vs llama3 on a book content question

Me: What are the algorithms in "50 Algorithms Every Programmer Should Know" by Imran Ahmad?

ChatGPT: I don't have direct access to the specific content of books or their indexes, including "50 Algorithms Every Programmer Should Know" by Imran Ahmad. However, I can suggest some common algorithms that are likely to be included in a book aimed at covering essential algorithms for programmers: (invented list of algorithms follows)

Me posing the same question to the newly-released Llama3:70b :

bash> ollama run llama3:70b
>>> What are the algorithms in "50 Algorithms Every Programmer Should Know" by Imran Ahmad?
@pmarreck
pmarreck / cusip_validator.ex
Last active April 8, 2024 22:56
CUSIP Validator in Elixir
defmodule CUSIP do
@spec valid?(String.t) :: boolean
def valid?(cusip) when is_binary(cusip) do
validate_format(cusip) && validate_checksum(cusip)
end
@spec validate_format(String.t) :: boolean
def validate_format(cusip) when is_binary(cusip) do
Regex.match?(~r/^[a-zA-Z0-9]{5}[a-zA-Z0-9\*@\#]{3}[0-9]?$/, cusip)
@pmarreck
pmarreck / pg_dump command
Created April 1, 2024 22:12
Dumping an entire postgres database
#!/usr/bin/env bash
datetimestamp() {
local datebin="date";
$datebin --resolution > /dev/null 2>&1 || datebin="gdate";
$datebin --resolution > /dev/null 2>&1 || datebin="date";
local format=${DATETIMESTAMPFORMAT:-'+%Y%m%d%H%M%S'};
case "$1" in
--date=* | -d=*)
$datebin --date="${1#*=}" "$format"
@pmarreck
pmarreck / flake.nix
Last active February 11, 2024 23:41
A basic flake.nix file for cross-platform Python projects. Use with "nix develop". pip, etc. should work via venv.
{
description = "A flake for pythonification";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
flake-utils.lib.eachSystem ["x86_64-darwin" "aarch64-darwin" "x86_64-linux" "aarch64-linux"] (system: