Skip to content

Instantly share code, notes, and snippets.

View gpeal's full-sized avatar

Gabriel Peal gpeal

View GitHub Profile
@gpeal
gpeal / s1-metrics-collector.sh
Created March 9, 2023 22:41
SentinelOne metrics collector
sentinelctl metrics enable ; sentinelctl metrics dump > /tmp/metrics.json ; count=0 ; while :; do clear; sentinelctl metrics dump > /tmp/metrics-tmp.log ; if grep -q "no metrics available" /tmp/metrics-tmp.log; then echo "Metrics Disabled" ; exit ; fi ; if [ $count = 0 ]; then echo "Starting Metrics Collection" ; count=$((count + 10)) ; else echo "Metrics have been collected for $count seconds" ; count=$((count + 10)) ; fi ; sleep 3 ; diff -u /tmp/metrics.json /tmp/metrics-tmp.log > /tmp/metrics-new.patch ; patch /tmp/metrics.json /tmp/metrics-new.patch ; sleep 3 ; echo "Collecting Metrics & writing to /tmp/metrics.json" ; sleep 4 ; done
export {};
export type PropertyValue<TValue> = TValue extends Array<infer AValue>
? Array<AValue extends infer TUnpacked & {} ? TUnpacked : AValue>
: TValue extends infer TUnpacked & {}
? TUnpacked
: TValue;
export type Fallback<T> = { [P in keyof T]: T[P] | NonNullable<T[P]>[] };
class GuidedWorkoutFragment : TonalFragment(R.layout.guided_workout_fragment) {
override val daggerComponent: GuidedWorkoutMergeComponent by fragmentComponent { scope, app ->
app.bindings<GuidedWorkoutMergeComponent.Parent>().guidedWorkoutComponentBuilder()
.coroutineScope(WorkoutCoroutineScope(scope))
.args(arg)
.build()
}
}
@gpeal
gpeal / ContributesApiCodeGenerator.kt
Last active February 12, 2024 20:10
Anvil Code Generator
package com.tonal.trainer.anvilcompilers
import com.google.auto.service.AutoService
import com.squareup.anvil.annotations.ContributesTo
import com.squareup.anvil.compiler.api.AnvilContext
import com.squareup.anvil.compiler.api.CodeGenerator
import com.squareup.anvil.compiler.api.GeneratedFile
import com.squareup.anvil.compiler.api.createGeneratedFile
import com.squareup.anvil.compiler.internal.asClassName
import com.squareup.anvil.compiler.internal.buildFile
@gpeal
gpeal / Simple.kt
Created March 5, 2022 23:45
Anvil Simple Use Case
@Singleton
class LocationProvider @Inject constructor() {
suspend fun currentLocation(): Pair<Float, Float> = 123.456f to 789.012f
}
class WeatherApi @Inject constructor() {
suspend fun getWeather(latLng: Pair<Float, Float>): Float = 72f
}
class WeatherUseCase @Inject constructor(
private val locationProvider: LocationProvider,
private val weatherApi: WeatherApi,
import com.sun.tools.javac.resources.CompilerProperties
import javax.swing.text.View
data class WorkoutDetailsState(
val workout: Async<Workout> = Uninitialized,
) : MavericksState {
}
class WorkoutDetailsViewModel @Inject constructor(
@Assisted initialState: WorkoutState,
implementation "com.airbnb.android:lottie-compose:4.0.0"
val anim = rememberLottieAnimatable()
LaunchedEffect(composition) {
anim.animate(
composition,
iterations = LottieConstants.IterateForever,
)
}
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.heart))
val progress by animateLottieCompositionAsState(
composition,
iterations = LottieConstants.IterateForever,
)
LottieAnimation(
composition,
progress,
)
LottieAnimation(
composition,
progress,
)