Skip to content

Instantly share code, notes, and snippets.

View mlagerberg's full-sized avatar

Mathijs Lagerberg mlagerberg

View GitHub Profile
@mlagerberg
mlagerberg / record.py
Created August 30, 2022 11:57
Android ADB Record touch events as a macro
#!/usr/bin/env python3
import subprocess
import sys
import time
#
# Usage:
# python record_taps.py /dev/input/event3 output_file.sh
# Find out your input event name by running:
# adb shell getevent -lp
@mlagerberg
mlagerberg / adb.sh
Last active November 21, 2017 09:12
[ADB control script that simplifies working with multiple devices] #android #adb
#!/bin/bash
# Get list of only the device identifiers
# 1 list devices
# 2 grep away the line 'list of devices'
# 3 grep away newline at the end
# 4 cut off everything but the first part (identifier)
ALL=`adb devices -l`
#LIST=`adb devices | grep -v devices | grep device | cut -f1`
LIST=`echo "$ALL" | grep -v devices | grep device | awk '{print $1}'`
@mlagerberg
mlagerberg / rpi-install-lite.sh
Last active April 28, 2019 00:50
[rpi-install-lite] Installs common stuff on a fresh Raspbian installation, without user input #rpi
#!/bin/bash
############################################################################
#
# Installs and configures many things useful for a fresh Rasbian install.
# All things configured are described in this repo:
# https://github.com/mlagerberg/raspberry-pi-setup
# A more complete version of this script (that requires user input) can
# be found here: https://gist.github.com/mlagerberg/df0e433f984b4c3595f7
#
# Created by Mathijs Lagerberg, 2017
@mlagerberg
mlagerberg / Jenkinsfile
Last active July 4, 2018 14:39
[Common build.gradle stuff.] Adds Lint, Findbugs, Checkstyle and PMD, uses release config keys from global properties, adds debug icon overlay, etc. #android #gradle
node('android') {
stage('Checkout') {
checkout scm
}
stage('Build') {
try {
@mlagerberg
mlagerberg / backup_rsync.sh
Last active September 10, 2017 22:54
[backup.sh] Bash script, uses rsync to back up directory to another drive and keeps 3 incremental backups #bash #pi
#!/bin/bash
# Runs a backup of /media/hdd/BTSync to /media/backup/,
# incremental, keeping the last 3 versions.
# Sources:
# rsync and hard links: http://www.mikerubel.org/computers/rsync_snapshots/#Rsync
# rsync progress: http://www.cyberciti.biz/faq/show-progress-during-file-transfer/
# human readable time: http://www.daveeddy.com/2014/06/29/human-readable-duration-in-bash/
human() {
local seconds=$1
@mlagerberg
mlagerberg / DottedLine.java
Last active February 20, 2021 11:04
[Vertical dotted line view] #android
package com.pixplicity.gist.ui.views;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PathDashPathEffect;
import android.util.AttributeSet;
@mlagerberg
mlagerberg / WebFragment.java
Last active August 17, 2018 15:40
[WebFragment] Fragment with WebView, busy indicator, custom user-agent, and correct fallback when offline. SDK 9 and up #android
package com.github.gist.monkeyinmysoup;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.net.ConnectivityManager;
import android.net.Uri;
@mlagerberg
mlagerberg / backup.sh
Last active September 10, 2017 22:55
[My Pi scripts] #rpi
#!/bin/bash
# ___ CREDITS
# This script is a modification of
# https://github.com/aweijnitz/pi_backup/blob/master/backup.sh
# which started from
# http://raspberrypi.stackexchange.com/questions/5427/can-a-raspberry-pi-be-used-to-create-a-backup-of-itself
# which in turn started from
# http://www.raspberrypi.org/phpBB3/viewtopic.php?p=136912
#
@mlagerberg
mlagerberg / rpi-install.sh
Last active September 10, 2017 22:56
[rpi-install.sh] Installs and configures many things useful for a fresh Rasbian install #rpi #bash
#!/bin/bash
############################################################################
#
# Installs and configures many things useful for a fresh Rasbian install.
# All things configured are described in this repo:
# https://github.com/mlagerberg/raspberry-pi-setup
#
# Created by Mathijs Lagerberg, 2015
#
# It does NOT:
@mlagerberg
mlagerberg / AndroidManifest.xml
Last active September 10, 2017 22:56
[Google Now shortcut] Add Android app as a replacement for the Google Now shortcut (swipe up on home button) #android
<activity ... >
<intent-filter>
<action android:name="android.intent.action.ASSIST"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<meta-data
android:name="com.android.systemui.action_assist_icon"
android:resource="@drawable/ic_assist"
/>
</activity>