Skip to content

Instantly share code, notes, and snippets.

View zkxs's full-sized avatar

zkxs

View GitHub Profile
@zkxs
zkxs / HatSwitchSnippet.java
Last active August 29, 2015 13:57
Example of how to use JInput to read the state of the POV hat switch.
/*
* Initialize JInput and get reference to `controller`
* Implementing this is left as an exercise to the reader
*/
initializeJInput();
String[] directions = { "NW", "N", "NE", "E", "SE", "S", "SW", "W" };
EventQueue eventQueue = controller.getEventQueue();
Event event = new Event(); // reused by the EventQueue
@zkxs
zkxs / UnicodeCharExtract.java
Created July 3, 2014 07:30
Extracts unicode characters less than 0x1F0F1 from a file
import java.io.*;
import java.nio.CharBuffer;
/**
* Extracts unicode characters less than 0x1F0F1 from a file.
* <br />
* Created for http://www.reddit.com/r/program/comments/1tvh50/request_unicodetxt/
* <br />
* Usage: java UnicodeCharExtract path/to/file > output.txt
* <br />
@zkxs
zkxs / LoggerSuppress.java
Created November 14, 2014 05:16
Suppress java Logger logging below some level
import java.util.logging.ConsoleHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
class LoggerSuppress
{
private void setLogHandlerLevel(Level level)
{
@zkxs
zkxs / quassel-commands.txt
Last active May 20, 2022 04:17
Quassel Commands
Standard IRC commands:
/away
/ban
/unban
/deop
/dehalfop
/devoice
/invite
/join
/kick
@zkxs
zkxs / InputProfile_User.xml
Created April 10, 2015 18:38
Planetside 2 keybindings and how they changed after Game Update 4/9 (Flight control changes)
<Profile name="User" version="3">
<ActionSet name="Generic" radialMenuNavigation="Right">
<Action name="StartChatText">
<Trigger>Return</Trigger>
</Action>
<Action name="Reply">
<Trigger>Backspace</Trigger>
</Action>
<Action name="TogglePerformance">
<Trigger>Alt_Left+F</Trigger>
@zkxs
zkxs / chown.java
Created July 14, 2015 02:37
Because sometimes /usr/bin/chown won't cut it
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.*;
public class chown {
private static final int
ERR_FEW_ARGS = 1,
ERR_FIRST_ARG = 2,
ERR_FILE_NONEXISTANT = 3,
@zkxs
zkxs / mingw-i686.sh
Created July 20, 2015 18:11
Cross compilation scripts
#!/bin/sh
PREFIX=i686-w64-mingw32
export CC=$PREFIX-gcc
export CXX=$PREFIX-g++
export CPP=$PREFIX-cpp
export RANLIB=$PREFIX-ranlib
exec "$@"
@zkxs
zkxs / pathgrep.sh
Created July 20, 2015 18:47
Search for $1 on the path, and print the filename if we find it
#!/bin/bash
#magically arrayify $PATH
IFS=':' read -a arr <<< "$PATH"
# iterate
for i in "${arr[@]}"; do
# grep for arg 1
ls -1 "$i" | fgrep "$1"
done
@zkxs
zkxs / psgrep
Last active August 29, 2015 14:25 — forked from minkcv/psgrep
grep for a process
#!/bin/bash
ps -Ne u
ps aux | fgrep "$1" | fgrep -v fgrep | fgrep -v $$
@zkxs
zkxs / Braces.java
Last active August 29, 2015 14:27
Double Brace Initialization
import java.util.*;
class Braces {
public static void main(String[] args) {
List<String> list = new ArrayList<String>(){{
add("michael");
add("was");
add("here");
}};