Skip to content

Instantly share code, notes, and snippets.

View bfu4's full-sized avatar
🌸

bfu4 bfu4

🌸
View GitHub Profile
@bfu4
bfu4 / TRUSTD.md
Last active November 24, 2020 08:01
some trustd thing

gist for trustdissues repository (more detailed! yay!)

a more detailed explanation of how this project even occurred.

repo: trustdissues

twitter and apple insider brought my attention to this. after most of my twitter feed was tweeting about how apple can see what you're opening, when you're opening it (supposedly), the first idea was: how can we prevent this?

the linked article above mentions how it won't send to the ocsp server unless you're connected to wifi. obviously, turning off the wifi every time you launch an app is just annoying. so the thought was - the daemons always running right? if there's not an if statement and it's trying to send information to that server, how can we change it to prevent it?

@bfu4
bfu4 / QuadReg.md
Last active December 8, 2020 19:10
[JAVA] Quadratic Regression - Solving for a parabola with 2 points

[JAVA] Quadratic Regression - Solving for a parabola with 2 points

A little bit about this: for the economy aspect of a plugin that I'm writing, I need to determine the price of something based on 1) the initial price and 2) a maximum price.

With this, if we create a parabola (and cut it off where x >= 0) with the axis of symmetry as 0 (x = 0), we can get this value. Since the parabola is dynamic based on the item needing to be charged, we have to create something to return the y of a point when given the x.

Our two points for testing were (0, 100) and (2500, 6000). Where 100 is base, 6000 is max, 2500 is maxLevel and point is the point we want to get. HOWEVER with the idea that this parabola starts at 0, a good idea is to treat this as

@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 {
@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 / 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 / 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 / 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 / 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 / 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;