Skip to content

Instantly share code, notes, and snippets.

View hiimjustin000's full-sized avatar

Justin hiimjustin000

View GitHub Profile
private string GetDiskSpace()
{
try
{
string diskName = FolderSelect.SelectedPath.Split(char.Parse("\\"))[0];
DriveInfo disk = Array.Find(DriveInfo.GetDrives(), (DriveInfo x) => x.Name.StartsWith(diskName));
decimal bytes = disk.AvailableFreeSpace;
decimal kilobytes = Math.Floor(bytes / 1024);
decimal megabytes = Math.Floor(kilobytes / 1024);
const fs = require("fs");
const path = require("path");
const filePath = path.resolve(process.cwd(), process.argv.slice(2).join(" "));
const file = fs.readFileSync(filePath);
const originalFile = Buffer.from(file);
if (file.subarray(0, 2).toString() != "MZ") {
console.error("Not a valid executable!");
process.exit(1);
}
const fs = require("fs");
const path = require("path");
const input = fs.readFileSync(path.resolve(__dirname, "input.txt"), "utf8").split("\n\n").map(x => x.split("\n"));
const workflows = {};
const parts = input[1].map(x => ({ ...JSON.parse(x.replace("{", "{\"").replace(/=/g, "\":").replace(/,/g, ",\"")), accepted: false }));
let result = 0;
for (const line of input[0]) {
const [workflow, funcs] = line.slice(0, -1).split("{").map((x, i) => i == 1 ? x.split(",") : x);
let functionString = "";
[
["2398Q", 426],
["23A84", 32],
["24A86", 882],
["25T37", 971],
["28693", 714],
["2T6K7", 920],
["2TAK5", 963],
["2Q573", 916],
["2Q5T7", 626],
const fs = require("fs");
const path = require("path");
const input = fs.readFileSync(path.resolve(__dirname, "day7.txt"), "utf8").split("\n").map(x => x.split(" ")).map(x => [x[0], parseInt(x[1])]);
const cardMap = {
J: 1,
2: 2,
3: 3,
4: 4,
5: 5,
package com.hiimjustin000.colorblocks.packets;
import com.hiimjustin000.colorblocks.entities.AlternatingColorBlockEntity;
import com.hiimjustin000.colorblocks.registries.BlockEntityTypeRegistry;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth;
[17:39:01] [Server thread/ERROR] [minecraft/PacketUtils]: Failed to handle packet net.minecraft.network.protocol.game.ServerboundUseItemOnPacket@301b74c1, suppressing error
java.lang.RuntimeException: VarInt too big
at net.minecraft.network.FriendlyByteBuf.readVarInt(FriendlyByteBuf.java:530) ~[forge-1.19.4-45.1.0_mapped_official_1.19.4-recomp.jar%23189!/:?] {re:classloading}
at net.minecraft.network.FriendlyByteBuf.readById(FriendlyByteBuf.java:178) ~[forge-1.19.4-45.1.0_mapped_official_1.19.4-recomp.jar%23189!/:?] {re:classloading}
at net.minecraft.network.FriendlyByteBuf.readItem(FriendlyByteBuf.java:656) ~[forge-1.19.4-45.1.0_mapped_official_1.19.4-recomp.jar%23189!/:?] {re:classloading}
at com.hiimjustin000.colorblocks.menus.ChangeColorMenu.<init>(ChangeColorMenu.java:24) ~[%23194!/:?] {re:classloading}
at com.hiimjustin000.colorblocks.blocks.ColorBlock.lambda$getMenuProvider$1(ColorBlock.java:50) ~[%23194!/:?] {re:classloading}
at net.minecraft.world.SimpleMenuProvider.createMenu(SimpleMenuProvide
java.lang.NullPointerException: Cannot invoke "net.minecraft.client.resources.model.AtlasSet$AtlasEntry.atlas()" because the return value of "java.util.Map.get(Object)" is null
at net.minecraft.client.resources.model.AtlasSet.getAtlas(AtlasSet.java:28) ~[forge-1.20.1-47.0.4_mapped_official_1.20.1-recomp.jar:?]
at net.minecraft.client.resources.model.ModelManager.getAtlas(ModelManager.java:232) ~[forge-1.20.1-47.0.4_mapped_official_1.20.1-recomp.jar:?]
at net.minecraft.client.Minecraft.getTextureAtlas(Minecraft.java:2478) ~[forge-1.20.1-47.0.4_mapped_official_1.20.1-recomp.jar:?]
at net.minecraft.client.resources.model.Material.sprite(Material.java:38) ~[forge-1.20.1-47.0.4_mapped_official_1.20.1-recomp.jar:?]
at net.minecraft.client.resources.model.Material.buffer(Material.java:49) ~[forge-1.20.1-47.0.4_mapped_official_1.20.1-recomp.jar:?]
at com.hiimjustin000.advancedbanners.client.renderer.AdvancedBannerRenderer.lambda$renderPatterns$1(AdvancedBannerRenderer.java:119) ~[main/:?]
at java.util.Optional
"use strict";
function module(code, x, y) {
const rows = code.length;
const columns = code[0].length;
if (y < 0) {
y += rows;
x += 4 - ((rows + 4) & 7);
}
if (x < 0) {
x += columns;
@hiimjustin000
hiimjustin000 / reed-solomon-codec.js
Created May 12, 2023 00:33
Universal Reed-Solomon codec ported from Python to JavaScript
"use strict";
// Originally by Signimu, ported by hiimjustin000
// https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders
let gf_exp = Array(512).fill(0);
let gf_log = Array(256).fill(0);
let field_charac = 255;
function rwh_primes1(n) {
const sieve = Array(n / 2).fill(true);
for (let i = 3; i * i <= n; i += 2) {