Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Simon SimonDanisch

🏠
Working from home
View GitHub Profile
View README.md
julia --project=. -e "using Pkg; pkg"add RadeonProRender#sd/moah GeometryBasics RadeonProRender_jll@2.2.7"

executed with:

julia --project=. --check-bounds=(yes|no) rpr_mwe.jl

Diff of the llvm code: https://www.diffchecker.com/chE5Jtim

View video_convert.jl
using FFMPEG
function save(src::String, out::String;
framerate::Int = 24, compression = 20)
typ = splitext(out)[2]
mktempdir() do dir
if typ == ".mp4"
ffmpeg_exe(`-i $(src) -crf $compression -c:v libx264 -preset slow -r $framerate -pix_fmt yuv420p -c:a libvo_aacenc -b:a 128k -y $out`)
elseif typ == ".webm"
ffmpeg_exe(`-i $(src) -crf $compression -c:v libvpx-vp9 -threads 16 -b:v 2000k -c:a libvorbis -threads 16 -r $framerate -vf scale=iw:ih -y $out`)
elseif typ == ".gif"
View SIMD.jl
using StructArrays
using BenchmarkTools
using LoopVectorization
function juliaset2(re, im, c, maxiter)
result = re % UInt8
for i in 1:maxiter
abs = re*re + im*im
mask = abs > 4f0
result = mask & ((i - 1) % UInt8)
View jsserve_example.jl
using Hyperscript, Markdown
using JSServe, Observables
using JSServe: Session, evaljs, linkjs, div, active_sessions
using JSServe: @js_str, onjs, Button, TextField, Slider, JSString, Dependency, Asset
using WGLMakie, AbstractPlotting
markdown_css = Asset(JSServe.dependency_path("markdown.css"))
function test_handler(session, req)
button = Button("click")
View axisarrays.jl
export play
"""
play(img, timedim, t)
Slice a 3D array along axis `timedim` at time `t`.
This can be used to treat a 3D array like a video and create an image stream from it.
"""
function play(array::Array{T, 3}, timedim::Integer, t::Integer) where T
index = ntuple(dim-> dim == timedim ? t : Colon(), Val(3))
@SimonDanisch
SimonDanisch / poly.jl
Created December 2, 2019 21:07
mutating poly in place
View poly.jl
using Makie, GeometryTypes
points = decompose(Point2f0, Circle(Point2f0(0), 1f0))
points[1] ≈ points[end] # first and last are the same, so they will get removed
# lets remove it ourselves, so that we can more easily map over it!
pop!(points)
mesh = GLNormalMesh(points)
# Visualize poly
scene = Makie.mesh(mesh, shading = false)
mplot = scene[end]
# Points get converted to 3d + get one end point
View Makie_Layout.jl
using Rhea, Makie
# Vbox: left and right-most spines match, heights are distributed
# Hbox: top and bottom-most spines match, widths are distributed
# grid: rows and columns aligned
mutable struct Axis
l::variable{Float64}
t::variable{Float64}
r::variable{Float64}
View minimal_websock.jl
using Sockets
import AssetRegistry
using WebSockets
using WebSockets: is_upgrade, upgrade, writeguarded
using WebSockets: HTTP
using Hyperscript
@tags div script
@tags_noescape style
View webiobench.jl
using Interact, WebIO, Random
struct Item{NT}
data::NT
end
Item(; kw...) = Item(values(kw))
Base.getproperty(x::Item, key::Symbol) = getfield(getfield(x, :data), key)
items = map(1:170) do i
Item(
View searchmodule.jl
function searchmodule(mod, name, visited = Set())
mod in visited && return nothing
push!(visited, mod)
string(mod) == string(name) && return mod
if mod isa Module
name == nameof(mod) && return mod
for sym in names(mod)
res = searchmodule(getfield(mod, sym), name, visited)
res !== nothing && return res
end