This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"time" | |
) | |
// Board is a set of points that are 'alive' | |
type Board map[Point]bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import argparse | |
def get_key(length: int = 8) -> str: | |
b62_alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$+" | |
key = random.choices(b62_alphabet, k=length) | |
return ''.join(key) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"image" | |
"image/color" | |
"image/draw" | |
"image/jpeg" | |
"math/rand" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"math" | |
"github.com/faiface/pixel" | |
"github.com/faiface/pixel/pixelgl" | |
) | |
// An interal type to store 2 related numbers, a low and high bound. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cameraOrigin := pixel.ZV.Add(win.Bounds().Center()) | |
scale := 1.0 | |
dragOrigin := pixel.V(0, 0) | |
second := time.Tick(time.Second) | |
viewMatrix := pixel.IM | |
frames := 0 | |
for !win.Closed() { | |
if win.MouseScroll().Y != 0 { | |
factor := math.Pow(1.2, win.MouseScroll().Y) | |
zoomDeltaStart := viewMatrix.Unproject(win.MousePosition()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/fish | |
#============== | |
# This is a fish shell script to download archived mp3 files of shows | |
# from the radio station XRAY (krxy). | |
#============== | |
# get show numbers given show title (in url style) | |
# curl -s https://xray.fm/shows/home-of-space-paranoid | grep -Poe '(?<=title"\>\<a href="\/broadcasts\/)\d*?(?=")' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// port of C source: http://www.pcg-random.org/download.html | |
type PCG32 struct { | |
state, seq uint64 | |
} | |
func NewPCG32(stateSeed, seq uint64) *PCG32 { | |
return &PCG32{ | |
state: stateSeed, | |
inc: seq } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package main implements a simple http file server mainly for use in | |
// serving files locally when testing web apps. | |
package main | |
import ( | |
"flag" | |
"log" | |
"net/http" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// plotline draws a simple line on img from (x0,y0) to (x1,y1). | |
// | |
// This is basically a copy of a version of Bresenham's line algorithm | |
// from https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm. | |
func plotline(img draw.Image, c color.Color, x0, y0, x1, y1 int) { | |
dx := abs(x1 - x0) | |
sx := -1 | |
if x0 < x1 { | |
sx = 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package arena | |
// #include <malloc.h> | |
import "C" | |
import ( | |
"runtime" | |
"unsafe" | |
) | |
// Arena memory allocator gets a large chunk of memory from the system at once |