Skip to content

Instantly share code, notes, and snippets.

import java.util.List;
import java.util.LinkedList;
public class Permute {
public static void main(String[] args) {
for(String s : permute("abcd"))
System.out.println(s);
}
public static List<String> permute(String s) {
@jmhertlein
jmhertlein / wowl.sh
Created June 5, 2015 06:11
WoW launch script w/ wine for nvidia hardware
#!/bin/bash
WOWPATH="/home/joshua/.wine/drive_c/Program Files (x86)/World of Warcraft"
cd "$WOWPATH"
if [ "$1" == "launcher" ]; then
WINEDEBUG=-all wine "World of Warcraft Launcher.exe"
elif [ "$1" == "kill" ]; then
wineserver -k
@jmhertlein
jmhertlein / gen_ca.sh
Last active June 18, 2024 19:30
bash script for generating new root SSL CA private key and certificate
#!/bin/bash
##################################################
# for generating your root CA private key and cert
##################################################
ca_name="jmhca"
ca_key_bits="4096"
ca_cert_expire_days="365"
Instead of this...
thinger: blah blah at x: 1, y: 1, z: 1
do this:
thinger:
msg: blah blah
x: 1
y: 1
@jmhertlein
jmhertlein / gist:f8fbf66f1109f9ad4cbc
Last active August 29, 2015 14:05
Orders using a Map
public class SomePlugin extends JavaPlugin {
private Map<String, Order> orders;
...
public void onEnable() {
//you'll need to remember to load the config from disk
//something like
//this.orders = getConfig().getMap("Amazon.Players");
this.orders = new HashMap<String, Order>;
@jmhertlein
jmhertlein / config.yml
Last active August 29, 2015 14:05 — forked from anonymous/config.yml
#The Configuration For Amazon!#
#This Config Will Contain Orders & More#
Amazon:
Players:
danderion:
item: DIAMOND_SWORD
count: 1
everdras:
item: DIAMOND
count: 64
/*
* Copyright (C) 2013 everdras@gmail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@jmhertlein
jmhertlein / MuhJFrame.java
Last active October 12, 2020 19:59
JFrame boilerplate
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.SwingWorker;
public class MuhJFrame extends JFrame {
private SwingWorker gameLooper;
private boolean stop;
private int seconds;
client connects to server
<authentication happens>
client writes a RemoteAction enum to signal what it wants to do (ADD_PLAYER, REMOVE_PLAYER, etc)
server reads enum, uses a big switch-case to direct flow to appropriate method
in the appropriate method, server reads in "arguments" for action one by one, as client sends them
server executes the action once it has all its input
server communicates back exit status
private void deleteTown(ObjectOutputStream oos, ObjectInputStream ois) throws IOException, ClassNotFoundException {
//receive arguments over socket
final String townName = (String) ois.readObject();
final FutureBoolean result = new FutureBoolean();
final Object callback = this;
//prepare a Runnable object to delete the town from the server's main thread
Runnable r = new Runnable() {
@Override