Skip to content

Instantly share code, notes, and snippets.

View Afforess's full-sized avatar

Cameron McAvoy Afforess

View GitHub Profile
@Afforess
Afforess / Main.java
Created January 4, 2012 11:29
synchronized test
public class Main {
public static void main(String[] args) {
MyThreadUnsafeTestObject o1 = new MyThreadUnsafeTestObject();
MyThreadSafeTestObject o2 = new MyThreadSafeTestObject();
long start = System.nanoTime();
for (int i = 0; i < 1000000; i++) {
o1.foo();
}
@Afforess
Afforess / Main.java
Created January 7, 2012 01:49
Trove vs Java Concurrent
public class Main {
public static void main(String[] args) {
long troveGetTime, trovePutTime, javaGetTime, javaPutTime;
troveGetTime = trovePutTime = javaGetTime = javaPutTime = 0L;
for (int test = 0; test < 10; test++) {
ConcurrentHashMap<Integer, Integer> testMap = new ConcurrentHashMap<Integer, Integer>(100000);
TIntObjectMap<Integer> testMap2 = TCollections.synchronizedMap(new TIntObjectHashMap<Integer>(100000));
ArrayList<Thread> threads = new ArrayList<Thread>();
for (int i = 0; i < 10; i++) {
if (i % 2 == 0) {
@Afforess
Afforess / RegionChunkProvider.java
Created February 5, 2012 14:48
Region Chunk Provider
package org.bukkit.craftbukkit;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
// CraftBukkit start
import java.util.Random;
import net.minecraft.server.BlockSand;
import net.minecraft.server.Chunk;
@Afforess
Afforess / World Save Format
Created March 1, 2012 23:10
World Save Format - Spout Server
Header Information for each Region:
Region Coord X (Integer).
Region Coord Y (Integer).
Region Coord Z (Integer).
Payload:
16x16x16 chunk information
Header information for each Chunk:
Format (0/1). 0 - Byte Ids. 1 - Short Ids.
@Afforess
Afforess / restapi.txt
Created September 19, 2012 01:58
Rest API Stuff
http://get.spout.org/nuget/mirrors
http://get.spout.org/nuget/builds/spout
http://get.spout.org/nuget/builds/dev/spout
http://get.spout.org/nuget/builds/beta/spout
http://get.spout.org/nuget/libraries
http://get.spout.org/nuget/libraries/dev
http://get.spout.org/nuget/libraries/beta
http://get.spout.org/nuget/libraries/stable
@Afforess
Afforess / Main.java
Created October 30, 2012 16:26
Random name generator
import java.util.Random;
public class Main {
public static void main(String[] args) {
System.out.println(getRandomName(new Random(), 10));
}
@Afforess
Afforess / gist:4013360
Created November 4, 2012 19:55
Death Cause Factory pattern
public enum DeathCause implements DeathCauseFactory {
DROWNING {
public Cause<?> buildCause(Entity victim, Entity killer) {
return new DrowningCause(victim);
}
},
FALLING {
public Cause<?> buildCause(Entity victim, Entity killer) {
//TODO
@Afforess
Afforess / mockup
Created December 23, 2012 04:26
Text to remember
[22:58:09] <@Wulfspider> Most of the buttons in the mockup can go away
[22:58:14] <@Wulfspider> Gear icon for options, by the player name
[22:58:28] <@Wulfspider> With the player's avatar to the left of the name (still pondering best placement)
[22:58:41] <@Wulfspider> Home Play Market About
[22:58:49] <@Wulfspider> Those for the bottom, all in a single line, no background
[22:58:59] <@Wulfspider> No other buttons
[22:59:17] <@Wulfspider> The rest in the middle is still being decided on, as we don't know exactly what we want there, but we don't want huge lists
[22:59:25] <@Afforess> ok
[22:59:38] <@Wulfspider> The servers and such can go on the place page
[22:59:55] <@Wulfspider> We were talking about removing the difference between SP and MP, so it'd all go under the Play page
# Get the latest Sun Java SDK from Oracle
wget http://download.oracle.com/otn-pub/java/jdk/7u17-b02/jdk-7u17-linux-i586.rpm
# Rename the file downloaded, just to be nice
mv jdk-7u17-linux-i586.rpm\?e\=1320265424\&h\=916f87354faed15fe652d9f76d64c844 jdk-7u17-linux-i586.rpm
# Install Java
sudo rpm -i jdk-7u17-linux-i586.rpm
# Check if the default java version is set to sun jdk
function softPowerScore() {
var html = $('<div>').append($(".highcharts-data-labels").children()[0]).html();
var search = '<tspan x="3">';
var index = html.indexOf(search) + search.length;
var end = html.indexOf('</tspan>', index);
console.log(index + " " + end);
return html.substring(index, end);
}