Skip to content

Instantly share code, notes, and snippets.

View jaguililla's full-sized avatar
🚀
Hacking Hexagon

Juanjo Aguililla jaguililla

🚀
Hacking Hexagon
View GitHub Profile
@jaguililla
jaguililla / server.main.kts
Created September 7, 2023 14:35
Kotlin (used as Python)
#!/usr/bin/env kotlin
// The next line also works
///usr/bin/env kotlin "$0" "$@" ; exit $?
// It is allowed to declare dependencies from Maven repositories
@file:DependsOn("com.hexagonkt:http_server_netty:3.1.0")
@file:DependsOn("com.hexagonkt:serialization_jackson_json:3.1.0")
import com.hexagonkt.http.server.netty.serve
import com.hexagonkt.core.logging.logger
@jaguililla
jaguililla / Scripting.java
Created September 7, 2023 14:28
Java Scripting (not JavaScripting)
///usr/bin/env java --enable-preview --source 20 -cp "*" "$0" "$@" ; exit $?
/*
* Requires flatlaf-3.2.jar on the same directory
* You can also remove '-cp "*"' from the 'shebang' and use the CLASSPATH variable instead:
* CLASSPATH="*" ./Scripting.java
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
@jaguililla
jaguililla / intellij_scripting_example.kts
Created October 4, 2021 17:39
IntelliJ scripting example
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.ui.popup.JBPopupFactory
import com.intellij.openapi.wm.ToolWindowManager
val popupFactory: JBPopupFactory = JBPopupFactory.getInstance()
val projectManager: ProjectManager = ProjectManager.getInstance()
val windowProject: Project = projectManager.openProjects[0]
#!/usr/bin/env kotlin
@file:Suppress(
"USELESS_IS_CHECK",
"FunctionName",
"PackageDirectoryMismatch",
"UnusedImport",
"unused",
"RedundantNullableReturnType",
"ReplaceManualRangeWithIndicesCalls",