Skip to content

Instantly share code, notes, and snippets.

@j-fu
Last active September 10, 2020 11:05
Show Gist options
  • Save j-fu/ec657daabc155aca02d272650ed4cb14 to your computer and use it in GitHub Desktop.
Save j-fu/ec657daabc155aca02d272650ed4cb14 to your computer and use it in GitHub Desktop.
Example for code control
### A Pluto.jl notebook ###
# v0.11.14
using Markdown
using InteractiveUtils
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
quote
local el = $(esc(element))
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
el
end
end
# ╔═╡ 8d418e20-f2c3-11ea-2914-b16be7cf6b24
using PlutoUI,Markdown
# ╔═╡ 360f48f4-f33e-11ea-0553-df1fe94c2274
prettyprintln(output)=show(stdout,MIME("text/plain"),output)
# ╔═╡ 8df6c4a8-f342-11ea-3af2-790fa84461ae
stdout_style(:nowrap);
# ╔═╡ ef9d896e-f342-11ea-1c4b-0bc82700764e
stdout_styles()
# ╔═╡ fbd16f82-f2f2-11ea-17c2-c3635e53f7c9
md"##### My Test $(@bind mytest CheckBox())"
# ╔═╡ ac6a6eb8-f26f-11ea-3903-a7fea6a447ec
md"x=$(@bind x Slider(0.00 : 0.01 : 0.30))"
# ╔═╡ 84944fce-f27b-11ea-36ab-47cfbe6f2cdb
md"y=$(@bind y Slider(0.00 : 0.01 : 0.30))"
# ╔═╡ ae37a0e0-f232-11ea-04a6-794f9e48f412
@with_stdout println("x=$(x), y=$(y)")
# ╔═╡ 6833a2de-f2cc-11ea-182b-c5ce7d3b39e4
@cond mytest y+1
# ╔═╡ 3e04a342-f221-11ea-133a-8bd98e77f235
@cond_with_stdout mytest begin
println("xxx")
println("yyy")
prettyprintln(rand(5,5).*x)
end
# ╔═╡ 81bd3974-f342-11ea-1107-f98073e63e73
@cond_with_stdout mytest begin
println("xxx")
println("yyy")
println(rand(40).*x)
end
# ╔═╡ Cell order:
# ╠═8d418e20-f2c3-11ea-2914-b16be7cf6b24
# ╠═360f48f4-f33e-11ea-0553-df1fe94c2274
# ╠═8df6c4a8-f342-11ea-3af2-790fa84461ae
# ╠═ef9d896e-f342-11ea-1c4b-0bc82700764e
# ╟─fbd16f82-f2f2-11ea-17c2-c3635e53f7c9
# ╟─ac6a6eb8-f26f-11ea-3903-a7fea6a447ec
# ╟─84944fce-f27b-11ea-36ab-47cfbe6f2cdb
# ╟─ae37a0e0-f232-11ea-04a6-794f9e48f412
# ╠═6833a2de-f2cc-11ea-182b-c5ce7d3b39e4
# ╠═3e04a342-f221-11ea-133a-8bd98e77f235
# ╠═81bd3974-f342-11ea-1107-f98073e63e73
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment