Skip to content

Instantly share code, notes, and snippets.

@ggorlen
ggorlen / scrape-kanopy.js
Last active April 21, 2025 14:22
scrape kanopy
var results = [];
for (let pg =1;pg < 50_000; pg++) {
var res = await fetch(`https://www.kanopy.com/kapi/search/videos?sort=popular&rfp=exclude&domainId=2290&isKids=false&page=${pg}&perPage=40`, {
"credentials": "include",
"headers": {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0",
"Accept": "application/json, text/plain, */*",
"Accept-Language": "en-US,en;q=0.5",
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InVpZCI6IjMzMDU3NjkiLCJpZGVudGl0eV9pZCI6IjE3OTMxMDI2OCIsInZpc2l0b3JfaWQiOiIxNzQzOTExNDcwNTk5MDE5MjI1Iiwic2Vzc2lvbl9pZCI6IjE3NDUxODkxOTI0MjQwNTE3NzIiLCJjb25uZWN0aW9uX2lkIjoiMTc0NTE4OTE5MjQyNDA1MTc3MiIsImt1aV91c2VyIjoxLCJyb2xlcyI6WyJjb21Vc2VyIl19LCJpYXQiOjE3NDUxODkxOTIsImV4cCI6MjA2MDU0OTE5MiwiaXNzIjoia2FwaSJ9.dS0SQ32ZF5Vezr2Ha3GCvgFZ5tbzraAjIvRm_5LFCTI",
"X-Version": "web/prod/5.3.0/2025-03-24-13-06-01",
@ggorlen
ggorlen / chatgpt_turtle.py
Created April 8, 2025 20:34
ChatGPT turtle
import turtle
from os import environ
from openai import OpenAI # 1.12.0
instructions = input("What should I draw? ")
prompt = (
"Generate valid Python turtle code to draw the following input:"
@ggorlen
ggorlen / guitar-tuner.html
Created April 7, 2025 19:39
Guitar tuner
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="color-scheme" content="dark light">
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 16 16'><text x='0' y='14'>🎸</text></svg>" />
<title>Guitar Tuner</title>
<style>
body {
font-family: sans-serif;
@ggorlen
ggorlen / mic-wav.html
Created April 7, 2025 17:43
Converting web audio to wav
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Record Mic to WAV</title>
</head>
<body>
<button id="record">Record Mic</button>
<script>
@ggorlen
ggorlen / bs_test.py
Last active April 1, 2025 00:09
Test gist with a requirements.txt
from bs4 import BeautifulSoup
soup = BeautifulSoup("<p>hello</p><p>World</p>")
print("\n".join([x.text for x in soup.select("p")]))
@ggorlen
ggorlen / main.lua
Last active February 24, 2025 03:34
love2d-10print
local size = 20
local tiles = {}
function love.load()
local r, g, b = love.math.colorFromBytes(0, 130, 200)
love.graphics.setBackgroundColor(r, g, b)
love.window.setTitle("10 print")
height = love.graphics.getHeight()
width = love.graphics.getWidth()
math.randomseed(os.time())
@ggorlen
ggorlen / openai-api-fetch.php
Created July 12, 2024 14:19
OpenAI API request with PHP
<?php
function openAICompletion(array $messages): string {
$apiKey = 'OpenAI API key here';
$url = 'https://api.openai.com/v1/chat/completions';
$payload = [
'messages' => $messages,
'model' => 'gpt-4o',
'temperature' => 0
];
$options = [
@ggorlen
ggorlen / browser-automation-reprex.md
Last active July 5, 2024 22:38
Creating Reproducible Browser Automation Examples

Creating Reproducible Browser Automation Examples

Motivation

  • Without a minimal, reproducible example (reprex), in most cases, it's impossible to answer your question.
  • Without a reprex, the question isn't likely to provide value to future visitors with the same problem (the main purpose of Q&A sites like Stack Overflow).

Question Checklist

  1. Include your reprex code as text, not an image in the question itself (not an external link).
@ggorlen
ggorlen / food.py
Created July 1, 2024 17:11
Turtle Snake
from random import randint
from turtle import Turtle
class Food:
def __init__(self, move_dist):
self.move_dist = move_dist
self.t = t = Turtle()
t.shape("circle")
t.penup()
@ggorlen
ggorlen / codementor-payouts.html
Last active August 31, 2024 04:34
Codementor payouts visualizer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="Codementor payout visualizer">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Codementor Payout Visualizer</title>
</head>
<body>
<div>