Skip to content

Instantly share code, notes, and snippets.

View SimonDanisch's full-sized avatar
🏠
Working from home

Simon SimonDanisch

🏠
Working from home
View GitHub Profile
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}
using Sockets
import AssetRegistry
using WebSockets
using WebSockets: is_upgrade, upgrade, writeguarded
using WebSockets: HTTP
using Hyperscript
@tags div script
@tags_noescape style
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(
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
# load test image
using Makie
using AbstractPlotting: limits
# The data
"""
Very simple resampling of an index range
"""
function resample(range)
using WebSockets, WebIO, Colors, ImageMagick
using CSSUtil
using ImageFiltering, JSExpr
using Base64, FixedPointNumbers
using ImageTransformations, CSSUtil
# using the string macro since for loops + ifs seem to make problems
const redraw = js"""
function redraw(context, brushsize, rect, drawtext){
context.clearRect(0, 0, rect.height, rect.width); // Clears the canvas
context.beginPath();
using Colors, FixedPointNumbers
const DWORD = Culong
const LONG = Clong
const WORD = Cushort
const CIEXYZTRIPLE = NTuple{3, XYZ{Float32}}
struct BITMAPV5HEADER
bV5Size::DWORD
bV5Width::LONG
bV5Height::LONG
AbstractPlotting.set_theme!() # reset theme
function lorenz(t0, a, b, c, h)
Point3f0(
t0[1] + h * a * (t0[2] - t0[1]),
t0[2] + h * (t0[1] * (b - t0[3]) - t0[2]),
t0[3] + h * (t0[1] * t0[2] - c * t0[3]),
)
end
# step through the `time`
function lorenz(array::Vector, a = 5.0 ,b = 2.0, c = 6.0, d = 0.01)
base = dirname(Base.find_source_file("sysimg.jl"))
file = "/home/sd/Desktop/precompile.jl" # snippet from slack
cd(homedir() * "/Desktop")
filebase = homedir() * "/Desktop/sysimg"
mkdir(filebase)
cd(base)
run(`julia1 --output-ji $filebase/corecompiler.ji --startup-file=no -g0 -O0 compiler/compiler.jl`)
run(`julia1 -g1 -O0 -C "native" --output-ji $filebase/sys.ji --startup-file=no --warn-overwrite=yes --sysimage $filebase/corecompiler.ji sysimg.jl`)
run(`julia1 -O3 -C "native" --output-o $filebase/sys.a --startup-file=no --warn-overwrite=yes --sysimage $filebase/sys.ji $file`)
pkg"add FixedPointNumbers"
using WebSockets, WebIO, Colors, ImageMagick
using CSSUtil
using ImageFiltering, JSExpr
using Base64, FixedPointNumbers
using ImageTransformations
# using the string macro since for loops + ifs seem to make problems
const redraw = js"""
function redraw(context, brushsize, rect, drawtext){
context.clearRect(0, 0, rect.height, rect.width); // Clears the canvas