Skip to content

Instantly share code, notes, and snippets.

View christopherperry's full-sized avatar

Christopher Perry christopherperry

View GitHub Profile
@christopherperry
christopherperry / adb+
Created July 30, 2012 16:12
A bash script that let's you issue adb commands to multiple devices at once
#!/bin/bash
# Script adb+
# Usage
# You can run any command adb provides on all your currently connected devices
# ./adb+ <command> is the equivalent of ./adb -s <serial number> <command>
#
# Examples
# ./adb+ version
# ./adb+ install apidemo.apk
# ./adb+ uninstall com.example.android.apis
@christopherperry
christopherperry / ExpiringLruCache.java
Last active February 16, 2024 15:12
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 android.support.v4.util.LruCache;
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
christopherperry / SwipeLinearLayout.java
Created August 27, 2012 18:38
Android LinearLayout that handles left swipes.
import android.content.Context;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.widget.LinearLayout;
public class SwipeLinearLayout extends LinearLayout {
private GestureDetector gestureDetector;
private OnSwipeListener listener;
@christopherperry
christopherperry / CheckableLinearLayout
Created September 18, 2012 22:43
A LinearLayout that implements the Checkable interface, allowing a LinearLayout to be put into a checked state.
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Checkable;
import android.widget.LinearLayout;
@christopherperry
christopherperry / PlayerInputManagerHelper.cs
Last active June 10, 2020 23:53
Using more than one prefab with Unity's PlayerInputManager
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerInputManagerHelper : MonoBehaviour
{
public GameObject redBoxerPrefab;
public GameObject blueBoxerPrefab;
public GameEvent onRedPlayerJoin;
public GameEvent onBluePlayerJoin;
@christopherperry
christopherperry / html_directory_selection
Created June 29, 2013 07:16
Select directory with HTML input field.
<input type="file" name="files[]" multiple directory webkitdirectory mozdirectory>
/**
* ArcUtils.java
*
* 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
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
christopherperry / CoffeeMaker1.java
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
*