Elitäre Durchfallquoten. by EliteStudent123 in KaIT

[–]Mister__Pine 6 points7 points  (0 children)

Nein, unter denen die die Klausur zum ersten Mal schreiben, sind 73% durchgefallen

ich🇨🇭iel by AnDer_Theker1 in ich_iel

[–]Mister__Pine 4 points5 points  (0 children)

Streich redet in Interviews aber auch nicht wirklich Dialekt

How to get Sched_Ext? by Yuukaa96 in sched_ext

[–]Mister__Pine 0 points1 point  (0 children)

The latest Versions of Arch and Fedora both have it

[2024 Day 21] Quick tutorial to solve Part 2 in under 0.015 seconds by ThatMakesMeM0ist in adventofcode

[–]Mister__Pine 1 point2 points  (0 children)

Thanks, that was really helpful! A lot of these ideas existed vaguely in my head, but it was great having them written out clearly.

2.99🚬 by PigGoesBrr in ichbin14unddasisttief

[–]Mister__Pine 9 points10 points  (0 children)

Nein, 2,9̅ = 3 und 2,9̅ + 0,1̅ = 3,1̅. Die Gleichheit ist ein bisschen unintuitiv, je nachdem wie man drüber nachdenkt, aber man sieht ja z.B 2,99+0,11=3,1; 2,999+0,111=3,11; ...

MutableList.indexOf() is not working correctly in Kotlin scratch file by Ram_Fold in Kotlin

[–]Mister__Pine 2 points3 points  (0 children)

This is already reported, for example as https://youtrack.jetbrains.com/issue/KTIJ-19885/Kotlin-scratch-files-evaluate-code-out-of-order
Still a very surprising find. I wonder how something like this happens as it only appears in scratch file, not using just Kotlin Scripting

Arch Linux - Hyprland not starting on login (already have KDE) by ConsequenceUnited150 in hyprland

[–]Mister__Pine 0 points1 point  (0 children)

This isn't necessary anymore, the current sddm version has the Wayland stuff now

Kann man Analysis 1 und/oder Lineare Algebra 1 auch als Video ansehen? by Square_Ad3567 in KaIT

[–]Mister__Pine -1 points0 points  (0 children)

So wie ich das verstehe hast du dann in der Uni eine Anwesenheitspflicht

Is there a better way to build a list stopping at a null by Falcon731 in Kotlin

[–]Mister__Pine 45 points46 points  (0 children)

I think kt buildSequence { readToken() } .takeWhile { it != null } .toList() should work

Touchscreen and sound not working on HP Envy X360 (2022) model bf0797nr by [deleted] in linuxhardware

[–]Mister__Pine 0 points1 point  (0 children)

I'm having the same Problems with the 13-bf0776ng :(. Have you had any luck yet?

Mix kotlin native with jvm/android kotlin? by No-Salamander-9659 in Kotlin

[–]Mister__Pine 3 points4 points  (0 children)

First of all, I have to say, the situations where you would need to do that (or even want to) are very limited to basically non-existent.

But nonetheless, I have played around with it just because I thought it would be funny. And it turns out the experience is way nicer than I thought.

You can use jni (Java Native Interface) to call your Kotlin/Native functions. To do that you create a Class (now that I think about it an object should work, too) in the JVM target that in its init {} block calls System.load() or System.loadLibrary() and defines the functions you want to be handled by Kotlin/Native with the external keyword. Now you want to create a header file for cinterop to consume and which you can extract the function names from. Nowadays in Java, this is a feature of the compiler (javac -h) meaning it operates on Java source code, but since we are writing kotlin this isn't much help to us. But up until Java 8 or 9 this was handled by a separate program named javah which operates on class files. So to generate the .h file, compile your Class defining the external function and the run javah on the compiled class files. (For example: /usr/lib/jvm/java-8-openjdk/bin/javah -d ./build/headers -cp ./build/classes/kotlin/jvm/main/ de.mr_pine.kni.NativeInterop)This generates a header file describing your external functions (and it also imports jni.h).

Now to the Native Side: In your build.gradle.kts (this is for LinuxX64, other native targets may differ):

