Skip to content

Instantly share code, notes, and snippets.

View Techcable's full-sized avatar
🇺🇸
Procrastinating

Techcable

🇺🇸
Procrastinating
View GitHub Profile
@Techcable
Techcable / Reflection.java
Created September 3, 2015 18:05
Get TPS
/**
* The MIT License
* Copyright (c) 2014-2015 Techcable
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
@Techcable
Techcable / start.sh
Last active February 25, 2024 11:02
Minecraft Launch Script (and options)
#!/bin/bash
# The type of the server: spigot, bukkit, paper, taco
SERVER_BRAND=taco
# The minecraft version
SERVER_VERSION=1.8.8
# The amount of memory you want the server to use
TARGET_MEMORY=512M
# The maximum amount of memory the server is allowed to use
@Techcable
Techcable / Concurrency1.java
Created September 16, 2015 02:30
GroupManger Stupidity
public UserData getUser(UUID userId) {
if (getUsers().containsKey(userId)) {
return getUsers().get(userId);
}
// No user account found so create a new one.
UserData newUser = createUser(userId);
return newUser;
@Techcable
Techcable / RayTrace.java
Created October 4, 2015 22:52
RayTrace
package net.techcable.tacoray.utils;
import lombok.*;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
@Techcable
Techcable / BukkitPlatform.java
Created October 18, 2015 21:57
Bukkit/Bungee platform abstraction
package net.techcable.bungeegroups.bukkit.platform;
import lombok.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@Techcable
Techcable / generatePatches.py
Created October 25, 2015 22:16
Python script to generate patches
#!/usr/bin/python3
import argparse
import os
import difflib
import util
parser = argparse.ArgumentParser("Generate patches to the MCP sources")
parser.add_argument('-mcp', help = 'The original mcp sources', default = 'mcp/src/minecraft_server')
parser.add_argument('-out', help = 'Where to place the generated patches', default = 'patches')
parser.add_argument('src', nargs = '?', help = 'The modified sources', default = 'src/main/java')
@Techcable
Techcable / dos2unix.py
Created November 2, 2015 06:45
A dos2unix python clone that supports recusrively finding files (doesn't suck)
import argparse
import os
import re
parser = argparse.ArgumentParser("Convert line endings to \\n")
parser.add_argument('--excluded', help='Patterns of files or directories to exclude', nargs='*')
parser.add_argument('--quiet', '-q', help='Suppress non-error output', action='store_true')
parser.add_argument('input', nargs='+', help='Files or directories to convert line endings in')
args = parser.parse_args()
@Techcable
Techcable / .java
Last active December 18, 2015 19:46
Yay craftbukkit!
// CraftBukkit start
public static int executeCommand(ICommandSender sender, CommandSender bukkitSender, String rawCommand) {
CraftServer server = (CraftServer) bukkitSender.getServer();
SimpleCommandMap commandMap = server.getCommandMap();
Joiner joiner = Joiner.on(" ");
if (rawCommand.startsWith("/")) rawCommand = rawCommand.substring(1);
String[] command = rawCommand.split(" ");
String commandName = command[0];
if (commandName.startsWith("minecraft:")) commandName = commandName.substring("minecraft:".length());
@Techcable
Techcable / prime.c
Last active May 27, 2016 18:44
Benchmarks
#include <stdbool.h>
#include <stdio.h>
#include <math.h>
#define SQRT_THRESHOLD 1000
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
bool isPrime(int num) {
if (num == 1 || num == 2 || num % 2 == 0) return false;
@Techcable
Techcable / plugintest.py
Created January 12, 2016 08:08
Utility to compile/copy and run a plugin in a test server
#!/usr/bin/env python3
import os
import sys
from os import path
import shutil
from subprocess import run, DEVNULL
from zipfile import ZipFile
# pip install PyYAML
import yaml