Skip to content

Instantly share code, notes, and snippets.

@sephiroth74
sephiroth74 / MyTest.java
Created May 31, 2017 15:34
android instrumentationTest grant permissions
@RunWith(AndroidJUnit4.class)
@LargeTest
public class MyTest {
@Before
public void grantPhonePermission() {
// In M+, trying to call a number will trigger a runtime dialog. Make sure
// the permission is granted before running this test.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getInstrumentation().getUiAutomation().executeShellCommand(
"pm grant " + getTargetContext().getPackageName()
# Copyright 2012 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
@sephiroth74
sephiroth74 / find-unused-layouts.sh
Created July 3, 2019 10:10
Android find unused layouts
for f in `find . -iname "*.xml" | grep src/main/res/layout`; do echo $f ; git grep --count -e "R\.layout\.$(basename $f .xml)\W" --or -e "@layout/$(basename $f .xml)\W" | wc -l ; done | grep -B1 "0$"
@sephiroth74
sephiroth74 / git pretty stat
Last active April 17, 2024 22:23
Show lines added/deleted and total commits per author in a period of time on all branches
git log --all --numstat --pretty="%H" --author="author" --since=1.year | awk 'NF==3 {plus+=$1; minus+=$2} NF==1 {total++} END {printf("lines added: +%d\nlines deleted: -%d\ntotal commits: %d\n", plus, minus, total)}'