Skip to content

Instantly share code, notes, and snippets.

@Moelf
Moelf / index.md
Last active June 10, 2023 18:30
How to efficiently cache I/O in a user-transparent way (`@threads` compatible)

Comparison

julia> includet("./tmp.jl")

julia> @time user_code(LRU_getindex);
  6.539568 seconds (840.07 k allocations: 69.739 MiB, 0.18% gc time, 1.18% compilation time: 33% of which was recompilation)

julia> @time user_code(illegal_getindex);
  3.374077 seconds (252.80 k allocations: 53.082 MiB, 2.87% compilation time: 25% of which was recompilation)
@Moelf
Moelf / A.md
Last active October 24, 2022 02:39
Limit test af.uchicago.edu Condor's scaling for analysis workload (I/O intense)

30 workers

julia> nworkers()
30

julia> pmap((x)->gethostname(), workers()) |> unique |> length
25

julia> res = @time WVZAnalysis.hist_root_pmap("Signal");
[ Info: -------------- Signal SF begin ------------ 
@Moelf
Moelf / index.md
Last active August 31, 2022 02:58
Re-use Awkward / pyarrow IPC for Julia Arrow.jl

This in principle allows one to read anything that uproot/awkward can read and represent (as long as to_arrow worked):

We use the following packages to demonstrate our round trip

julia> using PythonCall

julia> const ak = pyimport("awkward")

julia> ak.__version__
Python str: '1.9.0rc10'
@Moelf
Moelf / ONNX.jl
Created August 17, 2022 17:25
ONNX Inference in Julia
julia> using ONNX, ONNX.Ghost
julia> dummy = rand(Float32, 78, 1);
julia> model = ONNX.load("./classifier_DF.onnx", dummy);
julia> x = range(0, Float32(0.5), length=78)
0.0f0:0.0064935065f0:0.5f0
julia> result = Ghost.play!(model, x)
@Moelf
Moelf / Snowmass2022_JuliaHEP.md
Last active May 5, 2023 19:27
Snowmass2022 JuliaHEP

more links:

@Moelf
Moelf / numpy_is_absurr.md
Last active January 24, 2024 22:29
Numpy is absurd.

Numpy is absurd

HN Discussion

I always gripe about Python not having useful (i.e. performant and with adoption) built-in array type and Numpy doesn't distinguish "vector of vector" from "matrix", but this still surprised me.

in is actually intersect?

It seems that Numpy uses intersect logic to check a in b:

@Moelf
Moelf / test.jl
Created June 26, 2022 13:55
Cairo.jl hatching
using Cairo, LinearAlgebra
c = CairoRGBSurface(256,256);
cr = CairoContext(c);
save(cr);
set_source_rgb(cr,0.8,0.8,0.8); # light gray
rectangle(cr,0.0,0.0,256.0,256.0); # background
fill(cr);
restore(cr);
#= one can use these to test fastmath-like path in controlled way
@inline mul_fast(x::T, y::T) where {T<:Complex} =
T(complex(muladd(-imag(x), imag(y), real(x)*real(y)),
muladd( real(x), imag(y), imag(x)*real(y))))
@inline abs2_fast(z::Complex) = muladd(real(z), real(z), imag(z)*imag(z))
=#
function run_julia(height, width)
y = range(-1.0f0, 0.0f0; length = height)
@Moelf
Moelf / how long to beat.md
Created January 20, 2022 05:04
howlongtobeat api

https://howlongtobeat.com/

julia> get_hour("horizon zero dawn")44.0

julia> get_hour("Celeste")
8.0

julia> get_hour("Portal 2")
21.0
@Moelf
Moelf / eduroam.8021x
Created September 3, 2021 22:59
Harvard Secure and eduroam config for iwd/iwctl
[Security]
EAP-Method=TTLS
EAP-Identity=anonymous@harvard.edu
EAP-TTLS-CACert=/var/lib/iwd/usertrustrsacertificationauthority.cer
EAP-TTLS-ClientKeyBundle=/var/lib/iwd/blah.p12
EAP-TTLS-ClientKeyPassphrase=<> # your certification password
EAP-TTLS-Phase2-Method=Tunneled-PAP
EAP-TTLS-Phase2-Identity=<harvard id>@g.harvard.edu
EAP-TTLS-Phase2-Password=<> # your harvard key password