Skip to content

Instantly share code, notes, and snippets.

package echo.client.gl;
import echo.core.geom.Vector;
import lombok.Getter;
import lombok.Setter;
public class VertexVector extends Vector implements VertexAttribute {
public static final int ELEMENT_SIZE = 4;
/**
* Multi-threaded matrix multiplication.
* @param a a matrix
* @param b another matrix
* @return The resulting matrix-multiplied matrix
*/
public static int[][] multiplyMatrix(final int[][] a, final int[][] b) {
ExecutorService exec = Executors.newFixedThreadPool(9);
List<Callable<Object>> tasks = new LinkedList<>();
final int[][] result = new int[3][3];
@jhead
jhead / gist:6057224
Last active December 20, 2015 02:29
<?php
function pingNetwork($hostname, $port = 25565) {
$packet = "\xFE\x01";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
try {
$sConnectStatus = @socket_connect($socket, $hostname, $port);
if (!$sConnectStatus) return false;
$sWriteStatus = @socket_write($socket, $packet, strlen($packet));
@jhead
jhead / cleanup.php
Last active December 28, 2015 20:38
<?php
require_once("_api/init.php");
global $MCApi, $DB;
$result = $MCApi->listServers();
if ($result['success'] != 1) die('Unable to fetch server list.');
$servers = $result['data']['Servers'];
foreach ($servers as $id => $serverName) {
if (strpos($serverName, "InstantMC - ") !== 0) {
<?php
$procList = array();
$newProcList = array();
$limitProcs = array();
while (true) {
$count = 0;
$newProcList = getProc();
foreach ($newProcList as $pid) {
@jhead
jhead / spigot-patcher.sh
Last active August 29, 2015 14:06
Finds latest Spigot binary patch and applies to the specified file
#!/bin/bash
## Validate arguments
if [ "$#" -ne 2 ]; then
echo "Fetches latest Spigot patch and applies it."
echo
echo "Usage: <spigot-1649-jar-path> <output-file>"
exit 1
fi
#!/bin/bash
ITER=5
##
function usage {
echo "Usage: resolve [options] hostname"
echo
echo -e " -t #\t\tSpecify number of lookups (default 5)"
exit
var fs = require('fs'),
https = require('https'),
async = require('async'),
yaml = require('js-yaml');
var TIMESTAMP = 1422921600;
var data = fs.readFileSync('permissions.yml');
var doc = yaml.safeLoad(data);
//
package justinhead.se3345;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Stack;
@jhead
jhead / dedupe.sh
Last active August 29, 2015 14:16
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: ./dedupe.sh [path]"
exit 1
fi
BASE=$1
MAX_SIZE="25M"
FILTER='\.(mca|log|gz)$'