Skip to content

Instantly share code, notes, and snippets.

@gigamonkey
gigamonkey / gpt-4.md
Created April 6, 2023 15:42
Translating CTE standards

CTE Standards, summarize by GPT-4

C1.0 Systems Development Process

  • C1.1 Life Cycle Phases

  • C1.2 Development Models

  • C1.3 Specifications, Requirements

@gigamonkey
gigamonkey / gpt-fruit.md
Last active March 27, 2023 19:42
Another GPT experiment.

GPT reads the comics

I needed to generate some data for a test I was writing for my Intro to Programming class. So I asked GPT (3.5 originally) just to give me a list of fruits and their colors. It provided me with a great list which I started to paste into my code and convert to JSON when I realized, GPT should be able to do that for me. So I asked it to and it did a great job.

Then I wanted to add some more attributes to my fruit data so I asked it this:

Q. Can you please describe how your implementation differs from, and is similar to, a program that generates text with a Markov Chain?

A. Yes, of course!

A Markov Chain is a mathematical system that undergoes transitions from one state to another according to certain probabilistic rules. In the context of text generation, a Markov Chain can be used to model the probability of seeing a certain word (or character) given the previous word (or character). Then, the text generator can use the model to randomly sample a sequence of words (or

/*
* Regexp to match a single HTML tag.
*/
const tagPattern = /^<(\w+)>$/;
/*
* Get or create a single element. If the query is in the form of a tag, e.g.
* '<p>' it creates an element of that type. Otherwise it queries the document
* using the argument as a selector.
*/
@gigamonkey
gigamonkey / church.js
Last active November 4, 2022 15:35
Demonstration of Church numerals and booleans in Javascript
// Church numerals -- functions of two arguments, a function and a zero value.
// The nth Church numeral applies an n-fold compostion f to the zero value.
const Zero = (f, z) => z;
const One = (f, z) => f(z);
const Two = (f, z) => f(f(z));
const Three = (f, z) => f(f(f(z)));
// etc.
/*
@gigamonkey
gigamonkey / Main.java
Created October 19, 2022 15:37
Ms. O'Keefe's loop challenge
/*
Write a program to generate this output:
#
$#
*$#
$*$#
*$*$#
$*$*$#
@gigamonkey
gigamonkey / clean-branches.sh
Last active October 16, 2022 18:44
Script to clean up local branches that have been merged to the current branch.
#!/bin/bash
# Script to clean up local branches that have been merged to the current branch.
# Normally you'd run this while on main.
set -euo pipefail
current=$(git branch --show-current)
git branch --merged | cut -c 3- | while read -r branch; do
@gigamonkey
gigamonkey / fn-to-svg.py
Created October 8, 2021 23:31
This is how I roll ...
#!/usr/bin/env python
from math import cos, pi
def svg(width, height, s, fn):
zero = s(0)
points = " ".join(f"{x},{s(fn(x, width))}" for x in range(width))
#!/usr/bin/env python
"Group people so everyone meets everyone."
import sys
from argparse import ArgumentParser, FileType
from collections import defaultdict
from itertools import combinations
from random import choice
@gigamonkey
gigamonkey / mult.py
Created May 15, 2020 00:00
Got nerd sniped by a terrible interview question
#!/usr/bin/env python3
# Let's pretend we have to implement 32-bit multiplication with just
# addition, subtraction, equality/inequality tests, and bit twiddling
# (shifts and bitwise logical ops). For bonus points detect overflow
# and signal via an exception.
# A friend got asked this on an interview. It is a terrible interview
# question unless possibly you're interviewing someone to be a junior
# chip designer or something. But it nerd sniped me anyway as an