Skip to content

Instantly share code, notes, and snippets.

View emmaguy's full-sized avatar

Emma Vanbrabant emmaguy

View GitHub Profile
@emmaguy
emmaguy / textcolor-stats.kts
Created February 17, 2020 12:41
Look at all Android layout files and collate what value is set for 'android:textColor' and count the usages of each
val textColorsUsed = mutableMapOf<String, Int>()
File("../").walkTopDown().forEach { file ->
if (file.isFile && file.extension == "xml" && file.path.contains("res/layout")) {
val builder: DocumentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder()
val xmlInput = InputSource(StringReader(file.readText()))
val doc: Document = builder.parse(xmlInput)
val androidViews = XPathFactory.newInstance()
.newXPath()
@emmaguy
emmaguy / AndroidManifest.xml
Created February 1, 2020 14:01
Click the 'Skip Intro' button on the Android notification from the Netflix app
<service
android:name=".NotificationService"
android:label="@string/notification_service_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
Process: com.emmaguy.sampleapp, PID: 3053
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.emmaguy.sampleapp/com.emmaguy.sampleapp.MainActivity}: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter $receiver
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)

Keybase proof

I hereby claim:

  • I am emmaguy on github.
  • I am emmav (https://keybase.io/emmav) on keybase.
  • I have a public key ASD8wnfUrFUUxFBAjOv7NTEXc_2OAxTkTJqOH0LIl0awMwo

To claim this, I am signing this object:

import android.os.Build
public fun supportsKitKat(code:() -> Unit){
supportsVersion(code, 19)
}
public fun supportsLollipop(code:() -> Unit){
supportsVersion(code, 21)
}
@emmaguy
emmaguy / gist:28d91fddf5c9a0d0c434
Last active August 29, 2015 14:28
RxJava debug
RxJavaPlugins.getInstance().registerObservableExecutionHook(new DebugHook(new DebugNotificationListener() {
public Object onNext(DebugNotification n) {
Timber.v("onNext on " + n);
return super.onNext(n);
}
public Object start(DebugNotification n) {
Timber.v("start on " + n);
return super.start(n);
}
@emmaguy
emmaguy / gist:75e53f4bf980c4f4dfec
Created April 15, 2015 18:51
battery historian
adb shell dumpsys batterystats --enable full-wake-history
adb shell dumpsys batterystats > battery.txt
./historian.py battery.txt > out.html
@emmaguy
emmaguy / Provider.java
Last active August 29, 2015 14:05
Debug builds (inc content provider) side by side with release
public static final String AUTHORITY = BuildConfig.PACKAGE_NAME + ".provider";
@emmaguy
emmaguy / gist:81f87b3ceb0721aa509e
Last active July 17, 2020 00:43
SeekBarWithIntervals
public class SeekBarWithIntervals extends LinearLayout {
private LinearLayout mLinearLayout = null;
private SeekBar mSeekBar = null;
private int WidthMeasureSpec = 0;
private int HeightMeasureSpec = 0;
public SeekBarWithIntervals(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
@emmaguy
emmaguy / gist:5517492
Last active December 16, 2015 23:59
Useful git commands
git rm --cached `git ls-files -i --exclude-from=.gitignore` >> When updating a .gitignore, remove stuff that's previously added
git diff HEAD^ HEAD >> diff last commit with the version before it
git push origin :abc >> delete remote branch abc
git branch -d abc >> delete local branch abc
git push <origin> <branch name> -- push up new branch
git submodule update --init --recursive
git stash show -p stash@{0} -- diff against stash