Skip to content

Instantly share code, notes, and snippets.

View tatarize's full-sized avatar

tatarize

View GitHub Profile
@tatarize
tatarize / boys.txt
Last active July 12, 2023 22:31
Gist to create random children names
Liam
Noah
Oliver
James
Elijah
William
Henry
Lucas
Benjamin
Theodore
@tatarize
tatarize / 4-to-4.lean
Created May 6, 2023 10:57
4-to-4 matrix lean.
import tactic
def transform : ℚ × ℚ × ℚ × ℚ × ℚ × ℚ × ℚ × ℚ × ℚ → ℚ × ℚ → ℚ × ℚ
| (a, b, c, d, e, f, g, h, i) (x, y) := ((a * x + b * y + c) / (g * x + h * y + i), (d * x + e * y + f) / (g * x + h * y + i))
example (ax1 ay1 ax2 ay2 ax3 ay3 ax4 ay4 bx1 by1 bx2 by2 bx3 by3 bx4 by4 a b c d e f g h i : ℚ)
: transform (a, b, c, d, e, f, g, h, i)(ax1, ay1) = (bx1, by1)
∧ transform (a, b, c, d, e, f, g, h, i)(ax2, ay2) = (bx2, by2)
∧ transform (a, b, c, d, e, f, g, h, i)(ax3, ay3) = (bx3, by3)
@tatarize
tatarize / unitsquare.lean
Created May 5, 2023 22:36
Lean Code for the Unit Square transformation from points (x1,x1), (x2,y2), (x3,y3), (x4,y4) to (0,0), (0,1), (1,1), (1,0).
import tactic
def transform : ℚ × ℚ × ℚ × ℚ × ℚ × ℚ × ℚ × ℚ × ℚ → ℚ × ℚ → ℚ × ℚ
| (a, b, c, d, e, f, g, h, i) (x, y) := ((a * x + b * y + c) / (g * x + h * y + i), (d * x + e * y + f) / (g * x + h * y + i))
def xy : ℚ × ℚ := (0, 0)
def xy' : ℚ × ℚ := (0, 1)
def x'y' : ℚ × ℚ := (1, 1)
def x'y : ℚ × ℚ := (1, 0)
@tatarize
tatarize / affine.lean
Created May 4, 2023 08:52
LeanSolver code for creating an affine transformation matrix from 4 points.
import tactic
def transform : ℚ × ℚ × ℚ × ℚ × ℚ × ℚ → ℚ × ℚ → ℚ × ℚ
| (a, b, c, d, e, f) (x, y) := ((a * x + b * y + c) / (0 * x + 0 * y + 1), (d * x + e * y + f) / (0 * x + 0 * y + 1))
def xy : ℚ × ℚ := (0, 0)
def xy' : ℚ × ℚ := (0, 1)
def x'y' : ℚ × ℚ := (1, 1)
def x'y : ℚ × ℚ := (1, 0)
@tatarize
tatarize / readme.md
Last active April 10, 2023 21:17
Spreadsheet to Auto Entry

Spreadsheet to Auto Entry

This script should allow you to enter data in a custom ordering with special keypresses and allow some customization and development on-the-fly. Each line you will be prompted to give the desired ordering for the sendkeys, if you edit it. It will reflect this for the next attempt. When you have a working ordering for the keystrokes, you can rename the script file to that ordering name and it will be used as the default ordering.

The replacement variables $1 - $n are presented for each line.

Instructions

  1. Open the spreadsheet containing the data you want to enter into the program.
  2. Save the spreadsheet data in a Tab Delimited format.

Spreadsheet-to-Keystrokes Script

This script is designed to automate the process of inputting data from a spreadsheet into a program that only allows input one field at a time. By reading an exported file and simulating keystrokes, the script inputs each cell value into the corresponding field in the program.

The script is simple and easy to use, with no complicated setup or configuration required. All you need to do is prepare the data in a tab-delimited text file, open the order entry system, and drag and drop the file onto the script, then select the first field in the program. The script will wait three seconds then automatically input the data for you.

Prerequisites

We are assuming you are running Microsoft Windows with VBScript (it comes standard). If this is inaccurate, a python example is also provided.

Assumptions

We are assuming that you can press tab to move to the next field, and that pressing enter will move to the next line.

@tatarize
tatarize / point_in_polygon.py
Created January 2, 2023 03:15
Fast scanbeam point in polygon code
def build_edge_list(polygon):
edge_list = []
for i in range(0, len(polygon) - 1):
if (polygon[i].imag, polygon[i].real) < (polygon[i + 1].imag, polygon[i + 1].real):
edge_list.append((polygon[i], i))
edge_list.append((polygon[i + 1], ~i))
else:
edge_list.append((polygon[i], ~i))
edge_list.append((polygon[i + 1], i))
@tatarize
tatarize / calc_colors.py
Created February 13, 2022 20:18
Calculate color lists for various numbers of equidistant colors.
import math
from copy import deepcopy
from functools import lru_cache
from PIL import ImageDraw, Image
from random import Random
r = Random()
# Color conversion formula borrowed from:
@tatarize
tatarize / colorclusters.py
Last active February 14, 2022 15:29
Process color distances to find max color distances between all different colors.
import math
from copy import deepcopy
from functools import lru_cache
from PIL import ImageDraw, Image
# Color conversion formula borrowed from:
# http://www.easyrgb.com/index.php?X=MATH&H=02#text2
ref_X = 95.047 # ref_X = 95.047 Observer= 2°, Illuminant= D65
ref_Y = 100.000 # ref_Y = 100.000
@tatarize
tatarize / crash_demo.py
Created May 31, 2021 04:48
Crash Demo -- Load with Linux wx.Python 4.1.1 press the expand arrow for either Shapes or Selection. Segfault.
import wx.aui
import wx
import wx.ribbon as RB
ID_CIRCLE = wx.ID_HIGHEST + 1
ID_CROSS = ID_CIRCLE + 1
ID_TRIANGLE = ID_CIRCLE + 2
ID_SQUARE = ID_CIRCLE + 3
ID_POLYGON = ID_CIRCLE + 4
ID_SELECTION_EXPAND_H = ID_CIRCLE + 5