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
  • 17:24 (UTC -05:00)
View GitHub Profile
@pmarreck
pmarreck / replit.nix
Created September 30, 2024 14:39
Roc playground nix file for repl.it
# note: does not currently work?
{ pkgs ? import <nixpkgs> { } }:
let
rocPkgs = pkgs.fetchFromGitHub {
owner = "roc-lang";
repo = "roc";
rev = "main"; # Change to a specific commit or tag for stability
sha256 = "sha256-11yw9xh1719smxbp0ia03kkv6hrvw4l6hhvxjxa4w2i7wc2r6yqy"; # You can fetch the sha256 from `nix-prefetch-url`
};
@pmarreck
pmarreck / overzealous_ai.html
Created September 25, 2024 23:48
An example of arguably overzealous language policing in OpenAI's ChatGPT, a.k.a. "why open-source LLMs will ultimately win"
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Conversation</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
#!/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 December 29, 2024 01:06
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
&gt;&gt;&gt; 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)