Skip to content

Instantly share code, notes, and snippets.

View Sal7one's full-sized avatar
Probably making my 7th cup of Coffee

Saleh Alanazi Sal7one

Probably making my 7th cup of Coffee
View GitHub Profile
@Sal7one
Sal7one / download.sh
Last active June 9, 2025 03:24
Locally download all your repos.. don't forget to chmod x+ this
#!/bin/bash
# ==== User Configuration ====
GITHUB_USERNAME="your_github_username"
GITHUB_TOKEN="your_github_token"
PER_PAGE=100
GITHUB_API_URL="https://api.github.com"
DEST_DIR="./github_repos"
@Sal7one
Sal7one / test.kt
Created December 6, 2024 00:33
Roboelctric compose example
package com.sal7one.testingrobo
import android.app.Application
import android.content.pm.ActivityInfo
import androidx.activity.ComponentActivity
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.core.app.ApplicationProvider
@Sal7one
Sal7one / tabbedRow.kt
Last active July 24, 2024 06:21
TabbedRow
package com.example.salscomposecomponents
inline fun <R : Any> R.applyWhen(
condition: Boolean,
block: R.() -> R,
): R = applyChoice(condition = condition, trueBlock = block, falseBlock = { this })
inline fun <R : Any> R.applyChoice(
condition: Boolean,
trueBlock: R.() -> R,
@Sal7one
Sal7one / handlersCompose.kt
Created June 23, 2024 07:58
It's the weekend and I miss handlers :]
package com.sal7one.handler
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.os.Message
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
@Sal7one
Sal7one / README.md
Created May 27, 2024 15:44 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@Sal7one
Sal7one / ComposeWavesSimilarToFlag.kt
Last active May 10, 2024 14:05
Waves in canvas compose
val otherColors = listOf(
// Color(0xffffffff),
Color(0xff125B34),
)
@Composable
fun CubicWaves() {
var angle by remember { mutableFloatStateOf(0f) }
val cols = 50
@Sal7one
Sal7one / HeartShape.kt
Created May 5, 2024 07:00
Animated heart jetpack compose, with gaps
// infinite with gap of 1
@Composable
fun AnimatedHeartShapeRaw(
brush: Brush = Brush.verticalGradient(colors = listOf(Color.Magenta, Color.Magenta)), // Default gradient from Magenta to Blue
) {
val animationPercentage = remember { Animatable(0f) } // Animation state from 0 to 1
LaunchedEffect(Unit) {
animationPercentage.animateTo(
@Sal7one
Sal7one / ExpandedButtonCompose.kt
Last active April 21, 2024 16:52
Menu button scale expand something something compose kotlin
// Original idea by https://twitter.com/raffichill/status/1781492309500027206
// Tried to make it vanilla as possible
@Composable
fun EditMenu() {
var isExpanded by remember {
mutableStateOf(false)
}
val scale by animateFloatAsState(
@Sal7one
Sal7one / AssistedInjectionHilt.kt
Last active February 27, 2024 21:23
Assisted Injection with hilt Helper code - I think it's dumb and a bad practice but here's the code anyways :)
// Raw hilt viewmodel
@HiltViewModel
class SomeViewModel @Inject constructor(
private val repository: Repo // Injected from hilt
) : ViewModel() {
}
// Let's pass any var we want for example an int that we pass when we create the viewmodel
class MainActivity : AppCompatActivity() {
private val secretUserNum = Random().nextInt(100) + 1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById<TextView>(R.id.actualPass).text = "Actual pass $secretUserNum "