Skip to content

Instantly share code, notes, and snippets.

View mgbckr's full-sized avatar

Martin Becker mgbckr

View GitHub Profile
@mgbckr
mgbckr / pull_database_from_android.bash
Last active March 2, 2018 13:48
Small set of commands to download a database file (or any file) from an android device using `adb`
./adb shell
run-as the.package.of.the.application
cd /data/data/dthe.package.of.the.application/databases
chmod 777 TheDatabase.db
cp TheDatabase.db /mnt/sdcard/
./adb pull /mnt/sdcard/TheDatabase.db
@mgbckr
mgbckr / extract_hr_from_polar_csv.py
Created March 2, 2018 11:29
A little function to extract heart rates with absolute timestamps from Polar CSV files
def extract_hr_from_polar_csv(filename):
# read header and data
h = pd.read_csv(filename, nrows=2)
d = pd.read_csv(filename, skiprows=2)
# parse start time
datetime_string = h["Date"].values[0] + " " + h["Start time"].values[0]
starttime = datetime.strptime(datetime_string, '%d-%m-%Y %H:%M:%S')
#!/bin/bash
#
# colorpages_printstring.bash
#
# Tool to print only color pages from a PDF (duplex).
# Generates a string to be used for common printing dialogs which only contains pages (back and front) with color.
#
# usage: colorpages_printstring <your>.pdf
#
# requirements: ghostscript (gs)
@mgbckr
mgbckr / rpi3led.py
Last active June 1, 2017 08:14
Python 2 class for blinking the onboard ACT LED on the Raspberry PI 3
#/usr/bin/python -p
import time
import subprocess
import threading
"""
This is a class for blinking the onboard ACT LED on the Raspberry PI 3 based on
shell commands. There should be a way to do this via GPIO, but for me it did not
work so far. Here are some relevant links for blinking via GPIO:
* https://kofler.info/on-board-leds-des-raspberry-pi-steuern/
#!/bin/bash
# A small script for labelling music files (mp3) with their BPMs via filename.
#
# requires
# * bpm-tools
# * libsox-fmt-mp3
#
# usage:
#
# # get BPM of a file labels
@mgbckr
mgbckr / AccessFileOnClasspath
Last active July 14, 2018 12:55
Resource access in Maven projects.
/**
* <p>Shows how files in the class path can be accessed when using the standard
* Maven directory layout.</p>
*
* <p>The test file is "src/test/resources/accessFileOnClasspath/test.txt".
* It is accessed using either {@link ClassLoader#getResource(String)} or
* {@link ClassLoader#getResourceAsStream(String)}. Note that the file's
* path is always relative to the class path's root. Thus the test file is
* accessed using "accessFileOnClasspath/test.txt".</p>
*
@mgbckr
mgbckr / IntegerValueOf
Created August 2, 2012 21:04
Always be careful to compare Objects using Object.equals(Object): Integer.valueOf(int) caches common values.
import junit.framework.Assert;
import org.junit.Test;
public class IntegerValueOf {
@Test
public void test() {