Skip to content

Instantly share code, notes, and snippets.

@gullyn
gullyn / day14part2.go
Created Dec 15, 2021
aoc day 14 part 2
View day14part2.go
package main
import (
"fmt"
"math"
"os"
"strings"
)
func hash(id string) uint64 {
@gullyn
gullyn / breakout.html
Last active Jun 5, 2021
Breakout in 360 bytes
View breakout.html
<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>
View render.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<canvas></canvas>
<script>
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
View analyze.py
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")
View analyze.py
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:
View breakdown.txt
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
View results.txt
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 Jan 17, 2021
Wikipedia page lengths
View lengths.py
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 Aug 9, 2022
Flappy bird in 205 bytes (improved!)
View flappy.html
<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>