Skip to content

Instantly share code, notes, and snippets.

View JoshuaJB's full-sized avatar

Joshua Bakita JoshuaJB

View GitHub Profile
@JoshuaJB
JoshuaJB / disable-username-validation-craftbukkit-spigot.patch
Last active July 6, 2022 22:42
Fix `Internal Exception: java.lang.IllegalStateException: Invalid characters in username` on offline servers with Spigot 1.19.
index 2db69f9d..2d0dd14c 100644
--- a/CraftBukkit-Patches/0030-Fire-PreLogin-Events-in-Offline-Mode.patch
+++ b/CraftBukkit-Patches/0030-Fire-PreLogin-Events-in-Offline-Mode.patch
@@ -55,6 +55,19 @@ index dbf5769bc..a780e30d3 100644
}
}
+@@ -235,9 +262,9 @@ public class LoginListener implements PacketLoginInListener {
+ }
+
@JoshuaJB
JoshuaJB / update_papermc.sh
Created July 6, 2022 22:36
Display and download the latest build of the latest stable version of PaperMC. Simple, easy updater for any PaperMC-using server.
#!/bin/sh
# This script downloads the latest build of the latest version of PaperMC
if [ $# -eq 1 ]; then
latest_v=$1
else
latest_v=$(curl -sX GET "https://api.papermc.io/v2/projects/paper" | jq -r ".versions[-1]")
fi
# Lastest build of any sort
@JoshuaJB
JoshuaJB / gen_graphs_full.py
Created March 31, 2020 19:32
Full graph generation code for Sims, Bakita, and Anderson, ECRTS 2019
#!/usr/bin/python3
import matplotlib.pyplot as plt
import numpy
def read_sample(file):
"""Lazy function (generator) to read a file piece by piece.
Default chunk size: 1k."""
while True:
line = file.readline()
if line == b"*****\n":
@JoshuaJB
JoshuaJB / main.c
Created June 3, 2015 20:29
Pebble Accelerometer Variance Demo Scaffold
#include <pebble.h>
Window *my_window;
TextLayer *text_layer;
// isqrt_impl and isqrt provided by Siu Ching Pong on stackoverflow
uint32_t isqrt_impl(uint64_t const n, uint64_t const xk) {
uint64_t const xk1 = (xk + n / xk) / 2;
return (xk1 >= xk) ? xk : isqrt_impl(n, xk1);
}
@JoshuaJB
JoshuaJB / main.c
Created June 3, 2015 20:17
Pebble Accelerometer Average Demo Scaffold
#include <pebble.h>
// NOTE: See http://developer.getpebble.com/docs/c/Foundation/Event_Service/AccelerometerService/ for docs
Window *my_window;
TextLayer *text_layer;
static void display_acceleration(AccelData * data, uint32_t num_samples);
// TODO: Write accelerometer event handler
// TODO: All all the data points together for each axis, then divide by the number of samples
@JoshuaJB
JoshuaJB / app.js
Last active August 29, 2017 14:41
Basic Pebble App with WebSockets
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*/
var UI = require('ui');
@JoshuaJB
JoshuaJB / patch
Created December 26, 2013 04:51
Patch to enable profiling using yappi on the WFG 0 A.D. lobby bot.
Index: source/tools/XpartaMuPP/XpartaMuPP.py
===================================================================
--- source/tools/XpartaMuPP/XpartaMuPP.py (revision 14390)
+++ source/tools/XpartaMuPP/XpartaMuPP.py (working copy)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
"""
-
+import yappi
@JoshuaJB
JoshuaJB / options.xml
Created September 18, 2013 17:29
Options menu for 0AD.
<?xml version="1.0" encoding="utf-8"?>
<!--
==========================================
- Options Window -
==========================================
-->
<objects>
<script file="gui/common/functions_civinfo.js"/>
#include <string>
#include "sha.h"
void EncryptPassword(const std::string& username, std::string& password)
{
const int DIGESTSIZE = SHA_DIGEST_SIZE;
const int ITERATIONS = 1337;
static const byte salt_base[DIGESTSIZE] = {
244, 243, 249, 244, 32, 33, 34, 35, 10, 11, 12, 13, 14, 15, 16, 17,