Skip to content

Instantly share code, notes, and snippets.

@mattgmg1990
mattgmg1990 / DisplayTrackingService.java
Created January 10, 2017 02:08
An Android Service to track if any logical displays in addition to the built in display are added from the time the Service is started until 15 seconds later.
package com.mattgmg.miracastwidget;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.hardware.display.DisplayManager;
import android.os.CountDownTimer;
import android.os.IBinder;
import android.view.Display;
import android.widget.Toast;
@mattgmg1990
mattgmg1990 / .bashrc
Last active August 29, 2015 14:11
Prompts for confirmation if you ever try to push to refs/heads. Useful for pushing to Gerrit when might possibly bypass review on accident.
function git() {
if [ "$1" = push ] && [[ "$3" = *"refs/heads"* ]] ; then
echo "ARE YOU SURE YOU WANT TO PUSH TO REFS/HEADS?"
echo -n "Think hard and type uppercase YES to skip Gerrit review: "
read answer
if [ YES = "$answer" ]; then
command git "$@"
else
echo "Aborting command, push not executed."
fi