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 February 12, 2023 19:53
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
@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 <brice.dutheil@gmail.com>
*
* 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 December 4, 2023 10:56
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;
@normanmaurer
normanmaurer / Http3Server.java
Created December 1, 2020 09:28
Http3Server on top of netty
/*
* Copyright 2020 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software