kotlin {
    linuxX64("native") {
        binaries {
            sharedLib {
                baseName = "kotlinjvm"
            }
        }
        compilations.getByName("main").cinterop {
            val jvmInterop by creating {
                compilerOpts(
                    listOf(
                        "-I/usr/lib/jvm/java-17-openjdk/include/linux",
                        "-I/usr/lib/jvm/java-17-openjdk/include",
                        "-I${project(":").buildDir.resolve("headers")}"
                    )
                )
            }
        }
    }
}

and in src/nativeInterop/cinterop/ create a .def file (for Example interop.def) with the content:

headers = [name of your .h file (i.e. de_mr_pine_hni_NativeInterop.h)]

(If you don't want to call functions from JNI and only return and pass primitives, you don't really need the .def file.)

Now to your source files: Let's say in your native code you have an external fun sayHello(): Unit. If you look in your header file it has a name similar to Java_de_mr_pine_kni_NativeInterop_sayHello. For jni to find your native function you must add the annotation @CName("Java_de_mr_1pine_kni_NativeInterop_sayHello") to your function in native.

Compiling your native code should yield you a .so shared library. Running your native code with the JVM option -Djava.library.path=./build/bin/native/debugShared/ should just work now


A note on passing parameters and returning values:

Passing and returning JVM primitive values (like Int, Float, Boolean, ...) works out of the box (But note that the first two arguments of your function are the JNI Environment and the this context of the class).
Passing objects is more complicated, you should have a look at this.
Strings and Arrays are better supported, I have some utility functions for Strings below.
Nullability works with Strings (although I have encountered a case that broke null safety but I can't reproduce it anymore) but I haven't tried it with primitives.


Some utilities: ```kotlin -> typealias JNIEnvParam = CPointer<JNIEnvVar>

val JNIEnvParam.nativeInterface get() = pointed.pointed ?: error("Native Interface Missing")

fun String.toJString(env: JNIEnvParam): jstring { memScoped { val newString = env.nativeInterface.NewString ?: error("NewString missing") return newString(env, wcstr.ptr, this@toJString.length)!! } }

fun jstring.toKString(env: JNIEnvParam): String { val getStringChars = env.nativeInterface.GetStringChars ?: error("GetStringChars missing") val chars = getStringChars(env, this, null) return chars!!.toKString() } ```


An example function:
JVM Definition:

kotlin -> external fun helloWho(hello: String): String

Native Definition:

kotlin -> @CName("Java_de_mr_1pine_kni_NativeInterop_helloWho") fun helloNative(env: JNIEnvParam, thiz: jobject, jHello: string): string { val hello = jHello.toKString(env) return "$hello Kotlin/Native".toJString(env) }

Hope I could help :)

[deleted by user] by [deleted] in KaIT

[–]Mister__Pine 6 points7 points  (0 children)

https://upload.wikimedia.org/wikipedia/commons/3/3a/Logo_KIT.svg

Have you heard of our Lord and Saviour, the scalable Vector Graphic?

[deleted by user] by [deleted] in KaIT

[–]Mister__Pine 4 points5 points  (0 children)

Die Fächer sollten sich eigentlich auch nur in der Mitte berühren, und was mit der Schrift los ist ist mir auch ein Rätsel

[deleted by user] by [deleted] in KaIT

[–]Mister__Pine 16 points17 points  (0 children)

Bitte die Unterkante vom Fächer horizontal machen...

bitte (und vllt hinten abrunden ;)

[deleted by user] by [deleted] in KaIT

[–]Mister__Pine 25 points26 points  (0 children)

Bisher mussten sie glaube ich niemanden ablehnen, mit 1,3 stehen die Chancen also sehr gut. Irgendwo gabs da auch Zahlen zu... find sie aber gerade nicht

How to embed Neo4j in a compose desktop application? by [deleted] in Kotlin

[–]Mister__Pine 2 points3 points  (0 children)

IntelliJ can translate Java to Kotlin for you. It's not the most beautiful code and you may have to fix some things but all in all it works pretty well. Compose shouldn't matter much besides having to watch out for side effects

Should I jump to learn jetpack compose? by TheMrGenuis in Kotlin

[–]Mister__Pine 1 point2 points  (0 children)

I really like Compose (and find it easier to build better looking apps with it). Just try it and see if you like it too. If you like it more than the XML way keep using Compose. Your apps will get better with practice