Skip to content

Instantly share code, notes, and snippets.


Christopher Perry christopherperry

View GitHub Profile
christopherperry / PlayerInputManagerHelper.cs
Last active June 10, 2020 23:53
Using more than one prefab with Unity's PlayerInputManager
View PlayerInputManagerHelper.cs
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInputManagerHelper : MonoBehaviour
public GameObject redBoxerPrefab;
public GameObject blueBoxerPrefab;
public GameEvent onRedPlayerJoin;
public GameEvent onBluePlayerJoin;
package coffee.maker;
import coffee.maker.heater.Heater;
import coffee.maker.pump.Pump;
public class CoffeeMaker {
private final Heater heater;
private final Pump thermosiphon;
public CoffeeMaker(Heater heater, Pump pump) {
christopherperry /
Last active April 10, 2016 03:40
Coffee Maker Dependency Inversion Example
package coffee.maker;
import coffee.maker.heater.ElectricHeater;
import coffee.maker.pump.Thermosiphon;
public class CoffeeMaker {
private final ElectricHeater heater;
private final Thermosiphon thermosiphon;
public CoffeeMaker() {
package com.example;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
* Copyright 2015 Christopher Perry
christopherperry / activity_stack
Created July 8, 2014 21:58
Display current Activity stack in Android
View activity_stack
adb shell dumpsys activity package <>
* Copyright (c) 2014 BioWink GmbH.
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
christopherperry /
Last active December 30, 2015 10:19
Evil reflective code
public void happyDebuggingSuckers() throws SecurityException, NoSuchFieldException, IllegalAccessException {
Field value = Boolean.class.getDeclaredField("value");
Boolean trueBool = true;
Boolean falseBool = false;
value.setBoolean(trueBool, false);
christopherperry /
Last active August 23, 2022 07:41
LruCache for Android with expiring keys. Instead of modifying LruCache directly I used delegation to get around final keyword usage and a dirty hack to override everything else.
import android.os.SystemClock;
import java.util.HashMap;
import java.util.Map;
* An Lru Cache that allows entries to expire after
* a period of time. Items are evicted based on a combination
* of time, and usage. Adding items past the {@code maxSize}
christopherperry / Intellij Unit Test VM options
Last active December 24, 2015 23:08
IntelliJ memory setting for unit tests
View Intellij Unit Test VM options
Set VM options to: -ea -Xms800m -Xmx800m -XX:MaxPermSize=500m