Skip to content

Instantly share code, notes, and snippets.

View sureshg's full-sized avatar
🚀
☕️

Suresh sureshg

🚀
☕️
View GitHub Profile
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 June 6, 2024 05:03
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
@Hakky54
Hakky54 / cheat_sheet_http_client_ssl_configuration_for_java_kotlin_scala.md
Last active August 18, 2022 11:56
Cheat Sheet - Http Client SSL TLS Configuration for Java Kotlin and Scala with example http requests
@eygraber
eygraber / GatherDependenciesTask.kt
Last active October 5, 2024 03:24
Initial exploration of a configuration cache compatible way of collecting dependencies in Gradle (Heavily borrowed from https://github.com/google/play-services-plugins/blob/master/oss-licenses-plugin/src/main/groovy/com/google/android/gms/oss/licenses/plugin/LicensesTask.groovy)
import org.gradle.api.DefaultTask
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ConfigurationContainer
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.artifacts.result.ResolvedArtifactResult
import org.gradle.api.artifacts.result.UnresolvedArtifactResult
@DevSrSouza
DevSrSouza / GtkTheme.kt
Created July 4, 2021 19:00
Compose for Desktop get and listen to Gtk Dark/Light Theme changes
// implementation("org.zeroturnaround:zt-exec:1.12") LIBRARY USAGED
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import kotlin.coroutines.resume
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.flow
@bric3
bric3 / IsATTY.java
Created June 8, 2021 15:42
Allows to determine if standard stream are connected to a terminal. Calls native isatty C function, and dynamically build the wrapper code.
/*
* MIT License
*
* Copyright (c) 2021 Brice Dutheil <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@petrbouda
petrbouda / HttpInvocation.java
Last active June 22, 2024 19:00
Retry Mechanism for JDK HTTP Client
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandler;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;