Skip to content

Instantly share code, notes, and snippets.

View ericksli's full-sized avatar

Eric Li ericksli

View GitHub Profile
@ericksli
ericksli / CustomTabUtil.kt
Created July 28, 2024 02:51
Custom Tabs warm up
package net.swiftzer.metroride.app.customtab
import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import androidx.browser.customtabs.CustomTabsCallback
import androidx.browser.customtabs.CustomTabsClient
@ericksli
ericksli / AppLocale.kt
Created January 25, 2023 05:54
Android 13 Per-app Language Preferences
package net.swiftzer.metroride.common
enum class AppLocale {
SystemDefault,
English,
Chinese,
}
@ericksli
ericksli / AdMob.kt
Created July 26, 2022 05:50
AdMob AdView in Jetpack Compose
import android.view.ViewGroup
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ericksli
ericksli / layout.xml
Last active April 10, 2021 03:28
Icon at the end of TextView with view at the end of layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<!-- Simple horizontal chain -->
@ericksli
ericksli / FeatureFlag.kt
Last active April 29, 2020 15:35
Kotlin annotation processor example
package com.example.annotation.annotation
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FUNCTION)
@MustBeDocumented
annotation class FeatureFlag(val key: String, val defaultValue: Boolean)
@ericksli
ericksli / README.md
Last active January 11, 2020 11:37
Move PNG files for Android and iOS project

movepng

Move PNG files for Android and iOS project.

Suppose you have these images exported from Avocode in ~/Downloads/test:

.
├── image_distance-hdpi.png
├── image_distance-mdpi.png
@ericksli
ericksli / adb.md
Created July 26, 2019 03:53
Android ADB enable/disable animation

Disable animation

adb shell settings put global window_animation_scale 0
adb shell settings put global transition_animation_scale 0
adb shell settings put global animator_duration_scale 0

Enable animation

@ericksli
ericksli / android-default-datetime-format.md
Last active June 11, 2019 03:52
Android default date and time formats

Android Default Date and Time Formats

Sample Timestamps

Name Timestamp (millisecond) Human-readable form
Timestamp A 1557086889000 Monday, 6 May 2019 04:08:09 GMT+08:00
Timestamp B 1571984435000 Friday, 25 October 2019 14:20:35 GMT+08:00

12-hour Format

@ericksli
ericksli / Mail merge.csv
Last active April 13, 2019 15:50
Google Apps Script mail merge
Email Name Prize Sent By Sent At
[email protected] Atlas Cantu Google Pixel 3
[email protected] Keir James Huawei Mate 20 Pro
[email protected] Rhianne Kendall Samsung Galaxy Note 9
[email protected] Lillie-Rose Hahn Sony Xperia XZ3
[email protected] Leyton Zamora LG G7 ThinQ
@ericksli
ericksli / latecert.js
Created February 10, 2019 09:31
Fill in the MTR late cert form usling puppeteer.
const puppeteer = require('puppeteer');
const readline = require('readline');
const sleep = require('util').promisify(setTimeout);
require('dotenv').config();
const EVENT_SELECTOR = 'select#ddlEvent';
const NAME_SELECTOR = 'input#username';
const EMAIL_SELECTOR = 'input#email';
const CAPTCHA_SELECTOR = 'input#captcha-form';