Skip to content

Instantly share code, notes, and snippets.

@STQT
STQT / dump.py
Last active May 14, 2025 10:43
Tiktok search example
import time, uiautomator2 as u2
def dump_ui(device: str = None):
d = u2.connect(device)
d.app_start("com.zhiliaoapp.musically")
d.wait_activity("com.ss.android.ugc.aweme.splash.SplashActivity", timeout=20)
d(description="Discover").wait(timeout=10).click()
xml = d.dump_hierarchy() # получаем строку XML
with open("ui_dump.xml", "w", encoding="utf-8") as f:
f.write(xml)
@STQT
STQT / main.py
Created February 15, 2024 07:29
Вероятность попадания числа 41 по указанному вероятностью
import random
import unittest
def random_with_probability(prob_41):
numbers = list(range(1, 100 + 1))
weights = [prob_41 if num == 41 else (1 - prob_41) / (100 - 1) for num in numbers]
choice = random.choices(numbers, weights=weights, k=1)
return choice[0]

This is Dart Lessons