Skip to content

Instantly share code, notes, and snippets.

View bfu4's full-sized avatar
🌸

bfu4 bfu4

🌸
View GitHub Profile
@bfu4
bfu4 / print.py
Created May 15, 2021 07:24
micropython example
# ==== PSEUDO translation for micropython
# ==== GIVEN:
print("hi")
# `dis` interprets this as
"""
2 0 LOAD_NAME 0 (print)
2 LOAD_CONST 0 ('hi')
@bfu4
bfu4 / fix_smaller_int_size_cast.patch
Created April 4, 2021 19:26
really fucking stupid patch to get jdk17-internal to compile on m1
diff --git a/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c b/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c
index b139020c7b2..7f561db3bca 100644
--- a/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c
+++ b/src/java.desktop/macosx/native/libjsound/PLATFORM_API_MacOSX_MidiUtils.c
@@ -255,9 +255,9 @@ INT32 MIDI_Utils_GetDeviceVersion(int direction, INT32 deviceID, char *name, UIN
}
-static MIDIClientRef client = (MIDIClientRef) NULL;
-static MIDIPortRef inPort = (MIDIPortRef) NULL;
@bfu4
bfu4 / modding_spigot.md
Last active May 13, 2021 16:26
Basis of Spigot Modding POC

Turning Spigot into Forge

A concept, that is seemingly not too far from reality.

Abstract

Plugin development is modding, though not really considered modding by a lot of Minecraft Forge developers. That is fine. I'm very well aware that Spigot development as well as plugin development is probably a joke, and it's probably not impressive unless you're modifying the server(.jar). The deeper you get into plugin development, the more you learn from it -- including being able to do more than you would normally be able to with the Spigot API, using NMS (net.minecraft.server).

Ideologically, most people want to work through an API anyways. When you want to access NMS in its true, "raw" self,

@bfu4
bfu4 / PlayerJoinListener.java
Created March 16, 2021 02:11
force bukkit to render all maps by id on player join (fuck you)
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_16_R3.map.CraftMapView;
import org.bukkit.craftbukkit.v1_16_R3.map.RenderData;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@bfu4
bfu4 / Main.java
Last active February 8, 2021 15:49
JNI-1 (Debian/CrOS)
public class Main {
public static void main(String[] args) {
NativeImpl impl = new NativeImpl();
// print the added numbers: expected = 5
System.out.println(impl.add(1, 4));
// jstring object
impl.print("meow");
}
@bfu4
bfu4 / syscall.h
Created January 25, 2021 23:16
mac syscall list >.<
/*
* Copyright (c) 2004-2008 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
@bfu4
bfu4 / routing.md
Last active January 30, 2021 04:07
how i fought vue-router with the help of 10 blog posts.

routing.md

at this point, i've made github gist my archive of shitty solutions, haven't i?

Okay, seriously, I have no idea why or HOW it was so hard for me to get a decent routing system working in vue 2.0, but I did - and to be quite honest, I'm only dropping this here so that I can find it again in like .. a week.

Behold!

This is the shitshow of a router design I put together, using more posts than I can name, but I'll drop the most helpful.

@bfu4
bfu4 / Hmmm.md
Last active February 11, 2021 01:16
creating a list with a limited size..

LimitedList.java

Creating a custom list object restricted by a defined maximum size

What the hell ?

I needed a list that I could limit, without the weight of a List<?> or its children. We can do this efficiently with arrays! Playing with generics and arrays, we get some cool shit.

We synchronize stuff, because god forbid we're not threadsafe or whatever.

@bfu4
bfu4 / Implementation.md
Last active December 27, 2020 09:26
Implementing Prison (core) in your plugin

PrisonHook - a utility class to make hooking into Prison easier

Credit goes to PrisonTeam for their code I stole for isLocationInsideAMine(Location l) as well as for supplying their plugin

Basically, I stumbled upon this issue where I had to deal with mines involving this core. Obviously, I tried everything to work around it, with minimal luck. So the solution was to build with PrisonCore as a dependency, and use their objects.

Prison supplies a PrisonSpigotAPI, which is a bit useful. In the file PrisonHook.java, you can see how I use it. We steal from the core's class MinesCommand.java, and use a slightly modified version of the iterations in the mines whereami command.

@bfu4
bfu4 / Case.java
Created December 18, 2020 05:23
[JAVA] Switch statement using objects
package main.java.Switch;
/**
* Functional interface which we use to create a lambda and invoke doSomething();
*
* @author bfu4
*/
@FunctionalInterface
public interface Case {