initial commit

This commit is contained in:
dogeystamp 2024-01-29 16:35:02 -05:00
commit c4e57b3b94
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
9 changed files with 402 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# garbage-monorepo
a dump of all the actually useless scripts, code, and other toys, put into one repo

4
loader/README.md Normal file
View File

@ -0,0 +1,4 @@
# loader
whiptail toy.
loading bar that does weird things

1
loader/loader.sh Executable file
View File

@ -0,0 +1 @@
echo "ZXhwb3J0IFRFUk09YW5zaQp7Cglmb3IgaSBpbiAkKHNlcSAxIDUgMTAwKTsgZG8KCQlmb3IgaiBpbiAkKHNlcSAkKCgyMCAmICRpKSkpOyBkbwoJCQllY2hvICQoKCAkaSArICRqICkpCgkJCWZvciBrIGluICQoc2VxICRqKTsgZG8KCQkJCXNsZWVwIDAuMDEKCQkJZG9uZQoJCWRvbmUKCQlmb3IgaiBpbiAkKHNlcSAkKCgyMCAmICRpKSkpOyBkbwoJCQlzbGVlcCAwLjIKCQlkb25lCglkb25lCn0gfCB3aGlwdGFpbCAtLWdhdWdlICJsb2FkaW5nIiA2IDUwIDAKCndoaXB0YWlsIC0tbXNnYm94ICIkKGNhdCA8PCAnRU9GJwogICAgICAgICAgXyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXyAgICAgXyAgIF8gICAgICAgICAgCl9fICAgICAgX3wgfF9fICAgX19fIF8gX18gICAgXyAgIF8gIF9fXyAgXyAgIF8gICAgX18gX3wgfF8gIHwgfF98IHxfXyAgIF9fXyAKXCBcIC9cIC8gLyAnXyBcIC8gXyBcICdfIFwgIHwgfCB8IHwvIF8gXHwgfCB8IHwgIC8gX2AgfCBfX3wgfCBfX3wgJ18gXCAvIF8gXAogXCBWICBWIC98IHwgfCB8ICBfXy8gfCB8IHwgfCB8X3wgfCAoXykgfCB8X3wgfCB8IChffCB8IHxfICB8IHxffCB8IHwgfCAgX18vCiAgXF8vXF8vIHxffCB8X3xcX19ffF98IHxffCAgXF9fLCB8XF9fXy8gXF9fLF98ICBcX18sX3xcX198ICBcX198X3wgfF98XF9fX3wKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8X19fLyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgXyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCl9fICAgICAgX3wgfF9fICAgX19fIF8gX18gICAgXyAgIF8gIF9fXyAgXyAgIF8gICBfICAgXyAgX19fICBfICAgXyAKXCBcIC9cIC8gLyAnXyBcIC8gXyBcICdfIFwgIHwgfCB8IHwvIF8gXHwgfCB8IHwgfCB8IHwgfC8gXyBcfCB8IHwgfAogXCBWICBWIC98IHwgfCB8ICBfXy8gfCB8IHwgfCB8X3wgfCAoXykgfCB8X3wgfCB8IHxffCB8IChfKSB8IHxffCB8CiAgXF8vXF8vIHxffCB8X3xcX19ffF98IHxffCAgXF9fLCB8XF9fXy8gXF9fLF98ICBcX18sIHxcX19fLyBcX18sX3wKICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8X19fLyAgICAgICAgICAgICAgIHxfX18vICAgICAgICAgICAgIApFT0YKKSIgNDAgODAK" | base64 -d | sh

View File

