Skip to content

Instantly share code, notes, and snippets.

View sureshg's full-sized avatar
🚀
☕️

Suresh sureshg

🚀
☕️
View GitHub Profile
void main() {
var s = """
void main() {
var s = %c%c%c
%s%c%c%c;
IO.print(String.format(s, 34, 34, 34, s, 34, 34, 34));
}""";
IO.print(String.format(s, 34, 34, 34, s, 34, 34, 34));
}
@lbialy
lbialy / yield.scala
Created September 19, 2025 14:13
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
@nomisRev
nomisRev / LocalPortRouting.kt
Created August 29, 2025 11:34
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 = {
@basyliq
basyliq / gohugo_bsky_comments.md
Last active July 7, 2025 17:08
Integrate Bluesky replies as your blog's comment section in gohugo.io framework

Layout: layouts/_default/single.html

<div id="comments-section" data-bsky-uri="{{ .Params.bsky }}"></div>
{{ $comments := resources.Get "js/comments.js" }}
<script src="{{ $comments.RelPermalink }}"></script>
@aSemy
aSemy / kotlin_native_c_compile.md
Created January 23, 2024 14:45
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
addEventListener("fetch", e => {
if (e.request.destination !== "image" || // Only do this when requesting an image
request.mode === "no-cors") // We don't know the status of no-cors images
return;
e.respondWith((async () => {
try {
const response = await fetch(e.request);
if (response.ok)
return response;

Float precision

Source:

double x = 0.2F;

Fernflower:

double x = 0.20000000298023224D;
@mcpiroman
mcpiroman / build.gradle.kts
Last active November 16, 2025 11:15
Compose for Desktop with Proguard setup
import org.jetbrains.compose.compose
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
buildscript {
dependencies {
classpath("com.guardsquare:proguard-gradle:7.2.1")
}
}
repositories {
import RickRoll.writer
object RickRoll { var writer: (String) -> Unit = { println(it) } }
val Never = RickAstleyNever // to get different highlighting color
object RickAstleyNever {
infix fun gonna(x: give) = give
infix fun gonna(x: let) = let
infix fun gonna(x: run) = run
infix fun gonna(x: make) = make
infix fun gonna(x: say) = say
@thomasdarimont
thomasdarimont / quine.jshell.md
Created December 2, 2021 17:47
Simple JShell Quine
var s=%1$s%2$s%1$s;printf(s,(char)34,s);/exit";printf(s,(char)34,s);/exit