Skip to content

Instantly share code, notes, and snippets.

@jocopa3
jocopa3 / BooleanMagic.java
Created February 17, 2022 06:27
Inspired by similar magic tricks to make 2+2=5 through messing with IntegerCache, I present two more devious tricks to make booleans behave in unexpected ways.
import sun.misc.Unsafe;
import java.lang.reflect.Field;
public class BooleanMagic {
private static void doImpossibleBool() {
boolean impossible = ImpossibleBool.IMPOSSIBLE_BOOL;
if (impossible == true) {
System.out.println("Value was true");
} else if (impossible == false) {
@jocopa3
jocopa3 / Discord ANSI Chart Copy-Paste
Created January 31, 2022 18:47
List of the supported ANSI escape codes in Discord as well as some examples
```ansi
 Discord ANSI Chart 
Escape Char: \u001B, aka: 
Format : ESC[1;31;40mBold Red Text on TealESC[0m
Example : Bold Red Text on Teal
Code │ Regular: 0 │ Bold: 1 │ Underline: 4
─────┼────────────┼────────────┼─────────────
30 │ Gray  │ Gray  │ Gray 
@jocopa3
jocopa3 / CalculatorGameSolver.java
Last active December 25, 2023 08:10
A complete solver for "Calculator: The Game"
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;
public class CalculatorGameSolver {
// Given a single action input (e.x. "1=>5"), returns the appropriate action for that input
public static Action parseAction(String input) {
if (input.matches("\\d+")) {
// e.x.: 12
# [PackageDev] target_format: plist, ext: tmLanguage
name: Minecraft Addon
scopeName: source.mcaddon
fileTypes: []
uuid: a0c7e4ae-079d-4d09-9b1d-5379c586f67a
patterns:
- include: '#value'
repository:
@jocopa3
jocopa3 / client-only-test.json
Last active December 10, 2019 23:09
Debug command files from 0.15.90.0
{
"aigoals": {
"versions": [
{
"description": "Enables | Disables Drawing AI Goals",
"permission": "any",
"overloads": {
"default": {
"input": {
@jocopa3
jocopa3 / PaletteArray.java
Last active March 17, 2017 00:14
Compresses arrays of a few repeating random values using a variation on Palette Mapping.
/*
* I release this code into the public domain.
*/
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
@jocopa3
jocopa3 / client-only.json
Created March 6, 2017 00:05
Command files from MCPE/Win10 1.0.3
{
"closewebsocket": {
"versions": [
{
"description": "commands.closewebsocket.description",
"permission": "any",
"is_hidden": true,
"overloads": {
"default": {
@jocopa3
jocopa3 / JScriptAnalyzer.html
Last active March 2, 2017 01:00
Rudimentary webpage which can help deobfuscate malicious JScript files. It reports the URLS accessed, Files accessed, and ActiveX API calls made.
<html><head>
<script type="text/javascript">
var URLSRequested = [];
var FilesAccessed = [];
var APICalls = [];
// If true, the analyzer displays an alert box whenever the script calls WScript.echo
// If false, the analyzer prints the echo message to console
var AlertEchos = false;
@jocopa3
jocopa3 / ChatListener.java
Created February 20, 2017 01:04
Example of a global chat room listener for Minecraft using the PEWS API
/*
* This is a basic example of a global chatroom for Minecraft PE/Win10 made
* using the Pocket Edition WebSocket API.
*/
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.Collection;
{
"body": {
"input": {
"message": "Hello World"
},
"origin": {
"type": "player"
},
"name": "say",
"version": 1,