Skip to content

Instantly share code, notes, and snippets.

View InventivetalentDev's full-sized avatar
🏳️‍🌈

Haylee Schäfer InventivetalentDev

🏳️‍🌈
View GitHub Profile
@InventivetalentDev
InventivetalentDev / jquery-preload.js
Created May 25, 2016 14:25
Simple jQuery image pre-loader
function preloadImage(source, $element, callback) {
$preload = $("<img src='" + source + "' class='_image_preloader' style='display:none'>");
$preload.on("load", function() {
$element.attr("src", source);
if ( typeof callback === "function") {
callback(source, $element);
}
});
$preload.appendTo($("body"));
}
@InventivetalentDev
InventivetalentDev / StopSound.java
Last active June 10, 2016 01:30
Stop sound API
public void onEnable() {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "MC|StopSound");
}
public void stopSound(Player player, String source, String sound) {
byte[] sourceBytes = source.getBytes();
byte[] soundBytes = sound.getBytes();
ByteArrayDataOutput output = ByteStreams.newDataOutput();
writeLong(output, soundBytes.length);
output.write(soundBytes);
package org.inventivetalent.soundmuffler;
import java.util.concurrent.CountDownLatch;
// Based on http://stackoverflow.com/questions/3379787/make-asynchronous-queries-synchronous
public class FutureResult<V> {
private volatile V result;
private final CountDownLatch countDownLatch = new CountDownLatch(1);
window.ActivityTracker = {
track : function(callback, element, threshold) {
var cancelled = false;
var state = {
cancel : function() {
cancelled = true;
}
};
if (element == undefined) {
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class BlockIterable implements Iterable<Block> {
private final World world;
@InventivetalentDev
InventivetalentDev / NBTInjector.java
Created July 10, 2016 13:48
NBTInjector Example
Bukkit.getPluginManager().registerEvents(new Listener() {
@EventHandler
public void on(PlayerInteractEntityEvent event) {
CompoundTag tag = NBTInjector.getNbtData((Entity) event.getRightClicked());
if (tag != null) {
NBTTag countTag = tag.get("clickCount");
if (countTag == null) { countTag = new IntTag(); }
tag.set("clickCount", countTag.getAsInt() + 1);
}
}
package org.inventivetalent.nicknamer;
public class JavaVersion {
public static final JavaVersion INSTANCE = new JavaVersion(System.getProperty("java.version"));
private final int major;
private final int minor;
private final int patch;
private final int update;
@InventivetalentDev
InventivetalentDev / ng-preload-src.js
Created August 23, 2016 16:07
AngularJS image preloader
app.directive("ngPreloadSrc", function () {
return {
restrict: "A",
replace: true,
link: function (scope, element, attrs) {
var $preloader = $("<img style='display:none'>");
$preloader.attr("src", attrs.ngPreloadSrc);
$preloader.on("load", function () {
element.attr("src", attrs.ngPreloadSrc);
$preloader.remove();

Keybase proof

I hereby claim:

  • I am inventivetalentDev on github.
  • I am inventivetalent (https://keybase.io/inventivetalent) on keybase.
  • I have a public key whose fingerprint is B794 0567 2F13 8459 61D7 32C7 C700 3F26 A4C4 CFB9

To claim this, I am signing this object:

import org.json.simple.JSONValue;
import org.json.simple.parser.ParseException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class JSONAPI {