Skip to content

Instantly share code, notes, and snippets.

@gullyn
gullyn / day14part2.go
Created December 15, 2021 03:18
aoc day 14 part 2
package main
import (
"fmt"
"math"
"os"
"strings"
)
func hash(id string) uint64 {
@gullyn
gullyn / breakout.html
Last active June 5, 2021 11:25
Breakout in 360 bytes
<body onload="u=l=m.getContext`2d`;onkeydown=e=>k=e.which-38;setInterval(`l||b>w?(q=k=l=0,a=p=v=50,b=5e2,c=d=2):p+=k*2;m.width=m.height=w=610;a+=c-=a<0|a>w?2*c:0;b-=d-=b<0|(a>p&a<p+v&b>590)?d*2:0;for(i=-1;++i<30;x=i%10*60,y=~~(i/10)*20,!(q&2**i)&&${f='u.fillRect('}x,y,v,j=15),x<a&a<x+v&b>y&b<y+j&&(q|=2**i,d=-d));${f}p,590,v,j);${f}a,b,9,9)`,9)"><canvas id=m>
@gullyn
gullyn / render.html
Created January 21, 2021 13:09
render
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<canvas></canvas>
<script>
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
@gullyn
gullyn / analyze.py
Created January 20, 2021 12:42
analyze
import json, requests, re
def main():
print(page_length("Ivory_Coast", True))
countries = json.loads(open("countries.json", "r").read())
for country in countries:
link = country[1].split("wiki/")[1]
length = page_length(link, True)
print(country[0], length)
results = open("results.txt", "a")
@gullyn
gullyn / analyze.py
Created January 18, 2021 12:50
code
import requests, json, re
def main():
states = [l.split(",") for l in open("states.txt", "r").read().split("\n")]
state_codes = {l.split(",")[0].lower(): l.split(",")[1].lower() for l in open("state_codes.csv", "r").read().split("\n")}
pops = {l.split(",")[0].lower(): int(l.split(",")[1]) for l in open("pops.csv", "r").read().split("\n")}
styling = ""
lengths = {}
ratios = []
for state in states:
@gullyn
gullyn / breakdown.txt
Created January 17, 2021 16:09
breakdown
California: 977223
Etymology of California: 1749
Island of California: 34471
History of California: 445195
Indigenous peoples of California: 176626
California Republic: 448276
Conquest of California: 204275
History of California 1900%E2%80%93present: 450400
Geography of California: 122299
Climate of California: 268471
@gullyn
gullyn / results.txt
Created January 17, 2021 14:50
results
California: 5810441
Texas: 4097857
Florida: 3797057
New York: 5655709
Pennsylvania: 3110247
Illinois: 3240734
Ohio: 3532898
Georgia: 2651432
North Carolina: 3688125
Michigan: 1977142
@gullyn
gullyn / lengths.py
Created January 17, 2021 12:48
Wikipedia page lengths
import requests, json, re
def main():
states = [l.split(",") for l in open("states.txt", "r").read().split("\n")]
state_codes = {l.split(",")[0].lower(): l.split(",")[1].lower() for l in open("state_codes.csv", "r").read().split("\n")}
styling = ""
for state in states:
length = page_length(state[0], True)
print(f"{state[1].title()}: {length}")
styling += f".{state_codes[state[1]]} {{fill: {get_color(length)};}}\n"
@gullyn
gullyn / flappy.html
Last active May 4, 2024 15:35
Flappy bird in 205 bytes (improved!)
<body onload=z=c.getContext`2d`,setInterval(`c.width=W=150,Y<W&&P<Y&Y<P+E|9<p?z.fillText(S++${Y=`,9,9|z.fillRect(p`}*0,Y-=--M${Y+Y},P+E,9,W),P))):p=M=Y=S=6,p=p-6||(P=S%E,W)`,E=49) onclick=M=9><canvas id=c>