Skip to content

Instantly share code, notes, and snippets.

View diewland's full-sized avatar
🧩
Jigsaw Fam

diewland.eth diewland

🧩
Jigsaw Fam
View GitHub Profile
@diewland
diewland / requirements.txt
Created May 11, 2023 10:55
Query unclaim fee from UniswapV3 pool
aiohttp==3.8.3
aiosignal==1.3.1
async-timeout==4.0.2
attrs==22.2.0
base58==2.1.1
bitarray==2.6.2
certifi==2022.12.7
charset-normalizer==2.1.1
cytoolz==0.12.1
eth-abi==2.2.0
@diewland
diewland / HoldersOdyssey.csv
Created May 6, 2023 03:44
Holders Odyssey from @ArbnowDEX
We can't make this file beautiful and searchable because it's too large.
0x42543853a72EDb6f1FF9bddAB0cf4676187EC28a,
0xDcFD37eB9Db906528a8e750DA2d3270aDfc9DdCF,
0x00409fC839a2Ec2e6d12305423d37Cd011279C09,
0xE9748aC6c9D88719BD160DeF338e7bC520Fa9afa,
0xaA6e200d3552c1b1E8e0B7E925fb734c194f7Ebc,
0x9Ef4074529Cf8214f0AcF2eB8d3E9487747F9273,
0x2c83a7387684133F86c76b4719876d70e86100F4,
0x3e4F4DEe05C6B2f42704A3a713d4Ae4A084Ed8Ed,
0x762ae8d504Adb01A50D6d0b7acE52fbA786f9B09,
0x974A60bf964232c88625C9cd843f3C972e77841F,
@diewland
diewland / winner.sh
Last active August 12, 2022 17:35
shuffle list to find the winner
# shuffle to tmp file
shuf $1 -o $1.tmp
# shuffle 16 times
for (( i=1; i<=16; i++ )); do
shuf $1.tmp -o $1.tmp
done
# last shuffle and show winner
shuf $1.tmp -n 1
@diewland
diewland / calc_seed_size.js
Created July 14, 2022 16:02
Calculate seed size
let count_seed = (word_size, seed_size) => {
if (seed_size == 1) return word_size;
return word_size * count_seed(word_size-1, seed_size-1);
}
console.log('seed size 12', '=>', count_seed(2048, 12).toLocaleString());
console.log('seed size 24', '=>', count_seed(2048, 24).toLocaleString());
// seed size 12 => 5,271,537,971,301,488,400,000,000,000,000,000,000,000
// seed size 24 => 25,892,008,055,647,378,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000
@diewland
diewland / sleep_8bit.kt
Created May 5, 2021 08:32
Sleep in 8-bit style
fun sleep8bit (second: Int, width: Int=10, callback: (String)->Unit) {
val d = (second * 1000 / width ).toLong()
(1..width).forEach {
Thread.sleep(d)
val progress = "[${"#".repeat(it)}${" ".repeat(width-it)}]"
callback(progress)
}
}
@diewland
diewland / LoopBlockingWithoutFreeze.kt
Last active March 25, 2021 08:33
Loop heavy blocking process without UI freeze
fun main() {
val h = Handler(Looper.getMainLooper())
GlobalScope.launch(Dispatchers.Main) {
(1..5).forEach { proc(it, h) }
}
h.removeCallbacksAndMessages(null)
}
suspend fun proc(no: Int, h: Handler): Boolean = suspendCoroutine {
h.post {
@diewland
diewland / run-kitkat-app-on-android-11.md
Last active April 27, 2022 08:39
Run Kitkat app on Android 11

Run Kitkat app on Android 11

add 2 properties to in Manifest file

android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"

build.gradle (app) set targetSdkVersion to 29

@diewland
diewland / TempSetting.kt
Last active May 20, 2020 06:47
Parse nested json object to data class
import com.alibaba.fastjson.JSON
data class Setting (
val title: String,
val info: List<TimeRange>
)
data class TimeRange (
val from: String,
val to: String,
val temp: Int
@diewland
diewland / ReadLine.kt
Created April 15, 2020 15:55
Utility class for read line
class ReadLine {
private val EOL = listOf(
13.toByte(), // CR
10.toByte() // LR
)
private val EOL_SIZE = EOL.size
private val MSG_MAX_LENGTH = 99
private var line = byteArrayOf()
@diewland
diewland / SuUtil.kt
Last active December 6, 2023 12:00
Execute su commands for android ( root required )
package com.diewland.installmanager.util
import android.util.Log
import java.io.BufferedReader
import java.io.DataOutputStream
import java.io.InputStreamReader
object SuUtil {
private const val TAG = "SU_UTIL"