Skip to content

Instantly share code, notes, and snippets.

@cies
cies / gradle_snippet.kt
Created May 31, 2023 10:02
Make Gradle print its task plan
// This prints the dependencies of each task in the current execution graph
gradle.taskGraph.whenReady(
closureOf<TaskExecutionGraph> {
println("About to run ${allTasks.size} tasks: (use `-i` to see why tasks are skipped, use `--rerun-tasks` to prevent UP-TO-DATE checks)")
allTasks.forEachIndexed { i, task ->
val dependenciesString =
if (task.dependsOn.isEmpty()) {
""
} else {
task.dependsOn.joinToString(", ", " (depends on ", ")") { dependency ->
@mertceyhan
mertceyhan / TypewriterTextEffect.kt
Created May 8, 2023 13:54
TypewriterTextEffect: A customizable Jetpack Compose function that reveals text with a typewriter-like effect, one chunk at a time
/**
* A composable function that displays a text with a typewriter-like effect, revealing characters in chunks.
*
* @param text The input text to be displayed with the typewriter effect.
* @param minDelayInMillis The minimum delay in milliseconds between revealing character chunks, defaults to 10ms.
* @param maxDelayInMillis The maximum delay in milliseconds between revealing character chunks, defaults to 50ms.
* @param minCharacterChunk The minimum number of characters to reveal at once, defaults to 1.
* @param maxCharacterChunk The maximum number of characters to reveal at once, defaults to 5.
* @param onEffectCompleted A callback function invoked when the entire text has been revealed.
* @param displayTextComposable A composable function that receives the text to display with the typewriter effect.
import org.kodein.di.DirectDIAware
import org.kodein.di.instance
/**
* Auto resolve a class dependencies by using its constructor reference.
* The resolution is done at compile time by leveraging inline functions, no reflection is required.
*
* Example:
* ```
* val myModule = DI.module("myModule") {
@greeflas
greeflas / install-toolbox.sh
Last active March 29, 2024 07:53
JetBrains Toolbox installation script for Ubuntu - https://www.jetbrains.com/toolbox/app/
#!/bin/bash
set -e
if [ -d ~/.local/share/JetBrains/Toolbox ]; then
echo "JetBrains Toolbox is already installed!"
exit 0
fi
echo "Start installation..."
fun main(args: Array<String>) {
if (args[0] == "start") {
launch(CommonPool) {
println("Launching")
SerialisationHelper.test()
println("Finished")
}
}
@ssfang
ssfang / TypeSignature.java
Last active May 3, 2023 15:37
Java VM Type Signatures
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
/**
* <h2>Type Signatures</h2><br/>
* The JNI uses the Java VM’s representation of type signatures. Table 3-2 shows
* these type signatures.
* <p/>
* Table 3-2 Java VM Type Signatures
*
@johnkil
johnkil / JTarUtils.java
Created December 20, 2012 12:59
Implementation of two versions of the utilities to decompress tar.gz archives (apache tar & jtar).
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;
import org.xeustechnologies.jtar.TarEntry;
import org.xeustechnologies.jtar.TarInputStream;
@ah01
ah01 / gist:762576
Last active April 29, 2021 14:10
const.pde
//
// This sketch will print some of interesting predefined constants to Serial.
//
// For more information, look at
// http://electronics4dogs.blogspot.com/2011/01/arduino-predefined-constants.html
// helper macro
#define LINE(name,val) Serial.print(name); Serial.print("\t"); Serial.println(val);
void setup()