Skip to content

Instantly share code, notes, and snippets.

View apacheli's full-sized avatar
📝
Looking for commissions!

apacheli

📝
Looking for commissions!
View GitHub Profile
@apacheli
apacheli / hi.mjs
Last active August 20, 2023 10:16
function hi() {
console.log("hi")
}
@apacheli
apacheli / speed.js
Last active July 22, 2023 23:45
SPD (speed) determines who goes first, and the amount of actions that can be made in a turn. Here, the example uses two speeds: [125, 100]. The higher the value the faster. 125 can make 2 actions on every 4th turn, or 1.25 actions every turn to put it simply.
function actions_per_turn(speeds, turns) {
const arr = [];
const slowest_speed = Math.min(...speeds);
for (const speed of speeds) {
const speed_arr = [];
let remainder = 0;
for (let i = 0; i < turns; i++) {
const value = speed / slowest_speed + remainder;
const floored = Math.floor(value);
speed_arr.push(floored);
@apacheli
apacheli / damage_reduction.js
Last active July 22, 2023 23:55
DMG (damage) reduction refers to the amount of DMG that can be reduced relative to the target's max HP. Here in this example, the targeting is receiving 100 DMG. The target can reduce 25% of that damage. However, if that 25% of DMG is higher than 30% of the target's max HP (as indicated by damage_reduction_limit), it will max at that amount. The…
const damage = 100;
const hp = 15_000;
const damage_reduction = .25;
const damage_reduction_limit = hp * .3;
const damage_reduced = Math.min(damage * damage_reduction, damage_reduction_limit);
const incoming_damage = Math.max(1, damage - damage_reduced);
export interface Field {
contentType?: string;
filename?: string;
name: string;
value: string | Uint8Array;
}
export const boundary = Math.random().toString(16).substring(2);
export async function* fileIterator(fields: Field[]) {
import { randomBytes } from "node:crypto";
import { request as httpRequest } from "node:http";
import { request as httpsRequest } from "node:https";
const DEFAULT_PORT = 443;
const SEC_WEBSOCKET_VERSION = 13;
class WebSocket extends EventTarget {
constructor(url, protocols) {
super();
const APPDATA = Deno.env.get("APPDATA");
const index = await Deno.readTextFile(
`${APPDATA}/.minecraft/assets/indexes/1.19.json`,
);
const json = JSON.parse(index);
const directories = {};
const promises1 = [];
const APPDATA = Deno.env.get("APPDATA");
const VERSION = 2;
while (true) {
const input = prompt("Search for a mod:");
if (input === null) {
continue;
}
console.log("Searching...");
@apacheli
apacheli / git instructions
Created April 26, 2022 03:53
because apparently i'm too dumb and i forget
echo "# gerdjt" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M master
git remote add origin https://github.com/apacheli/gerdjt.git
git push -u origin master
@apacheli
apacheli / generate.py
Created March 15, 2022 01:29
mdbook_emoji.py
import aiohttp
import asyncio
import os
async def main():
async with aiohttp.ClientSession() as session:
headers = {
"accept": "application/vnd.github.v3+json"
}
async with session.request("GET", "https://api.github.com/emojis", headers=headers) as response:
from datetime import datetime
MS_TO_DAYS = 8.64e+7
DISCORD_EPOCH = 1420070400000
FIRST_RAID = 1606866300000
total_bans = int(input("total bans: "))
total_raids = int(input("total raids: "))
first_case = int(input("first case: "))
first_case_url = input("first case url: ")