Skip to content

Instantly share code, notes, and snippets.

View Foso's full-sized avatar
👨‍💻
Break stuff, fix stuff

Jens Klingenberg Foso

👨‍💻
Break stuff, fix stuff
View GitHub Profile
@Foso
Foso / qasegherking.user.js
Created November 12, 2021 10:26
add syntax highlighting to Qase
// ==UserScript==
// @name Qase Gherkin
// @version 0.1
// @description add syntax highlighting to Qase
// @author github.com/foso
// @match https://app.qase.io/run/*
// @match https://app.qase.io/case/*
// @match https://app.qase.io/project/APP20*
// @icon https://qase.io/favicon.png
// @grant none
import androidx.compose.desktop.AppWindow
import androidx.compose.foundation.Text
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Button
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import java.awt.BorderLayout
import javax.swing.JButton
import javax.swing.JLabel
import javax.swing.JPanel
/**
* A [PreviewParameterProvider] that combines two providers. The output will be a [Pair] containing
* both Results
*/
open class PreviewParameterCombiner<T, U>(
private val provider: Pair<PreviewParameterProvider<T>, PreviewParameterProvider<U>>
) : PreviewParameterProvider<Pair<T, U>> {
override val values: Sequence<Pair<T, U>>
get() = provider.first.values.flatMap { first ->
provider.second.values.map { second ->
@Foso
Foso / ComposableDumper.kt
Created August 17, 2020 19:51 — forked from zach-klippenstein/ComposableDumper.kt
Simple utility to dump the current Composition tree to logcat.
import android.util.Log
import androidx.compose.runtime.Composable
import androidx.compose.runtime.currentComposer
import androidx.compose.runtime.remember
import androidx.compose.ui.unit.IntBounds
import androidx.ui.tooling.CallGroup
import androidx.ui.tooling.Group
import androidx.ui.tooling.NodeGroup
import androidx.ui.tooling.asTree
@Foso
Foso / gist:f254410ba99722101b000e03181c4f45
Created June 24, 2020 20:51
KotlinJs get entries from Dict<T>
fun entriesOf(jsObject: dynamic): List<Pair<String, Any?>> =
(js("Object.entries") as (dynamic) -> Array<Array<Any?>>)
.invoke(jsObject)
.map { entry -> entry[0] as String to entry[1] }
fun mapEntriesOf(jsObject: dynamic): Map<String, Any?> =
entriesOf(jsObject).toMap()
val c = Class.forName("de.jensklingenberg.jetpackcomposeplayground.ui.samples.mysamples.other.CounterModelKt")
val m = c.getDeclaredMethod("CounterModelDemo")
m.invoke(null)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.ui.tooling.preview.ComposeViewAdapter
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@Composable
fun TextView(text: String) {
val context = +ambient(ContextAmbient)
Text(text)
}
@Composable
fun SimpleTextView(){
@Foso
Foso / MpAptTestProcessor.kt
Last active October 11, 2019 20:30
MpApt find @JsName
package de.jensklingenberg
import de.jensklingenberg.mpapt.common.simpleName
import de.jensklingenberg.mpapt.model.AbstractProcessor
import de.jensklingenberg.mpapt.model.Element
import de.jensklingenberg.mpapt.model.RoundEnvironment
import de.jensklingenberg.mpapt.utils.KotlinPlatformValues
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.TargetPlatform
@Foso
Foso / gist:092caab594578c8cd894016c7f24867d
Created December 3, 2018 19:08
How to link your own app settings in Androids App Info Page
<activity
android:name="SettingsActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>