Skip to content

Instantly share code, notes, and snippets.

@shakalaca
shakalaca / gist:39849ad02f92b26335ccd21aff991a89
Created March 30, 2021 23:15
Patch for 64bit magisk build
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 802e8972..cabd0452 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -70,23 +70,23 @@ android {
val syncLibs by tasks.registering(Sync::class) {
into("src/main/jniLibs")
- into("armeabi-v7a") {
+ into("arm64-v8a") {
@shakalaca
shakalaca / gist:9410e9678d6679dfbc5fe88fa90bed97
Created February 19, 2021 08:52
Mount & df on Android S emulator
console:/ # df
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 1014480 1020 1013460 1% /dev
tmpfs 1014480 0 1014480 0% /mnt
/dev/block/vdd1 11248 132 11116 2% /metadata
/dev/block/dm-4 766572 764240 2332 100% /
/dev/block/dm-3 149204 148748 456 100% /vendor
/dev/block/dm-2 1466760 1462368 4392 100% /product
/dev/block/dm-1 175596 175068 528 100% /system_ext
tmpfs 1014480 12 1014468 1% /apex
@shakalaca
shakalaca / patch.diff
Created August 6, 2020 16:30
Fix 403 limit exceeded error
diff --git a/app/src/main/java/com/example/android/codelabs/paging/data/GithubRepository.kt b/app/src/main/java/com/example/android/codelabs/paging/data/GithubRepository.kt
index 81b3b8d..7529c8a 100644
--- a/app/src/main/java/com/example/android/codelabs/paging/data/GithubRepository.kt
+++ b/app/src/main/java/com/example/android/codelabs/paging/data/GithubRepository.kt
@@ -42,7 +42,7 @@ class GithubRepository(
// appending '%' so we can allow other characters to be before and after the query string
val dbQuery = "%${query.replace(' ', '%')}%"
- val pagingSourceFactory = { database.reposDao().reposByName(dbQuery) }
+ val pagingSourceFactory = { database.reposDao().reposByIdx(dbQuery) }
@shakalaca
shakalaca / gist:32198097ba4ba4f402ceafb284ea28f1
Created August 6, 2020 16:14
實際上 PagingState.data 的內容 (對應 RemoteKeys)
+---------+--------------+---------+
| prev: 0 | repo 001 | next: 2 |
+---------+--------------+---------+
| prev: 1 | repo 087 | next: 3 |
+---------+--------------+---------+
| prev: 0 | repo 002 | next: 2 |
+---------+--------------+---------+
...
+---------+--------------+---------+
| prev: 1 | repo 056 | next: 3 |
@shakalaca
shakalaca / gist:a68e0e9249477d11521695ade285fc3e
Last active August 6, 2020 16:15
理想中 PagingState.data (對應到 RemoteKeys) 內容,prev 為上一頁,next 為下一頁。
+---------+--------------+---------+
| prev: 0 | repo 001 | next: 2 |
+---------+--------------+---------+
| prev: 0 | repo 002 | next: 2 |
+---------+--------------+---------+
| prev: 0 | repo 003 | next: 2 |
+---------+--------------+---------+
...
+---------+--------------+---------+
| prev: 0 | repo 048 | next: 2 |
interface RepoDao {
@Query("SELECT * FROM repos WHERE " +
"name LIKE :queryString OR description LIKE :queryString " +
"ORDER BY stars DESC, name ASC")
fun reposByName(queryString: String): PagingSource<Int, Repo>
}
class GithubRepository {
fun getSearchResultStream(query: String): Flow<PagingData<Repo>> {
val dbQuery = "%${query.replace(' ', '%')}%"
val pagingSourceFactory = { database.reposDao().reposByName(dbQuery)}
return Pager(
config = PagingConfig(pageSize = NETWORK_PAGE_SIZE, enablePlaceholders = false),
remoteMediator = GithubRemoteMediator(query, service, database),
pagingSourceFactory = pagingSourceFactory
).flow
interface GithubService {
/**
* Get repos ordered by stars.
*/
@GET("search/repositories?sort=stars")
suspend fun searchRepos(
@Query("q") query: String,
@Query("page") page: Int,
@Query("per_page") itemsPerPage: Int
): RepoSearchResponse
diff --git a/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt b/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt
index 16ac44a..61d77ca 100644
--- a/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt
+++ b/app/src/main/java/com/example/android/codelabs/paging/ui/SearchRepositoriesViewModel.kt
@@ -55,7 +55,11 @@ class SearchRepositoriesViewModel(private val repository: GithubRepository) : Vi
if (before == null) {
// we're at the beginning of the list
- return@insertSeparators UiModel.SeparatorItem("${after.roundedStarCount}0.000+ stars")
+ if (after.roundedStarCount >= 1) {
* Download magisk.zip and unzip
* Rename x86/magiskboot to x86/magiskboot.real
* Add x86/magiskboot
* Add x86/mboot (https://github.com/shakalaca/MagiskOnIntelDevices/raw/master/mboot)
* ZIP and update from MagiskManager custom channel (modify https://raw.githubusercontent.com/topjohnwu/magisk_files/canary/debug.json)