Skip to content

Instantly share code, notes, and snippets.

View kevinmost's full-sized avatar
🏠
Working from home

Kevin Most kevinmost

🏠
Working from home
View GitHub Profile
@kevinmost
kevinmost / How not to go nuts.md
Created March 11, 2017 15:57
Writing a Kotlin @autoservice processor
@kevinmost
kevinmost / Func0.java
Created January 24, 2017 22:48
Making Gson's JsonElement less bad [Apache 2 license]
public interface Func0<R> {
@NotNull R call();
}
@kevinmost
kevinmost / JSONAdapterFactory.java
Last active August 25, 2016 17:08
Helper for @JsonAdapter
public abstract class JSONAdapterFactory<T> implements TypeAdapterFactory {
@NotNull private final TypeToken<T> typeToken;
@Nullable private final JSONUnmarshaler<T> unmarshaler;
@Nullable private final JSONMarshaler<T> marshaler;
public JSONAdapterFactory() {
this.typeToken = typeToken();
this.unmarshaler = unmarshaler();
this.marshaler = marshaler();
@kevinmost
kevinmost / ExampleUsage.kt
Created April 29, 2016 19:41
Hawk Wrappers
val generalModelVersion: Float = HawkFloatKey.GENERAL_MODEL_VERSION.getValue()
main() {
selectDevice
runLastCommand
}
selectDevice () {
clear
echoerr "What running device would you like to change the URL for?"
EXIT_CHOICE="Exit"
PS3="Select a device: "
switch (currentColumnClass.getName()) {
case "int":
try {
builderToAddColumnTo.getClass().getMethod("get" + StringUtils.capitalize(currentColumnName), currentColumnClass).invoke(builderToAddColumnTo, Integer.parseInt(currentColumnValue));
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
}
@kevinmost
kevinmost / -
Created July 3, 2014 21:24
my tint2 config, goes into ~/.config/tint2/tint2rc
# Tint2 config file
# Generated by tintwizard (http://code.google.com/p/tintwizard/)
# For information on manually configuring tint2 see http://code.google.com/p/tint2/wiki/Configure
# Background definitions
# ID 1
rounded = 0
border_width = 0
background_color = #000000 100
border_color = #000000 16
@kevinmost
kevinmost / gist:65dc597119eebf9e82ed
Created May 15, 2014 21:28
Simple CircularBuffer
import java.util.ArrayList;
import java.util.List;
/**
* This is an "array"-type object that only holds a set number of frames, and overwrites the oldest ones as you go on.
* For example, if you set it to have a size of 8, it will record frames 0-7, and then on frame 8, record over 0, on frame 9, record over 1, etc.
* The "length" will appear, from the outside, to extend onwards, as with a normal list (for example, after two loops through, it will have a reported length of 16)
* You will be able to push to this array, peek n layers down, etc
* @author kmost
* @date 5/15/14