Instantly share code, notes, and snippets.
- Capital One
- United States
- https://hanslovsky.github.io/
- @hanslovsky
hanslovsky /test.jpg
Last activeJune 6, 2024 07:14

hanslovsky /recompress.kts
Last activeFebruary 21, 2023 03:57
Recompress zarr array inplace using n5-zarr. Untested, use at own risk. Does not deal with non-existing blocks. Not multi-threaded. Run with kscript:https://github.com/kscripting/kscript This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
@file:Repository("https://maven.scijava.org/content/groups/public") | |
@file:DependsOn("org.janelia.saalfeldlab:n5-zarr:0.0.8") | |
importkotlin.math.ceil | |
importorg.janelia.saalfeldlab.n5.zarr.N5ZarrWriter | |
importorg.janelia.saalfeldlab.n5.zarr.ZArrayAttributes | |
importorg.janelia.saalfeldlab.n5.zarr.ZarrCompressor | |
require(args.size==2) {"Two arguments required, zarr group and dataset"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[packages] | |
numba ="~=0.55" | |
matplotlib ="~=3.5" | |
[requires] | |
python_version ="3.9" |
hanslovsky /ConcordeLib.kt
Last activeJuly 2, 2022 21:33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
packageme.hanslovsky.konkorde | |
importcom.sun.jna.Library | |
importcom.sun.jna.Memory | |
importcom.sun.jna.Native | |
importcom.sun.jna.Pointer | |
importcom.sun.jna.Structure | |
interfaceConcordeLib :Library { |
hanslovsky /extension-func-resolution.kt
CreatedMarch 30, 2022 20:10
Exploring how kotlin extension functions are resolved This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
interfaceBase<T:Base<T>> | |
interfaceDerived<T:Derived<T>> :Base<T> | |
classImpl:Derived<Impl> | |
data classContainer<T>(valt:T) | |
@JvmName("f1") | |
fun <T:Base<T>> Container<T>.someFunc(c:Container<T>)= | |
println("generic:$c") | |
@JvmName("f2") | |
funContainer<outDerived<*>>.someFunc(c:Container<outDerived<*>>)= |
hanslovsky /Pipfile
CreatedNovember 2, 2021 13:19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[[source]] | |
url ="https://pypi.org/simple" | |
verify_ssl =true | |
name ="pypi" | |
[packages] | |
imglyb ="~=2.0" | |
jupyter ="~=1.0" | |
matplotlib ="~=3.4" | |
pillow ="~=8.4" |
hanslovsky /numpy-cacheloader.kts
Last activeJune 9, 2021 03:01
Example use case for using Jep to generate numpy arrays in CacheLoader This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
#!/usr/bin/env kscript | |
// requires kscript: https://github.com/holgerbrandl/kscript | |
// install jep native libraries with | |
// python -m pip install jep | |
// When using Python interpreter in a a non-standard location, set PYTHONHOME appropriately. | |
@file:MavenRepository("scijava","https://maven.scijava.org/content/groups/public") | |
@file:DependsOn("net.imglib2:imglib2-cache:1.0.0-beta-16") | |
@file:DependsOn("net.imglib2:imglib2:5.12.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
importjava.lang.Class | |
importjava.lang.Thread | |
importjava.util.concurrent.Callable | |
importjava.util.concurrent.ExecutorService | |
importjava.util.concurrent.Executors | |
importjep.Interpreter | |
importjep.SharedInterpreter | |
classThreadsafeInterpreter2( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.9 | |
fromfunctoolsimportreduce | |
frompathlibimportPath | |
fromsubprocessimportcheck_output | |
importre | |
m2_repo=Path.home()/'.m2'/'repository' |
hanslovsky /example-kotlin-repl.kts
Last activeMarch 15, 2021 02:46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
importnet.imglib2.imklib.* | |
importnet.imglib2.type.volatiles.* | |
importnet.imglib2.type.numeric.integer.* | |
// pick any data here | |
val rawData= imklib.io.n5.openUntypedHDF5("/home/zottel/Downloads/sample_A_20160501.hdf","volumes/raw").asUnsignedBytes() | |
val rawDataExtended= rawData.extendBorder().asInts() | |
val gradientMagnitudeData= (0..2) | |
.map { d->LongArray(3) {if (it== d)1else0 } } | |
.map { rawDataExtended[rawData+ it].zeroMin- rawDataExtended[rawData- it].zeroMin } |
NewerOlder