Skip to content

Instantly share code, notes, and snippets.

View eric100lin's full-sized avatar

Eric Lin (Tzu Hsiang Lin) eric100lin

  • Taiwan
  • 10:52 (UTC +08:00)
View GitHub Profile
@eric100lin
eric100lin / build.gradle
Created October 24, 2018 07:13
Gradle task to parse xml of Android JUnit test result(connectedAndroidTest) and generate a csv with mapping owner
task collectResults() {
doLast {
def ownerTable = new XmlSlurper().parse(file("owners.xml"))
def output = file("summary.csv")
output.text = '"Owner","Result","Test","Duration","Command"\r\n'
allprojects.each { project_x ->
println "Processing project ${project_x.name}"
def resultFiles = project_x.fileTree("build") { include '**/TEST-*.xml' }
resultFiles.each { file ->
println "Processing report ${file}"
@eric100lin
eric100lin / Makefile
Created October 24, 2018 07:23
A Makefile to parse each row of space-delimited file
all:
ifeq "$(PARSE_FILE)" "true"
@while read crc sym module export; do \
#echo "=> '{$$sym,$$crc}' <="; \
done < Module.symvers
endif
@eric100lin
eric100lin / play_and_stop_youtube.bat
Last active November 23, 2022 03:17
ADB command to play Youtube video then stop on Android device
am start -a android.intent.action.VIEW -d https://www.youtube.com/watch?v=iu10TkjDFxA
am force-stop com.google.android.youtube.tv
@eric100lin
eric100lin / debug_android_instrument.bat
Created October 24, 2018 11:26
Debug Android instrument test code
adb shell am instrument -w -r -e debug true com.your.package_name.test/android.support.test.runner.AndroidJUnitRunner
gradlew.bat connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.debug=true --continue
@eric100lin
eric100lin / Android.mk
Last active December 14, 2020 06:02
Define a custom Android SDK addon with java sources, aidl, JNI part and droiddoc
LOCAL_PATH := $(call my-dir)
# ============================================================
# Build the library
# ============================================================
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(call all-java-files-under,src) \
$(call all-subdir-Iaidl-files)
LOCAL_AIDL_INCLUDES += $(LOCAL_PATH)/src/
@eric100lin
eric100lin / generate_coverage.sh
Created November 8, 2018 14:55
Collect gcov runtime data
# Execute tar_gcda_results.sh
sh tar_gcda_results.sh
# Untar gcda results
tar zxvf kernel_part_gcda.tar.gz -C /
tar zxvf non_kernel_part_gcda.tar.gz -C /
# Process coverage info
lcov --capture --rc lcov_branch_coverage=1 --directory $OBJ_PATH --output-file coverage.info
genhtml coverage.info --rc lcov_branch_coverage=1 --output-directory out_html
* HeidiSQL: database viewer
https://www.heidisql.com/
* DevManView: detail properties of all devices
https://www.nirsoft.net/utils/device_manager_view.html
* Online Json Viewer
http://jsonviewer.stack.hu
* Online XPath Generator
https://xmltoolbox.appspot.com/xpath_generator.html
* Online Hex editor tool
https://hex-works.com/eng
@eric100lin
eric100lin / test_commands.bat
Last active June 25, 2019 04:14
Android Gradle Plugin 3.4.1 with Gradle 5.1.1 connectedAndroidTest
REM Gradle 5.1.1 https:/services.gradle.org/distributions/gradle-5.1.1-all.zip
REM Android Gradle Plugin 'com.android.tools.build:gradle:3.4.1'
REM 1. Gradle 5.1.1 change project property command options
REM need to use '-P KEY=VALUE' or '--project-prop KEY=VALUE' instead of '-PKEY=VALUE'
REM Android Gradle Plugin DSL: https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.ProductFlavor.html#com.android.build.gradle.internal.dsl.ProductFlavor:testInstrumentationRunnerArguments
REM 2. Use 'notClass' to skip test cases OR use 'class' to run specific test cases
REM 3. The 'tee' command exist in Windows PowerShell
powershell ".\gradlew.bat --info --continue \
--project-prop android.testInstrumentationRunnerArguments.notClass=com.example.myapplication#useAppContext \
connectedAndroidTest 2>&1 | tee log.txt"
@eric100lin
eric100lin / About Powershell.exe
Last active December 16, 2019 13:38
some tip about Windows Commands
https://blog.darkthread.net/blog/powershell-learning-notes/
*Important!! First time to run powershell, you need to Set-ExecutionPolicy if .ps1 is not signed
On a 64-bit OS you need to run Set-ExecutionPolicy for 32-bit and 64-bit PowerShell separately
Set-ExecutionPolicy RemoteSigned
Get-ExecutionPolicy
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
This will set the execution policy for the current user (stored in HKEY_CURRENT_USER) rather than the local machine (HKEY_LOCAL_MACHINE).
This is useful if you don't have administrative control over the computer.
*Create full path to ".\dummyfile" and overwrite it if exist
New-Item -Path ".\dummyfile" -ItemType File -ErrorAction Ignore -Force
@eric100lin
eric100lin / find_median.py
Last active July 31, 2019 08:47
find median of two sorted arrays
# From: https://www.geeksforgeeks.org/median-two-sorted-arrays-different-sizes-ologminn-m/
# def to find median of two sorted arrays
def findMedianSortedArrays(A, len_A, B, len_B):
median = 0
index_in_A = 0
index_in_B = 0
min_index = 0
max_index = len_A
half_length = (len_A + len_B + 1) // 2