Skip to content

Instantly share code, notes, and snippets.

julia> function async_eval(code)
sleep(2)
# hide prompt
print(stdout, "\e[1K\r")
# write code
printstyled(stdout, "julia> ", bold = true, color=:green)
print(stdout, code)
# eval code
println(stdout)
# paste into your coffee.init
atom.commands.add 'atom-text-editor', 'Toggle #\'', (e) =>
ed = atom.workspace.getActiveTextEditor()
sels = ed.getSelections()
buffer = ed.getBuffer()
lines = buffer.getLines()
for sel in sels
isOn = true
preIndents = []
@pfitzseb
pfitzseb / plotting.jl
Created June 26, 2018 16:20
juno 0.7 plotting integration
module MockPlotting
struct SimplePlot end
struct InteractivePlot end
const img = """
/9j/2wCEAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDIBCQkJDAsMGA0NGDIhHCEyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMv/AABEIAY8BkAMBIgACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AOuBpQeaYDTs1BY8GlzTAaXNAxwPvS5pgNOzQA+jNMz70v40CuOFITg0ZphPNMBwb86cDUY5NPHSkAuaKSlpjsKBSEYpaCKBDT0ptPNNNIY09KaadSGgBppppSKaaBid6UGm0tADwaBTRS5oAcDzSi
Revise.Diff('+', (Markdown, :(#5#f = begin
function hashheader(stream::IO, md::MD)
withstream(stream) do
eatindent(stream) || return false
level = 0
while startswith(stream, '#')
level += 1
end
(level < 1 || level > 6) && return false
c = ' '
julia> logs = filter(r->r.level==Debug && r._module==Revise, rlogger.logs);
julia> logs
1357-element Array{Test.LogRecord,1}:
Test.LogRecord(Debug, "Recipe for Base", Revise, "Watching", :Revise_61343d83, "C:\\Users\\Basti\\.julia\\dev\\Revise\\src\\recipes.jl", 25, Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:filename, :mtime, :mtimeref),Tuple{String,Float64,Float64}}}(:filename=>"D:\\Programme\\Julia-1.0.0\\share\\julia\\base\\traits.jl",:mtime=>1.53377e9,:mtimeref=>1.53377e9))
Test.LogRecord(Debug, "Recipe for Base", Revise, "Watching", :Revise_61343d84, "C:\\Users\\Basti\\.julia\\dev\\Revise\\src\\recipes.jl", 25, Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:filename, :mtime, :mtimeref),Tuple{String,Float64,Float64}}}(:filename=>"D:\\Programme\\Julia-1.0.0\\share\\julia\\base\\array.jl",:mtime=>1.53469e9,:mtimeref=>1.53377e9))
Test.LogRecord(Debug, "Recipe for Base", Revise, "Watching", :Revise_61343d85, "C:\\Users\\Basti\\.julia\\dev\\Revise\\sr
julia> filter(r->r.level==Base.CoreLogging.Debug && r._module==Revise, rlogger.logs)
522-element Array{Test.LogRecord,1}:
Test.LogRecord(Debug, "Recipe for Base", Revise, "Watching", :Revise_61343d83, "C:\\Users\\Basti\\.julia\\dev\\Revise\\src\\recipes.jl", 25, Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:filename, :mtime, :mtimeref),Tuple{String,Float64,Float64}}}(:filename=>"D:\\Programme\\Julia-1.0.0\\share\\julia\\base\\traits.jl",:mtime=>1.53377e9,:mtimeref=>1.53377e9))
Test.LogRecord(Debug, "Recipe for Base", Revise, "Watching", :Revise_61343d84, "C:\\Users\\Basti\\.julia\\dev\\Revise\\src\\recipes.jl", 25, Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:filename, :mtime, :mtimeref),Tuple{String,Float64,Float64}}}(:filename=>"D:\\Programme\\Julia-1.0.0\\share\\julia\\base\\array.jl",:mtime=>1.53469e9,:mtimeref=>1.53377e9))
Test.LogRecord(Debug, "Recipe for Base", Revise, "Watching", :Revise_61343d85, "C:\\Users\\Basti\\.julia\\dev\\Revise\\src\\re
julia> f = filter(r->r.message=="Diff" && (!isempty(r.kwargs[:newexprs]) || !isempty(r.kwargs[:oldexprs])), rlogger.logs);
julia> for i in f
println(f)
end
Test.LogRecord[LogRecord(Debug, "Diff", Revise, "Parsing", :Revise_67b60225, "C:\\Users\\Basti\\.julia\\dev\\Revise\\src\\Revise.jl", 212, Base.Iterators.Pairs{Symbol,Any,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:activemodule, :newexprs, :oldexprs),Tuple{Module,Set{Revise.RelocatableExpr},Set{Revise.RelocatableExpr}}}}(:activemodule=>LibGit2,:newexprs=>Set(Revise.RelocatableExpr[:(function clone(repo_url::AbstractString, repo_path::AbstractString; branch::AbstractString="", isbare::Bool=false, remote_cb::Ptr{Cvoid}=C_NULL, credentials::Creds=nothing, callbacks::Callbacks=Callbacks())
cred_payload = reset!(CredentialPayload(credentials))
if !(haskey(callbacks, :credentials))
callbacks[:credentials] = (credentials_cb(), cred_payload)
elseif haskey(callbacks, :credentials) && credentials !== nothing
julia> tryprint.(f[1].kwargs[:oldexprs])
call
Base.Docs.doc!
Libdl
call
Base.Docs.Binding
Libdl
:RTLD_NODELETE
call
using REPL
using REPL.LineEdit
# basically the same as Base's `display_error`, just with different frames removed
function display_error(io, err, st)
ind = findfirst(frame -> frame.file == Symbol(@__FILE__) && frame.func == :repleval, st)
st = st[1:(ind == nothing ? end : ind - 2)]
printstyled(io, "ERROR: "; bold=true, color=Base.error_color())
showerror(IOContext(io, :limit => true), err, st)
println(io)
end
@pfitzseb
pfitzseb / Manitfest.toml
Created November 9, 2018 09:31
LanguageServer setup
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[CSTParser]]
deps = ["LibGit2", "Test", "Tokenize"]
git-tree-sha1 = "fac55d11171228b7101948abde613e769b9277d6"
repo-rev = "master"
repo-url = "https://github.com/ZacLN/CSTParser.jl.git"
uuid = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
version = "0.5.0+"