Skip to content

Instantly share code, notes, and snippets.

Avatar

Philipp Hanslovsky hanslovsky

View GitHub Profile
@hanslovsky
hanslovsky / ambiguous_calls.kt
Last active Aug 9, 2020
kotlin ambiguous overloads test
View ambiguous_calls.kt
import net.imglib2.*
import net.imglib2.img.Img
import net.imglib2.img.array.ArrayImgs
interface _A
interface _B
interface _AB: _A, _B
interface _BA: _B, _A
View hello.kt
const val BEST = "PAH"
val String?.better: String
get() = BEST
fun main(vararg args: String) {
val name = args.firstOrNull()
println("Hello, ${name.better}!")
}
@hanslovsky
hanslovsky / for-lobbel.py
Created May 24, 2020
midi dump with python
View for-lobbel.py
import mido
import sys
for idx, track in enumerate(mido.MidiFile(sys.argv[1]).tracks):
print(f'Track {idx}: {track.name}')
for msg in track:
print(f' {msg}')
@hanslovsky
hanslovsky / rn-exif-date.kts
Created Apr 25, 2020
Add date prefix to image files based on EXIF data
View rn-exif-date.kts
#!/usr/bin/env kscript
@file:DependsOn("com.drewnoakes:metadata-extractor:2.13.0")
@file:DependsOn("org.apache.commons:commons-lang3:3.10")
@file:DependsOn("info.picocli:picocli:4.2.0")
import java.io.File
import java.nio.file.CopyOption
import java.nio.file.StandardCopyOption
import java.nio.file.Files
@hanslovsky
hanslovsky / n5-tree.kts
Last active Mar 25, 2020
script to list all groups and dataset within n5 container
View n5-tree.kts
#!/usr/bin/env kscript
@file:MavenRepository("imagej.public", "https://maven.imagej.net/content/groups/public")
@file:DependsOn("org.janelia.saalfeldlab:n5:2.1.0")
@file:DependsOn("info.picocli:picocli:4.2.0")
@file:DependsOn("ch.qos.logback:logback-classic:1.3.0-alpha5")
import java.util.concurrent.Callable
import org.janelia.saalfeldlab.n5.N5FSReader
View move-kotlin-files.sh
#!/usr/bin/env bash
ROOT_DIR="$HOME/workspace/paintera/paintera"
JAVA_SRC="$ROOT_DIR/src/main/java"
KOTLIN_SRC="$ROOT_DIR/src/main/kotlin"
cd $JAVA_SRC
FILES=$(find . -type f -name '*kt')
@hanslovsky
hanslovsky / cachged-image-example.kts
Created Jan 30, 2020
kscript example for how to create ImgLib2 cached cell images and show them in BDV
View cachged-image-example.kts
#!/usr/bin/env kscript
@file:MavenRepository("scijava.public", "https://maven.scijava.org/content/groups/public")
@file:DependsOn("sc.fiji:bigdataviewer-vistools:1.0.0-beta-11")
import kotlin.math.pow
import bdv.util.BdvFunctions
import bdv.util.volatiles.VolatileViews
import net.imglib2.Localizable
@hanslovsky
hanslovsky / error-message
Created Dec 17, 2019
syrnchronizing cell img access generation both on java and python
View error-message
Traceback (most recent call last):
File "jnius/jnius_proxy.pxi", line 156, in jnius.invoke0
Access is null, returning!
File "jnius/jnius_proxy.pxi", line 124, in jnius.py_invoke0
AttributeError: 'dict' object has no attribute 'invoke'
Traceback (most recent call last):
Access is null, returning!
File "jnius/jnius_proxy.pxi", line 156, in jnius.invoke0
File "jnius/jnius_proxy.pxi", line 124, in jnius.py_invoke0
AttributeError: 'dict' object has no attribute 'invoke'
@hanslovsky
hanslovsky / pyimagej-qt.py
Last active Dec 16, 2019
pyimagej-from-qt-thread
View pyimagej-qt.py
import time
def main():
import threading
ij = [None]
def start_qt_and_ij():
from PyQt5 import QtCore, QtWidgets
app = QtWidgets.QApplication([])
View count-locked-voxels.groovy
import java.util.concurrent.Executors
import javafx.application.Platform
import javafx.util.Duration
import net.imglib2.algorithm.util.Grids
import net.imglib2.util.Intervals
import net.imglib2.view.Views
import org.janelia.saalfeldlab.paintera.state.LabelSourceState
import org.janelia.saalfeldlab.paintera.state.label.ConnectomicsLabelState
You can’t perform that action at this time.