Skip to content

Instantly share code, notes, and snippets.

View sureshg's full-sized avatar
🚀
☕️

Suresh sureshg

🚀
☕️
View GitHub Profile
@sureshg
sureshg / ktor-app.main.kts
Last active November 4, 2025 19:47
Ktor App Kotlin Script
#!/usr/bin/env -S kotlin -Xplugin=/opt/homebrew/opt/kotlin/libexec/lib/kotlin-serialization-compiler-plugin.jar
@file:DependsOn("io.ktor:ktor-server-core-jvm:3.3.1")
@file:DependsOn("io.ktor:ktor-server-jetty-jakarta-jvm:3.3.1")
@file:DependsOn("io.ktor:ktor-server-servlet-jakarta-jvm:3.3.1")
@file:DependsOn("io.ktor:ktor-serialization-kotlinx-json-jvm:3.3.1")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
@file:DependsOn("ch.qos.logback:logback-classic:1.5.12")
@file:CompilerOptions("-jvm-target", "21")
@sureshg
sureshg / yield.scala
Created October 1, 2025 08:49 — forked from lbialy/yield.scala
Different thread yielding techniques with Loom
//> using scala 3.7.3
//> using dep com.softwaremill.ox::core:1.0.0
import scala.concurrent.duration.*
import java.time.Instant
import ox.*
import scala.util.boundary
import java.util.ArrayList
import java.util.concurrent.locks.LockSupport
@sureshg
sureshg / LocalPortRouting.kt
Created August 30, 2025 04:33 — forked from nomisRev/LocalPortRouting.kt
Example of splitting up your services across different ports within the same Ktor service
package org.jetbrains.demo
import io.ktor.server.application.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
fun main() {
embeddedServer(Netty, configure = {
@sureshg
sureshg / amper-trace.jsonl
Created August 8, 2025 04:40
amper-trace.jsonl
This file has been truncated, but you can view the full file.
{"resourceSpans":[{"resource":{"attributes":[{"key":"host.arch","value":{"stringValue":"aarch64"}},{"key":"os.type","value":{"stringValue":"Mac OS X"}},{"key":"os.version","value":{"stringValue":"15.5"}},{"key":"service.instance.id","value":{"stringValue":"ab814328-7f99-4a93-a3a0-0eec9f60dc47"}},{"key":"service.name","value":{"stringValue":"Amper"}},{"key":"service.namespace","value":{"stringValue":"org.jetbrains.amper"}},{"key":"service.version","value":{"stringValue":"0.8.0-dev-3078"}},{"key":"telemetry.sdk.language","value":{"stringValue":"java"}},{"key":"telemetry.sdk.name","value":{"stringValue":"opentelemetry"}},{"key":"telemetry.sdk.version","value":{"stringValue":"1.50.0"}}]},"scopeSpans":[{"scope":{"name":"org.jetbrains.amper.telemetry","attributes":[]},"spans":[{"traceId":"0299868cc90426bd8b92acbb079c9ffa","spanId":"6608b921b48291e7","parentSpanId":"3b1be2d9afd95352","name":"JVM startup","kind":1,"startTimeUnixNano":"1754611508891394000","endTimeUnixNano":"1754611509268394000","attributes":[],"event
@sureshg
sureshg / kotlin_native_c_compile.md
Created December 18, 2024 01:43 — forked from aSemy/kotlin_native_c_compile.md
Compile C libraries for Kotlin/Native

Kotlin/Native requires that C libraries are compiled with a specific verison of GCC.

You can use the GCC used by Kotlin/Native itself. These Gradle tasks will help with this.

Example usage

// build.gradle.kts
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
@sureshg
sureshg / index.http
Created July 20, 2023 03:55 — forked from linux-china/index.http
Run Llama-2-13B-chat RESTful server locally on your M1/M2/Intel Mac with GPU inference.
### Llama 2 Chat
POST http://127.0.0.1:8080/completion
Content-Type: application/json
{
"prompt": "What is Java Language?",
"temperature": 0.7
}
### Llama 2 tokenize
@sureshg
sureshg / FFMCrash.java
Created May 9, 2023 01:19
FFM API crash
#!/usr/bin/env java --enable-preview --enable-native-access=ALL-UNNAMED --source 21
import java.lang.foreign.*;
import java.lang.foreign.MemoryLayout.PathElement;
import java.lang.invoke.MethodHandle;
public class FFMCrash {
static Linker LINKER = Linker.nativeLinker();
static SymbolLookup loaderLookup = SymbolLookup.loaderLookup();
@sureshg
sureshg / vega_lite.json
Last active April 26, 2023 22:45
Vegalite Viz for cpu/memory usage
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"description": "A dual axis chart, created by setting y's scale resolution to `\"independent\"`",
"width": 400,
"height": 300,
"data": {
"values": [
{
"process": "java",
"time": "2023-04-27 00:00:00",
@sureshg
sureshg / GituhubActionEnv.kt
Created November 11, 2022 03:01
Github Action Envs
fun main() {
"""
CI=Always set to true.
GITHUB_ACTION=The name of the action currently running, or the id of a step. For example, for an action, __repo-owner_name-of-action-repo. GitHub removes special characters, and uses the name __run when the current step runs a script without an id. If you use the same script or action more than once in the same job, the name will include a suffix that consists of the sequence number preceded by an underscore. For example, the first script you run will have the name __run, and the second script will be named __run_2. Similarly, the second invocation of actions/checkout will be actionscheckout2.
GITHUB_ACTION_PATH=The path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action. For example, /home/runner/work/_actions/repo-owner/name-of-action-repo/v1.
GITHUB_ACTION_REPOSITORY=For a step executing an action, this is the owner and repository name of the action. Fo
@sureshg
sureshg / renew-gpgkey.md
Created June 10, 2022 16:58 — forked from krisleech/renew-gpgkey.md
Renew Expired GPG key

Renew GPG key

Given that your key has expired.

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date: