Skip to content

Instantly share code, notes, and snippets.

View chRyNaN's full-sized avatar

Chris Keenan chRyNaN

View GitHub Profile
@chRyNaN
chRyNaN / DefaultListener.java
Last active March 24, 2023 23:11
Server-Sent Event Java Servlet backend
public interface DefaultListener {
public void onNotification(NotificationEvent event);
}
@chRyNaN
chRyNaN / Optional.java
Created February 18, 2017 20:38
A Java 8 Optional representation using RxJava.
import java.util.NoSuchElementException;
import rx.functions.Action1;
import rx.functions.Func1;
/**
* Created by ckeenan on 2/18/17. A Java 8 Optional representation using RxJava.
*/
public class Optional<T> {
@chRyNaN
chRyNaN / ItemAdapter.java
Created March 31, 2016 00:34
Classes to bridge the gap between RecyclerView and ListView by providing a common API.
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
@chRyNaN
chRyNaN / Escape.js
Last active April 29, 2016 14:59
JavaScript code that parses HTML/XHTML escape characters
(function(){
/**
* Code is heavily influenced from Underscore.js (their escape and unescape functions):
* https://github.com/jashkenas/underscore/blob/master/underscore.js
*/
window.Code = {};
var escapeMap = {
'&': '&amp;',
@chRyNaN
chRyNaN / ViewUtils.java
Created March 25, 2016 16:08
A convenient utility class for Android Views.
import android.animation.Animator;
import android.animation.TimeInterpolator;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
@chRyNaN
chRyNaN / AbstractJob.java
Last active March 31, 2016 20:29
Android classes to simplify performing tasks of different types using a job queue.
import android.os.Looper;
import java.util.ArrayList;
import java.util.List;
/**
* Created by chRyNaN on 3/31/2016. An abstract class implementation of the Job interface to handle some boilerplate code.
*/
public abstract class AbstractJob implements Job {
private List<JobCompletedListener> listeners;
@chRyNaN
chRyNaN / ItemAdapter.java
Created March 30, 2016 21:14
An Android RecyclerView adapter class that adds ArrayAdapter functionality.
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
@chRyNaN
chRyNaN / ArrayObjectAnimator.java
Created March 25, 2016 16:18
An Android class that supports animating over an array of values.
import android.animation.AnimatorSet;
import android.animation.TimeInterpolator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import java.lang.reflect.Field;
/**
* Created by chRyNaN on 3/24/2016. This class encapsulates an AnimatorSet and an ObjectAnimator (actually a ValueAnimator
* but it updates the value of an Object similar to how an ObjectAnimator works) and performs animations over an array of
@chRyNaN
chRyNaN / JSONSerializer.java
Created January 9, 2016 19:16
Simple JSONObject Serialization
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
@chRyNaN
chRyNaN / User.java
Created January 21, 2015 02:48
Simple Entity Structure Implementation for User
import java.util.Date;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQuery;