Skip to content

Instantly share code, notes, and snippets.

View sphrak's full-sized avatar
🐱
hax

Niclas sphrak

🐱
hax
  • Stockholm, Sverige
  • 05:22 (UTC +01:00)
View GitHub Profile
@sphrak
sphrak / DeviceComponent.kt
Created June 16, 2023 08:01
dagger2 desktop jvm
@DeviceScope
@Component(
modules = [
DeviceModule::class
],
dependencies = [
// shared dependencies
AppComponent::class
]
)
@sphrak
sphrak / pihole.md
Last active March 30, 2023 18:27
pihole

Deploy pihole in docker

  • pull
  • tear down
  • re-deploys pihole

Requirements

  • requires root to execute if docker daemon runs as root
@sphrak
sphrak / ColoredShadow.kt
Created January 25, 2023 15:38 — forked from tasjapr/ColoredShadow.kt
Draw a colored shadow in Android Jetpack Compose
/*
Copyright 2020 Cedric Kring.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@sphrak
sphrak / gstreamer.md
Last active January 10, 2023 18:43
gstreamer commands

http streaming

authorized flac/mp3 streaming command with 50% vol

./Library/Frameworks/GStreamer.framework/Versions/1.0/bin/gst-launch-1.0 souphttpsrc location="https://example.tld/v1/stream/YjEyMDA1NDAtYzNlZS00NmQ2LTg2OTEtOTlkMjAyYjU2NGIy" extra-headers="test, Authorization=(string)\"<ACCESS_TOKEN>\"" ! decodebin ! audioconvert ! audioresample ! volume volume=0.5 ! autoaudiosink
import android.graphics.Matrix
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.infiniteRepeatable
import androidx.compose.animation.core.rememberInfiniteTransition
import androidx.compose.animation.core.tween
@sphrak
sphrak / MessageService.kt
Last active January 6, 2023 14:03
ktor websocket flow retry mechanism
@Serialized
data class MessageDto(
@SerialName(value = "id")
val id: String,
@SerialName(value = "message")
val message: String
)
class MessageService constructor(
private val httpClient: HttpClient
@sphrak
sphrak / .editorconfig
Created December 24, 2022 23:26
ktlint
[*.{kt,kts}]
# possible values: number (e.g. 2), "unset" (makes ktlint ignore indentation completely)
indent_size=4
# true (recommended) / false
insert_final_newline=false
# possible values: number (e.g. 120) (package name, imports & comments are ignored), "off"
# it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide)
max_line_length=off
ktlint_standard_no-empty-first-line-in-method-block=disabled
ktlint_standard_trailing-comma-on-declaration-site=disabled
@sphrak
sphrak / blender.md
Last active August 14, 2022 15:25
blender cheatsheet

keys

move objects

hit g then move freely -- or combine with z, x or y to move along respective axis

deleting objects

hit x

@sphrak
sphrak / 0-sqlite-pagination.md
Last active August 20, 2022 23:43
sqlite3 stable cursor pagination with uuid's

sqlite3 stable pagination with uuid

based on https://morningcoffee.io/stable-pagination.html.

In order for this to work I had to use uuidgen -t to generate time-based uuids otherwise the ordering would be messed up after 2-3 pages in.

create db

sqlite3 pagination.db
@sphrak
sphrak / ParallaxScreen.kt
Created May 28, 2022 11:32 — forked from surajsau/ParallaxScreen.kt
Parallax effect with Jetpack Compose
@Composable
fun ParallaxScreen(modifier: Modifier = Modifier) {
val context = LocalContext.current
val scope = rememberCoroutineScope()
var data by remember { mutableStateOf<SensorData?>(null) }
DisposableEffect(Unit) {
val dataManager = SensorDataManager(context)
dataManager.init()