Skip to content

Instantly share code, notes, and snippets.

View Ribesg's full-sized avatar
🇫🇷

Gael Ribes Ribesg

🇫🇷
View GitHub Profile
@Ribesg
Ribesg / Foo.java
Last active January 3, 2016 12:29
// INPUT
final Map<ItemStack, Double> myItemsWithWeight; // Initialized somewhere before that
// Data
final List<ItemStack> myItems = new ArrayList<>(myItemsWithWeight.size());
final double[] risingWeights = new double[myItemsWithWeight.size()];
// Compute total weight
double total = 0;
for (final double d : myItemsWithWeight.values()) {
// Java 6
SomeStream stream
try {
stream = new SomeStream(someArg);
// Stuff
} catch (SomeStreamExceptions e) {
// Stuff
} final {
try {
stream.close();
@Ribesg
Ribesg / bash_aliases.sh
Last active December 31, 2015 12:09
Here's my server's Starbound related config files and scripts.
alias sb_start="sudo start starbound"
alias sb_stop="sudo stop starbound"
alias sb_restart="sb_stop;sb_start"
alias sb_update="sudo /home/ribesg/sb_update"
alias sb_online="netstat -nt | grep -c 21025"
alias sb_status="sudo status starbound"
#####################################################################
## Config file for NPlayer plugin ##
## If you don't understand something, please ask on dev.bukkit.org ##
## Ribesg ##
#####################################################################
# Maximum login attempts before punishment. Possible values: Positive integers
# Default : 3
maximumLoginAttempts: 1
# How do we punish people after too many attempts? Possible values: 0, 1, 2
#####################################################################
## Config file for NTalk plugin ##
## If you don't understand something, please ask on dev.bukkit.org ##
## Ribesg ##
#####################################################################
# The template used to parse chat messages
# Default : &f<[prefix][name][suffix]&f> [message]
template: "[prefix][name][suffix] &f: [message]"
# The template used to parse private messages
import java.util.ArrayList;
import java.util.List;
/** @author dumptruckman, Ribesg */
public class ArgumentParser {
/**
* Transform a Bukkit-provided args array, considering quotes in the original String.
* Example:
* - Input = { a | 'b | c | d' | "e | f | g" | h"i | j" | "k | l'm | n" | 'o | p | q }
@Ribesg
Ribesg / Utils.java
Last active December 21, 2015 17:39
/**
* Parses an original args array provided to a CommandExecutor to support quotes.
* If the parameter array is malformed, then this method returns the parameter array as-is.
*
* @param args The original args array. Ex: ['A', '"B', 'C', 'D"', 'E']
*
* @return The resulting args array, if valid. Ex: ['A', 'B C D', 'E']
*/
public static String[] parseArgumentsWithQuotes(String[] args) {
final List<String> resultList = new ArrayList<>();
/**
* Parses an original args array provided to a CommandExecutor to support quotes.
* If the parameter array is malformed, then this method returns the parameter array as-is.
*
* @param args The original args array. Ex: ['A', '"B', 'C', 'D"', 'E']
*
* @return The resulting args array, if valid. Ex: ['A', 'B C D', 'E']
*/
public static String[] parseArgumentsWithQuotes(String[] args) {
final List<String> resultList = new ArrayList<>();
public class TestClass {
public void method() {
// 1
}
public void someOtherMethod() {
new Runnable() {
@Override
public void run() {
// !gstats
private class GlobalStats {
public String serversAmount;
public String serversDiff;
public String serversMax;
public String serversMin;
public String serversAvg;
public String playersAmount;