Skip to content

Instantly share code, notes, and snippets.

View rodel77's full-sized avatar
💻
Coding

rodel77 rodel77

💻
Coding
View GitHub Profile
:greeting // Label: This stores in memory as a pointer (same for all references to this label)
set_tx "message.greeting" // Set the text, clear decision list
add_dc "message.good" // Set decision
add_dc "message.bad"
decide // The program yields, then moves the result (index) to register #D
if D=="message.good" // Maybe test suits to check that "message.good" REALLY exists, in order to avoid typos
set_tx "message.me_too"
continue // The first option will be continue
decide
@rodel77
rodel77 / Java Syncronization
Last active November 24, 2018 20:46
A guide to myself to understand Java Synchronization
Without Modifiers:
Instance methods are async, this means that you can call a method in the same object from different threads at the same time and they will be executed as well *at the same time*, without locking
Synchronized Method:
Synchronized Methods of the *SAME INSTANCE* can't be in execution at the same time, even if they are different methods.
Synchronized Blocks:
2 or more synchronized blocks with the same reference (the argument) can't be in execution at the same time.
Doing a synchronized block with the instance (this) as reference has the same behaviour as a Synchronized Method but with no need of making the entire method synchronized.
In order to add "global synchronization" on a block, you can set the class of the instance or any other static object as reference.
@rodel77
rodel77 / resize.py
Last active November 13, 2018 04:50
Python batch resizing (Targeted to 32x32 & requires PIL)
import os
import PIL
from PIL import Image
if not os.path.exists("resized"):
os.makedirs("resized")
for (dirpath, dirnames, files) in os.walk("."):
for _file in files:
if ".png" in _file:
local TAG_MATCH = "[%a%d#=_-]+";
function tagize(tag)
if tag:sub(1, 2)=="</" then
local pos1, pos2 = tag:find(TAG_MATCH);
return {
tag = tag:sub(pos1, pos2),
mode = 0,
};
else
@rodel77
rodel77 / Spigot Chat Click Callback
Created May 5, 2017 23:37
Add callback to ClickEvent in TextComponent
import java.util.HashMap;
import java.util.UUID;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.Plugin;
@rodel77
rodel77 / config.php
Last active November 20, 2016 02:30
MBG WebStats
<?php
## CONFIGURATION ###
# MySQL Connection #
$sql_host = "";
$sql_username = "";
$sql_password = "";
$sql_dbname = "";
# Strings #
<html>
<head>
<title>MiniBoardGames Web-Stats</title>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body>
@rodel77
rodel77 / SoundHelper.java
Created October 3, 2016 00:16
Sound helper
package mx.com.rodel.utils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
* Sound helper enum
*
* Select one sound and play it, in 1.7/1.8/1.9/1.10
*