Skip to content

Instantly share code, notes, and snippets.

View megaacheyounes's full-sized avatar
turning coffee into code

Megaache Younes megaacheyounes

turning coffee into code
View GitHub Profile
@REM take screenshot on HarmonyOS Next device using HDC CLI (windows script)
@REM Requirements:
@REM 1. add hdc.exe to environment varilable (path)
@REM 2. connect watch with PC using command: hdc tconn <ip>:5555
@REM screenshots will be saved to the same folder as this script
set timestamp=%time:~0,2%_%time:~3,2%_%time:~6,2%
set spath="/data/local/tmp/harmony_screeshot_%timestamp%.jpeg"
@megaacheyounes
megaacheyounes / build.gradle
Created October 31, 2023 12:31
sample build.gradle script with dynamic APK naming and versioning
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
}
android {
compileSdk 34
@megaacheyounes
megaacheyounes / TimberTree.kt
Created October 31, 2023 12:24
Tree for Timber Android logger with persistent storage to txt file
package com.megaache.myapp.util
import android.os.Environment
import android.util.Log
import com.megaache.myapp.BuildConfig
import com.megaache.myapp.FmtApp
import timber.log.Timber
import timber.log.Timber.DebugTree
import java.io.File
import java.io.FileInputStream
@megaacheyounes
megaacheyounes / settings.gradle
Created September 18, 2023 05:23
optimized settings.gradle example
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google() {
content {
//check google repo only for google dependencies
includeGroupByRegex "com\\.google.*"
includeGroupByRegex "com\\.android.*"
includeGroupByRegex "androidx.*"
}
@megaacheyounes
megaacheyounes / starship.toml
Created April 11, 2023 11:19
terminal style for starship, save to ~/.config/starship.toml, download starship => https://starship.rs
#Younes Megaache starship terminal config
#April 11th, 2023
format = "$directory$git_branch$package$time$cmd_duration$character"
[line_break]
disabled = true
[character]
success_symbol = "[➜](bold green) "
error_symbol = "[✗](bold red) "
@megaacheyounes
megaacheyounes / tips.md
Last active November 22, 2024 15:39
HarmonyOS development tips (more tips are being added)

HarmonyOS development tips

HarmonyOS development tips

How to connect HarmonyOS device for debugging (wirelessly)

  1. Create hotspot from PC (or from your phone and connect to the hotspot from PC)
  2. On the watch, go to Settings -> WLAN and connect to hotspot
  3. On the watch,Go to Settings > About Device and tap HarmonyOS version multiple times to enable Developer Mode.
  4. On the watch, Go to Settings > developer options and enable HDC debugging
@megaacheyounes
megaacheyounes / AddCookiesInterceptor.java
Created January 4, 2023 16:22 — forked from tsuharesu/AddCookiesInterceptor.java
Handle Cookies easily with Retrofit/OkHttp
/**
* This interceptor put all the Cookies in Preferences in the Request.
* Your implementation on how to get the Preferences MAY VARY.
* <p>
* Created by tsuharesu on 4/1/15.
*/
public class AddCookiesInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
@megaacheyounes
megaacheyounes / AdBannerCompose.kt
Created September 28, 2022 10:15
Huawie banner ad using jetpack compose sample
@Composable
fun AdBannerCompose(
modifier: Modifier = Modifier,
adId: String = "testw6vs28auh3",
) {
AndroidView(
modifier = modifier.fillMaxWidth(),
factory = { context ->
BannerView(this).apply {
adId = adId
@megaacheyounes
megaacheyounes / huawei_devices_detection_demo.html
Last active March 4, 2025 09:13
Simple example showing the detection of Huawei devices using the UserAgent
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Huawei device detection using user agent</title>
</head>
<body>
<h1 id="h1">Loading...</h1>
@megaacheyounes
megaacheyounes / general.scss
Last active November 15, 2019 16:08
general css utility classes
.w-2 {
width: 2px !important;
}
.h-2 {
height: 2px !important;
}
.mar-2 {
margin: 2px !important;