Skip to content

Instantly share code, notes, and snippets.

View ddrscott's full-sized avatar

Scott Pierce ddrscott

View GitHub Profile
(() => {
const className = 'dataturd-sidebar';
function openIframe(url) {
if ( document.querySelector('.' + className) ) {
console.log('Sidebar already exists');
return
}
var styleTag = document.createElement('style');

Prompt

I want to create a FFT visualization in a single page web app. Please separate the HTMLCSS in JavaScript. The canvas should fill up the entire bottom of the screen. Provide a button at the top to start and stop recording. The FFT should be based on web audio taking microphone recordings.

Code

<!DOCTYPE html>
<html>
  <head>
"""
Prompt: Help me create Python script to play connect four against a computer ai opponent.
"""
# Define the game board
board_rows = 6
board_cols = 7
# Define the evaluation function for the minimax algorithm
def evaluate_window(window, piece):
@ddrscott
ddrscott / Makefile
Created January 3, 2023 17:41
Compile a bunch of pixel art frames into an animated gif.
frames=$(shell ls -tr bouncing-ball/*.png)
bouncing-ball.gif: $(frames)
convert -delay 12 -loop 0 -dispose previous -resize 256x -filter Point $(frames) $@
(
(imgs, h) => imgs.forEach((i, idx) => {
let l = document.createElement('a');
l.href=i.src;
l.download=`image-${idx}.png`;
l.innerText=l.download;
h.appendChild(l)
})
)(
d.querySelectorAll("#jmuse-scroller-component img[alt]"),
version: '3'
services:
db:
image: postgres:11
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=secret
volumes:
- database-data:/var/lib/postgresql/data/
- .:/app
"""
See __test_time function for example use
>>> import pathlib
>>> pathlib.Path("__test_time.pickle").unlink(missing_ok=True)
>>> a = __test_time() # Get current time
>>> import time
>>> time.sleep(0.1)
>>> __test_time() - a # Time should be the same since it is cached.
0.0
@ddrscott
ddrscott / color-picker-box.js
Created April 26, 2022 14:58
Simple color picker input maker. Every time it's used. It will append to existing container.
((d)=>{
let z=d.querySelector("#__z");
if (!z) {
z = d.createElement("div");
z.setAttribute("id", "__z");
z.setAttribute("style", "z-index: 999999; padding: 1em; position:fixed; display:flex; width:100vw; top: 0px; left:0px; align-items: center; flex-direction: row; flex-wrap: nowrap; align-content: space-around; justify-content: center; ");
d.body.appendChild(z);
}
let e=d.createElement("input");
e.setAttribute("type", "color");
@ddrscott
ddrscott / index.html
Created March 24, 2022 19:08
Simple Leaflet.js Map
<div id="map"></div>
@ddrscott
ddrscott / k-watch-all.sh
Created March 23, 2022 21:30
watch all the logs from everything in a namespace
kubectl logs -fl 'app!=empty' --all-containers --max-log-requests 999
# specify namespace
kubectl -n my_project logs -fl 'app!=empty' --all-containers --max-log-requests 999
# in case you have a label `app` equal to `empty`
kubectl -n my_project logs -fl 'any_existing_label!=a_real_value' --all-containers --max-log-requests 999
kubectl -n my_project logs -fl 'foo!=bar' --all-containers --max-log-requests 999