@ -0,0 +1,5 @@
# make-linux-fast
a shell script webserver inspired by [this](https://news.ycombinator.com/item?id=22830330).
the premise is that if you automatically curl'ed this into your grub config (with grub-mkconfig),
it might set your init to reboot and bootloop your system

View File

@ -0,0 +1,23 @@
#!/bin/sh
while true
do
RAND="$(seq 5 | shuf | head -n 1)"
RET=""
if [ "$RAND" = "1" ]
then
RET='init=/usr/sbin/reboot'
else
RET='noibrs noibpb nopti nospectre_v2 nospectre_v1 l1tf=off nospec_store_bypass_disable no_stf_barrier mds=off tsx=on tsx_async_abort=off mitigations=off'
fi
LEN=$(printf "$RET" | wc -c)
HEADERS="HTTP/1.0 200 OK\r\nContent-Length: $LEN\r\n\r\n"
RESP="$HEADERS$RET\r\n"
printf "$RESP" \
| nc -l -p 8080
done

9
pongwars/README.md Normal file
View File

@ -0,0 +1,9 @@
# pongwars
code taken from https://codyebberson.github.io/pong-wars/
includes more colors, and the ability for a color to win.
optionally (look in the code for the commented line), enable sudden death mode after a few minutes.
also, pressing the number keys will control the individual balls.
relevant hacker news thread (original): https://news.ycombinator.com/item?id=39159418

341
pongwars/index.html Normal file
View File

@ -0,0 +1,341 @@
<!DOCTYPE html>
<html>
<head>
<title>Pong wars | Koen van Gilst</title>
<link rel="canonical" href="https://pong-wars.koenvangilst.nl/" />
<style>
html {
height: 100%;
}
body {
height: 100%;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(to bottom, #172b36 0%, #d9e8e3 100%);
}
#container {
display: flex;
width: 100%;
max-width: 750px;
align-items: center;
flex-direction: column;
height: 100%;
}
#pongCanvas {
display: block;
border-radius: 4px;
overflow: hidden;
width: 100%;
margin-top: auto;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}
#score {
font-family: monospace;
margin-top: 30px;
font-size: 20px;
padding-left: 20px;
color: #172b36;
}
#made {
font-family: monospace;
margin-top: auto;
margin-bottom: 20px;
font-size: 12px;
padding-left: 20px;
}
#made a {
color: #172b36;
}
</style>
</head>
<body>
<div id="container">
<canvas id="pongCanvas" width="800" height="800"></canvas>
<div id="score"></div>
<p id="made">
made by <a href="https://koenvangilst.nl">Koen van Gilst</a> | source on
<a href="https://github.com/vnglst/pong-wars">github</a>
</p>
</div>
</body>
<script>
// Based on: https://github.com/vnglst/pong-wars
// Idea for Pong wars: https://twitter.com/nicolasdnl/status/1749715070928433161
const canvas = document.getElementById("pongCanvas");
const ctx = canvas.getContext("2d");
const scoreElement = document.getElementById("score");
const startTime = new Date();
var suddenDeathCoeff = 0;
const teams = [
{
name: "red",
color: "#ff5555",
backgroundColor: "#aa0000",
x: 256,
y: 256,
dx: 8,
dy: 8,
score: 0,
},
{
name: "blue",
color: "#5555ff",
backgroundColor: "#0000aa",
x: 768,
y: 256,
dx: -8,
dy: 8,
score: 0,
},
{
name: "green",
color: "#a7f070",
backgroundColor: "#00aa00",
x: 256,
y: 768,
dx: 8,
dy: -8,
score: 0,
},
{
name: "yellow",
color: "#ffff55",
backgroundColor: "#aa5500",
x: 768,
y: 768,
dx: -8,
dy: -8,
score: 0,
},
{
name: "white",
color: "#ffffff",
backgroundColor: "#aaaaaa",
x: 400,
y: 768,
dx: -9,
dy: -9,
score: 0,
},
{
name: "black",
color: "#333333",
backgroundColor: "#000000",
x: 400,
y: 300,
dx: -8,
dy: -8,
score: 0,
},
{
name: "ourple",
color: "#dd33dd",
backgroundColor: "#aa00aa",
x: 400,
y: 768,
dx: -8,
dy: -8,
score: 0,
},
{
name: "gray",
color: "#dddddd",
backgroundColor: "#333333",
x: 400,
y: 768,
dx: -8,
dy: -8,
score: 0,
},
];
var state = teams.map((team) => ({
elim: false,
boost: 1,
boostEnabled: false,
}))
const squareSize = 16;
const numSquaresX = canvas.width / squareSize;
const numSquaresY = canvas.height / squareSize;
let squares = [];
document.addEventListener("keydown", (event) => {
const key = parseInt(event.key)
if (isNaN(key)) return
state[key].boostEnabled = true;
})
document.addEventListener("keyup", (event) => {
const key = parseInt(event.key)
if (isNaN(key)) return
state[key].boostEnabled = false;
})
for (let i = 0; i < numSquaresX; i++) {
squares[i] = [];
const t = randInt(0, teams.length-1);
for (let j = 0; j < numSquaresY; j++) {
squares[i][j] = t;
}
}
function randomNum(min, max) {
return Math.random() * (max - min) + min;
}
function randInt(min, max) {
return Math.floor(randomNum(min, max+1))
}
function elapsedSec() {
return ((new Date()) - startTime)/1000
}
updateScoreElement();
function drawBall(x, y, color) {
ctx.beginPath();
ctx.arc(x, y, squareSize / 2, 0, Math.PI * 2, false);
ctx.fillStyle = color;
ctx.fill();
ctx.closePath();
}
function drawSquares() {
for (let i = 0; i < numSquaresX; i++) {
for (let j = 0; j < numSquaresY; j++) {
ctx.fillStyle = teams[squares[i][j]].backgroundColor;
ctx.fillRect(i * squareSize, j * squareSize, squareSize, squareSize);
}
}
}
function clamp(min, max, num) {
return Math.min(max, Math.max(min, num))
}
function mix(x, y, v) {
return v*x + (1-v)*y;
}
function updateSquareAndBounce(x, y, dx, dy, color) {
if (state[color].elim) return
if (Math.max(Math.abs(dx), Math.abs(dy)) < 0.02) state[color].elim = true
let updatedDx = dx;
let updatedDy = dy;
// Check multiple points around the ball's circumference
for (let angle = 0; angle < Math.PI * 2; angle += Math.PI / 4) {
let checkX = x + Math.cos(angle) * (squareSize / 2);
let checkY = y + Math.sin(angle) * (squareSize / 2);
let i = Math.floor(checkX / squareSize);
let j = Math.floor(checkY / squareSize);
if (i >= 0 && i < numSquaresX && j >= 0 && j < numSquaresY) {
if (squares[i][j] !== color) {
squares[i][j] = color;
// Determine bounce direction based on the angle
if (Math.abs(Math.cos(angle)) > Math.abs(Math.sin(angle))) {
updatedDx = -updatedDx;
} else {
updatedDy = -updatedDy;
}
updatedDx += randomNum(-0.15, mix(0.153, 0.15, suddenDeathCoeff));
updatedDy += randomNum(-0.15, 0.15);
const nTeams = state.map(t => !t.elim).filter(Boolean).length
const coeff = Math.min((teams[color].score/(squares.length**2/nTeams/mix(1.2, 4, suddenDeathCoeff))), 1.00);
updatedDx *= coeff;
updatedDy *= coeff;
const speedLim = mix(100, 18, suddenDeathCoeff)
updatedDx = clamp(-speedLim, speedLim, updatedDx);
updatedDy = clamp(-speedLim, speedLim, updatedDy);
}
}
}
const theta = (Math.PI/180)*10;
const ct = Math.cos(theta);
const st = Math.sin(theta);
if (state[color].boostEnabled) {
updatedDx = (ct * updatedDx - st * updatedDy)*1.01
updatedDy = (st * updatedDx + ct * updatedDy)*1.01
}
return { dx: updatedDx, dy: updatedDy };
}
function updateScoreElement() {
if (!squares) {
return;
}
teams.forEach((t) => (t.score = 0));
for (let i = 0; i < numSquaresX; i++) {
for (let j = 0; j < numSquaresY; j++) {
teams[squares[i][j]].score++;
}
}
for (let i = 0; i < teams.length; i++) {
if (teams[i].score <= 4) {
state[i].elim = true
}
}
scoreElement.textContent = teams
.map((t) => `${t.name} ${t.score}`)
.join(" | ") + (suddenDeathCoeff > 0.1 ? " | sudden death!" : "");
}
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
drawSquares();
for (let i = 0; i < teams.length; i++) {
if (state[i].elim) continue
const t = teams[i];
drawBall(t.x, t.y, t.color);
let bounce = updateSquareAndBounce(t.x, t.y, t.dx, t.dy, i);
t.dx = bounce.dx;
t.dy = bounce.dy;
if (
t.x + t.dx > canvas.width - squareSize / 2 ||
t.x + t.dx < squareSize / 2
) {
t.dx = -t.dx;
}
if (
t.y + t.dy > canvas.height - squareSize / 2 ||
t.y + t.dy < squareSize / 2
) {
t.dy = -t.dy;
}
t.x += t.dx;
t.y += t.dy;
}
updateScoreElement();
// suddenDeathCoeff = Math.min((elapsedSec()/60/3)**15, 1);
requestAnimationFrame(draw);
}
requestAnimationFrame(draw);
</script>
</html>

View File

@ -0,0 +1,3 @@
# square validator
find examples for an erroneous method for doing square/cube/... roots of numbers

View File

@ -0,0 +1,13 @@
# self-explanatory by looking at the output
def digs(x: int) -> list[int]:
return [int(i) for i in str(x)]
def outp(x: int, exp: int) -> None:
pw: int = x**exp
print(f"{exp}{pw}: {' + '.join(str(pw))} = {(s := sum(digs(pw)))}\n\t{s} - {exp} = {x}\n")
for exp in range(1, 10):
gen = (i for i in range(10000) if sum(digs(i**exp)) - exp == i)
for x in gen:
outp(x, exp)