Skip to content

Instantly share code, notes, and snippets.

View tosh's full-sized avatar
💭
🍄🌈

Thomas Schranz tosh

💭
🍄🌈
View GitHub Profile
@Gaelan
Gaelan / README.md
Last active August 29, 2023 04:13
ChatGPT passes the 2022 APCSA free response section

ChatGPT passes the 2022 AP Computer Science A free response section

For fun, I had ChatGPT take the free response section of the 2022 AP Computer Science A exam. (The exam also has a multiple-choice section, but the College Board doesn't publish this.) It scored 32/36.

Methodology

  • For each question, I pasted in the full text of the question and took the response given.
  • I tried each question once and took the response given: no cherry-picking. For readability, I've added indentation in some cases, and included method signatures where they were provided in the question and ChatGPT only provided a body. I've added question numbers; any other comments are ChatGPT's.
  • Many questions have examples containing tables or diagrams; because those don't translate well to plain text, I excluded those tables/diagrams and any text that referenced them.
  • I excluded the initial instructions at the top of th
@jeeger
jeeger / bookstats.clj
Last active November 26, 2022 15:37
Sum up page counts of books from Calibre library with babashka
#!/usr/bin/env bb
(ns bookstats
(:require [babashka.pods :as pods]
[clojure.pprint :as pprint]))
(pods/load-pod 'org.babashka/go-sqlite3 "0.1.0")
(pods/load-pod 'retrogradeorbit/bootleg "0.1.9")
(require '[pod.babashka.go-sqlite3 :as sqlite]
'[pod.retrogradeorbit.hickory.select :as s]
'[pod.retrogradeorbit.bootleg.utils :as utils])
(import [java.net URLEncoder]
@ssrihari
ssrihari / clojure-learning-list.md
Last active April 24, 2024 03:06
An opinionated list of excellent Clojure learning materials

An opinionated list of excellent Clojure learning materials

These resources (articles, books, and videos) are useful when you're starting to learn the language, or when you're learning a specific part of the language. This an opinionated list, no doubt. I've compiled this list from writing and teaching Clojure over the last 10 years.

  • 🔴 Mandatory (for both beginners and intermediates)
  • 🟩 For beginners
  • 🟨 For intermediates

Table of contents

  1. Getting into the language
@borkdude
borkdude / aoc21_01.clj
Last active December 22, 2021 02:32
Advent of Code 2021 - in Clojure / babashka 0.6.8
(ns aoc21-01
(:require [clojure.string :as str]))
(def input (map parse-long (str/split-lines (slurp "input.txt"))))
(defn answer-01 [input]
(count (filter true? (map < input (rest input)))))
(def three-sliding-window
(map + input (next input) (nnext input)))
@shawwn
shawwn / What happens when you allocate a JAX tensor on a TPU.md
Last active April 15, 2023 04:11
JAX C++ stack trace walkthrough for TpuExecutor_Allocate
#!/usr/bin/python3
# Solution to the challenge at https://gist.github.com/ehmo/7f515ac6461c1c4d3e5a74f12e6eb5ea
# Sample solution: https://twitter.com/marcan42/status/1428933147660492800
#
# Given an input base image, computes two derivative images that have different
# perceptual hashes, yet differ by only one pixel.
#
# Usage: hash_bisector.py <input.png> <output_a.png> <output_b.png>
#
# Licensed under the terms of the STRONGEST PUBLIC LICENSE, Draft 1:
@chrispsn
chrispsn / war_on_raze.md
Last active February 9, 2024 02:45
WAR ON RAZE

WAR ON RAZE

This is the story of what happened when I went down a rabbit hole.

It starts with k7. If you press Ctrl-] in the k7 WASM console, this appears:

x^x*/:x:2_!100

That's a prime number filter. There are faster ones - kparc.com's x,1_&&/80#'!:'x is beautiful - but this one is really short.

<?
//
// AUTO KEYWORD-BASED FOLLOWER CURATION BOT (by @levelsio)
//
// File: twitterFollowerCuratorBot.php
//
// Created: May 2021
// License: MIT
//
@searls
searls / do-this.js
Created May 24, 2020 04:05
How to play web audio that won't interrupt background system-wide audio playback in iOS
let audioContext
export function play (url) {
const AudioContext = window.AudioContext || window.webkitAudioContext
if (!audioContext) audioContext = new AudioContext()
const request = new window.XMLHttpRequest()
request.open('GET', url, true)
request.responseType = 'arraybuffer'
request.addEventListener('load', function (e) {
const source = audioContext.createBufferSource()
source.buffer = audioContext.createBuffer(request.response, false)
what k4/k7 k9 example result
---------------------------------------------------------------------------------
each-left a f\:b a f\:b (!3)*\:!2 (0 0;0 1;0 2)
each-right a f/:b a f/:b (!3)*/:!2 (0 0 0;0 1 2)
fold f/v f/v */6 7 42
fold w/initial a f/v a f/v 7*/11 13 1001
scan f\v f\v -\1 1 1 1 0 -1
scan w/initial a f\v a f\v 3-\1 1 1 2 1 0