Skip to content

Instantly share code, notes, and snippets.

View games647's full-sized avatar

games647 games647

View GitHub Profile
@games647
games647 / minecraft-offline-uuid.php
Last active April 1, 2024 00:24
Generate an offline minecraft UUID v3 based on the case sensitive player name
<?
/**
* Generates a offline-mode player UUID.
*
* @param $username string
* @return string
*/
public static function constructOfflinePlayerUuid($username) {
//extracted from the java code:
//new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name));
@games647
games647 / Account.java
Created December 9, 2016 14:54
Upload a Minecraft skin automatically
package com.github.games647.changeskin.core.model.mojang.auth;
import com.github.games647.changeskin.core.model.PlayerProfile;
public class Account {
private final PlayerProfile profile;
private final String accessToken;
public Account(PlayerProfile profile, String accessToken) {
@games647
games647 / OfflineUUID.java
Created August 10, 2016 15:13
Generate a offline uuid based on the minecraft player name
import com.google.common.base.Charsets;
import java.util.UUID;
public class OfflineUUID {
public static void main(String[] test) throws Exception {
UUID.nameUUIDFromBytes(("OfflinePlayer:" + "playerName").getBytes(Charsets.UTF_8));
}
@games647
games647 / Origin-focus steal.kwinrule
Last active May 20, 2022 13:54
KDE window rule to prevent Origin launcher in steam proton/wine to steal the focus if notifications pop up like achievements, chat message or opening the overlay itself. To import it select window rules in KDE, click import and then import the file below.
[Origin no minimize (low enough for notification but still allows dialogs (e.g. close dialog))]
Description=Origin no minimize (low enough for notification but still allows dialogs (e.g. close dialog))
fsplevel=1
fsplevelrule=2
skipswitcher=true
skipswitcherrule=2
title=Origin
titlematch=1
types=1
wmclass=steam_(proton|app_[0-9])
@games647
games647 / bungee-sqlite.md
Last active December 12, 2021 04:18
Add SQLite support to your BungeeCord server.
  1. Download the SQLite driver .jar from here: https://bitbucket.org/xerial/sqlite-jdbc/downloads
  2. Open your BungeeCord/Waterfall jar with any archiver program
  3. Open the SQLite driver with any archiver program
  4. Copy the contents (the "org"-folder) from the SQLite driver to BungeeCord
  5. Now just use the SQLite settings in the ChangeSkin config.
public class AnnotationHelper {
private static final String ANNOTATIONS = "annotations";
public static final String ANNOTATION_DATA = "annotationData";
public static boolean isJDK7OrLower() {
boolean jdk7OrLower = true;
try {
Class.class.getDeclaredField(ANNOTATIONS);
} catch (NoSuchFieldException e) {
//Willfully ignore all exceptions
@games647
games647 / ReflectionTest.java
Created May 18, 2020 14:43
Java Reflection performance
package org.sample;
import java.lang.invoke.LambdaMetafactory;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.UUID;
"""
Copyright 2011 Tyler Kennedy <tk@tkte.ch>. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
@games647
games647 / HeapDump.java
Created December 9, 2016 12:04
Dumps the JVM heap stats to a single string or in a file which then can be analyzed by VisualVM or Java Mission Control
import java.io.File;
import java.lang.management.ManagementFactory;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
@games647
games647 / gist:924ae035ab3586e6bbee2894b4b64cd5
Last active March 7, 2020 20:56
Java HTTP Keep-Alive Summary
* HTTP Keep alives are enabled by default and hold a connection up to a couple of minutes.
* By default up to 5 connections per destination are hold up
* You can disable it by calling explicitly disconnect
(Note: For android you should call disconnect always)
* For re-use the following has to be true
* share similar settings like same **instance** of SSLFactory
* Server has to accept keep-alive (no close)
* Fully consume inputstream, outputstream and errorstream and close it
(Since JDK 6: spawns a extra thread that consume some remaining data if the length is longer it's not used for keep-alives)