Skip to content

Instantly share code, notes, and snippets.

@TylerLeite
TylerLeite / merge-sort.hs
Created December 8, 2021 04:29
haskell merge sort
arr = [x*97 `mod` 61 - 30 | x <- [1..20]]
-- expecting rhs and lhs to be sorted
merge :: Ord a => [a] -> [a] -> [a] -> [a]
merge lhs rhs sorted =
if length lhs == 0 && length rhs == 0 then
sorted
else if length lhs == 0 || (length rhs > 0) && head rhs < head lhs then
merge (tail rhs) lhs (sorted ++ [head rhs])
else
execute pathogen#infect()
syntax on
filetype plugin on
set clipboard=unnamed
set mouse=a
noremap <Up> <NOP>
noremap <Down> <NOP>
@TylerLeite
TylerLeite / gravity.html
Last active November 4, 2020 18:17
Gravity
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>moonshot</title>
<style>
* {padding: 0; margin: 0; outline: 0;}
body {display: flex; align-items: center; justify-content: center; margin-top: 5vh}
canvas {width: 800px; height: 800px;}
@TylerLeite
TylerLeite / randorune.py
Created July 28, 2020 23:54
randomly generate a rune
from enum import Enum
from math import floor, sin, cos, pi
import random as r
from uuid import uuid4
import cairo
class Rune:
top = ['angstrom', 'antennae', 'docstring', 'swinton']
shape = ['shape_'+a for a in ['circle', 'boob', 'penis', 'yinyang', 'triangup', 'deniro', 'triangdown', 'beatrice', 'grimace', 'box', 'domino', 'teeth', 'panini', 'fermata']]
@TylerLeite
TylerLeite / rent_improved.js
Created July 22, 2020 22:44
rent 2.0: now featuring comments!
// Enter data here:
const total_rent = 0;
// A measure of the relative quality between different rooms in the same type.
// Probably will just go with area for these, but if theres like e.g. a really
// shitty bathroom no one wants to use, it might make sense to lower its quality
// NOTE: quality of two different types (e.g. a bedroom and bathroom) have nothing
// to do with each other and will never be compared. Because of this, rooms
// that are one-of-a-type can have their quality left null
const room_qualities = {
@TylerLeite
TylerLeite / complex_matrix.py
Created July 21, 2020 05:13
complex numbers, vectors, matrices
import random
from math import sin, cos, atan2, acos
from math import pi as π, e
class ComplexRect:
def __init__(self, j, i=0):
self.a = j
self.b = i
@TylerLeite
TylerLeite / explosion.html
Last active July 29, 2020 00:50
generate a bunch of rooms and separate them. then repeat
<html>
<head>
<style>*{margin: 0; padding: 0;}</style>
<script type="text/javascript" src="./explosion.js"></script>
</head>
<body onload="main();">
<canvas id="canvas" style="width:100vw;height:100vh"></canvas>
</body>
@TylerLeite
TylerLeite / skribblio.py
Created March 5, 2020 03:44
convert a file to another file
out = []
with open('text/skriblio', 'r') as file:
for line in file:
if '@' in line:
continue
word = line.strip()
if len(word) > 0:
out.append(word)
@TylerLeite
TylerLeite / symm.js
Last active February 6, 2020 23:48
evolve symmetrical art
const fs = require('fs');
const PNG = require('pngjs').PNG;
W = 256;
H = 256;
AB = '0123456789';
PSIZE = 128;
GENS = 300;
function choice (arr) {
@TylerLeite
TylerLeite / cells.js
Created December 3, 2019 23:06
cells_1
tiles = '*-+=o8|:x '.split('')
// tiles = ' #.'.split('')
function newWorld () {
world = []
for (let i = 0; i < 23; i++) {
world.push([])
for (let j = 0; j < 80; j++) {
// world[i].push(' ')