Skip to content

Instantly share code, notes, and snippets.

Avatar

Christopher Perry christopherperry

View GitHub Profile
@christopherperry
christopherperry / html_directory_selection
Created Jun 29, 2013
Select directory with HTML input field.
View html_directory_selection
<input type="file" name="files[]" multiple directory webkitdirectory mozdirectory>
@christopherperry
christopherperry / SwipeLinearLayout.java
Created Aug 27, 2012
Android LinearLayout that handles left swipes.
View SwipeLinearLayout.java
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 / PlayerInputManagerHelper.cs
Last active Jun 10, 2020
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;
@christopherperry
christopherperry / CheckableLinearLayout
Created Sep 18, 2012
A LinearLayout that implements the Checkable interface, allowing a LinearLayout to be put into a checked state.
View CheckableLinearLayout
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 / ExpiringLruCache.java
Last active Jul 4, 2020
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.
View ExpiringLruCache.java
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 / adb+
Created Jul 30, 2012
A bash script that let's you issue adb commands to multiple devices at once
View adb+
#!/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