Skip to content

Instantly share code, notes, and snippets.

View gkhays's full-sized avatar

Garve Hays gkhays

View GitHub Profile
@gkhays
gkhays / minecraft-server
Created June 17, 2014 15:04
Run Minecraft Server as a Daemon
I liked this one the best: http://www.minecraftforum.net/topic/74402-setup-linux-daemon/.
1) Get the code snippet below into a file in /etc/init.d/. This will be referenced as FILENAME henceforth. I used:
/etc/init.d/minecraft-server:
minecraft-server
#! /bin/sh
#
# network Bring up/down networking
@gkhays
gkhays / mc-parselog
Created June 17, 2014 15:14
Minecraft Server Log One-Liners
Create a list of users based on logins
grep "logged in with entity id" server.log | cut -f4 -d" " | sort -u > users.txt
Get connection information:
Date/Time, Name, and IP Address
grep logged server.log | cut -f1,2,4,5 -d" "
Get disconnect information:
Date/Time, Name
grep disconnect server.log | cut -f1,2,4 -d" "
@gkhays
gkhays / StringSwitch.java
Created July 3, 2014 21:46
Prior to JDK 1.7, you had to use an approximation to evaluate strings in a switch statement. Much easier now!
package org.gkh.test;
/*
* Prior to JDK 1.7, you had to use an approximation to evaluate strings in a
* switch statement. See the following links.
* http://www.xefer.com/2006/12/switchonstring
* http://stackoverflow.com/questions/338206/switch-statement-with-strings-in-java
* http://docs.oracle.com/javase/7/docs/technotes/guides/language/strings-switch.html
*/
public class StringSwitch {
@gkhays
gkhays / TestQueuingThread.java
Last active August 29, 2015 14:03
A simple inter-process communication (IPC) utility that watches for the creation of tiles in a specific subdirectory and then queues them for processing. Currently hard-coded to watch a subdirectory called "Locker" located in the test directory relative to the execution path.
package org.gkh.test;
import java.nio.file.Path;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
/**
* This is a demonstration Producer/Consumer that queues and dequeues new file
* items as they are created in the directory we are watching.
*
@gkhays
gkhays / JrxmlParser.java
Created July 7, 2014 19:40
A simple JasperReports parser that also demonstrates issues with UTF-8 encoded XML files.
package org.gkh.test;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@gkhays
gkhays / GoogleAuthCode.java
Last active August 29, 2015 14:20
Working with Google APIs
package com.netiq;
import java.awt.Desktop;
import java.awt.Desktop.Action;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
import java.util.Properties;
@gkhays
gkhays / audit-jars.sh
Created October 8, 2015 18:32
List all the JAR files being used in a project or installation.
#!bin/bash
# Find all the JARs starting here and print them out.
find . -name *.jar -print > audit.txt
# Strip out the path and sort.
find . -name *.jar -exec basename {} \; | sort -u > audit-nopath.txt
@gkhays
gkhays / svn-history.md
Last active October 8, 2015 19:49
SVN Activity Metrics: See and count the number of revisions given a date range.

Subversion Log

The first place I looked for svn log syntax was the manual; see Examining History. E.g.

$ svn log
------------------------------------------------------------------------
r3 | sally | 2008-05-15 23:09:28 -0500 (Thu, 15 May 2008) | 1 line

Added include lines and corrected # of cheese slices.
#! /bin/sh
#
# network Bring up/down networking
#
# chkconfig: 345 20 80
# description: Starts and stops minecraft-server-nogui.sh
#
case "$1" in
start)