Skip to content

Instantly share code, notes, and snippets.

@pfitzseb
Created August 19, 2018 14:20
Show Gist options
  • Save pfitzseb/0d8fb36e6a5416684b044784fe9cc461 to your computer and use it in GitHub Desktop.
Save pfitzseb/0d8fb36e6a5416684b044784fe9cc461 to your computer and use it in GitHub Desktop.
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 = ' '
!(eof(stream)) && (begin
c = read(stream, Char)
!(c in " \n")
end && return false)
if c != '\n'
h = strip(readline(stream))
h = (match(r"(.*?)( +#+)?$", h)).captures[1]
buffer = IOBuffer()
print(buffer, h)
push!(md.content, Header(parseinline(seek(buffer, 0), md), level))
else
push!(md.content, Header("", level))
end
return true
end
end
end)), 1.534688115129e9)
Revise.Diff('+', (Markdown, :((Markdown.breaking!)(#5#f))), 1.534688115129e9)
Revise.Diff('+', (Markdown, :(#6#f = begin
function blockquote(stream::IO, block::MD)
withstream(stream) do
buffer = IOBuffer()
empty = true
while eatindent(stream) && startswith(stream, '>')
startswith(stream, " ")
write(buffer, readline(stream, keep=true))
empty = false
end
empty && return false
md = String(take!(buffer))
push!(block, BlockQuote((parse(md, flavor=config(block))).content))
return true
end
end
end)), 1.534688115129e9)
Revise.Diff('+', (Markdown, :((Markdown.breaking!)(#6#f))), 1.534688115129e9)
Revise.Diff('+', (Markdown, :(#7#f = begin
function admonition(stream::IO, block::MD)
withstream(stream) do
startswith(stream, "!!! ") || return false
(category, title) = let untitled = r"^([a-z]+)$", titled = r"^([a-z]+) \"(.*)\"$", line = strip(readline(stream))
if occursin(untitled, line)
m = match(untitled, line)
(m.captures[1], uppercasefirst(m.captures[1]))
elseif occursin(titled, line)
m = match(titled, line)
(m.captures[1], m.captures[2])
else
return false
end
end
buffer = IOBuffer()
while !(eof(stream))
if startswith(stream, " ")
write(buffer, readline(stream, keep=true))
elseif blankline(stream)
write(buffer, '\n')
else
break
end
end
nested = parse(String(take!(buffer)), flavor=config(block))
push!(block, Admonition(category, title, nested.content))
return true
end
end
end)), 1.534688115129e9)
Revise.Diff('+', (Markdown, :((Markdown.breaking!)(#7#f))), 1.534688115129e9)
Revise.Diff('+', (Markdown, :(#8#f = begin
function list(stream::IO, block::MD)
withstream(stream) do
bullet = startswith(stream, NUM_OR_BULLETS; eat=false)
indent = if isempty(bullet)
return false
else
length(bullet)
end
(initial, regex) = if occursin(BULLETS, bullet)
(-1, BULLETS)
elseif occursin(r"^ {0,3}\d+(\.|\))( |$)", bullet)
r = if occursin(".", bullet)
r"^ {0,3}(\d+)\.( |$)"
else
r"^ {0,3}(\d+)\)( |$)"
end
(Base.parse(Int, (match(r, bullet)).captures[1]), r)
else
return false
end
list = List(initial)
buffer = IOBuffer()
newline = false
count = 0
while !(eof(stream))
if startswith(stream, "\n")
if newline
pushitem!(list, buffer)
break
else
newline = true
println(buffer)
end
else
if startswith(stream, " " ^ indent)
newline && (list.loose = true)
print(buffer, readline(stream, keep=true))
else
matched = startswith(stream, regex)
if isempty(matched)
pushitem!(list, buffer)
break
else
newline && (list.loose = true)
count += 1
count > 1 && pushitem!(list, buffer)
print(buffer, readline(stream, keep=true))
end
end
newline = false
end
end
count == length(list.items) || pushitem!(list, buffer)
push!(block, list)
return true
end
end
end)), 1.534688115129e9)
Revise.Diff('+', (Markdown, :((Markdown.breaking!)(#8#f))), 1.534688115144e9)
Revise.Diff('+', (FileWatching, :(function poll_fd(s::Union{RawFD, if Sys.iswindows()
WindowsRawSocket
else
Union{}
end}, timeout_s::Real=-1; readable=false, writable=false)
wt = Condition()
fdw = _FDWatcher(s, readable, writable)
try
if timeout_s >= 0
result::FDEvent = FDEvent()
begin
local #20#task = (Base.Task)((()->begin
begin
sleep(timeout_s)
notify(wt)
end
end))
if $(Expr(:isdefined, Symbol("##sync#72")))
(Base.push!)(##sync#72, #20#task)
end
(Base.schedule)(#20#task)
end
begin
local #21#task = (Base.Task)((()->begin
begin
try
result = wait(fdw, readable=readable, writable=writable)
catch e
notify_error(wt, e)
return
end
notify(wt)
end
end))
if $(Expr(:isdefined, Symbol("##sync#72")))
(Base.push!)(##sync#72, #21#task)
end
(Base.schedule)(#21#task)
end
wait(wt)
return result
else
return wait(fdw, readable=readable, writable=writable)
end
finally
close(fdw, readable, writable)
end
end)), 1.534688115463e9)
Revise.Diff('+', (FileWatching, :(function watch_file(s::AbstractString, timeout_s::Real=-1)
fm = FileMonitor(s)
try
if timeout_s >= 0
begin
local #22#task = (Base.Task)((()->begin
begin
sleep(timeout_s)
close(fm)
end
end))
if $(Expr(:isdefined, Symbol("##sync#72")))
(Base.push!)(##sync#72, #22#task)
end
(Base.schedule)(#22#task)
end
end
return wait(fm)
finally
close(fm)
end
end)), 1.534688115463e9)
Revise.Diff('+', (FileWatching, :(function poll_file(s::AbstractString, interval_seconds::Real=5.007, timeout_s::Real=-1)
pfw = PollingFileWatcher(s, Float64(interval_seconds))
try
if timeout_s >= 0
begin
local #23#task = (Base.Task)((()->begin
begin
sleep(timeout_s)
close(pfw)
end
end))
if $(Expr(:isdefined, Symbol("##sync#72")))
(Base.push!)(##sync#72, #23#task)
end
(Base.schedule)(#23#task)
end
end
statdiff = wait(pfw)
if statdiff[2] isa IOError
statdiff = wait(pfw)
end
return statdiff
finally
close(pfw)
end
end)), 1.534688115463e9)
Revise.Diff('+', (LinearAlgebra, :(function ldlt!(S::SymTridiagonal{T, V}) where {T <: Real, V}
n = size(S, 1)
d = S.dv
e = S.ev
begin
$(Expr(:inbounds, true))
local #34#val = begin
let ##r#362 = 1:n - 1
for ##i#363 = Base.simd_outer_range(##r#362)
let ##n#364 = Base.simd_inner_length(##r#362, ##i#363)
if zero(##n#364) < ##n#364
let ##i#365 = zero(##n#364)
while ##i#365 < ##n#364
local i = Base.simd_index(##r#362, ##i#363, ##i#365)
begin
e[i] /= d[i]
d[i + 1] -= abs2(e[i]) * d[i]
end
##i#365 += 1
$(Expr(:simdloop, false))
end
end
i = last(##r#362)
end
end
end
end
nothing
end
$(Expr(:inbounds, :pop))
#34#val
end
return LDLt{T, SymTridiagonal{T, V}}(S)
end)), 1.534688115584e9)
Revise.Diff('+', (LibGit2, :(function tag_list(repo::GitRepo)
ensure_initialized()
sa_ref = Ref(StrArrayStruct())
begin
#39#err = (LibGit2.Cint)(ccall((:git_tag_list, :libgit2), Cint, (Ptr{StrArrayStruct}, Ptr{Cvoid}), sa_ref, repo.ptr))
if #39#err < 0
(LibGit2.throw)((LibGit2.Error).GitError(#39#err))
end
#39#err
end
res = convert(Vector{String}, sa_ref[])
free(sa_ref)
res
end)), 1.534688115631e9)
Revise.Diff('+', (LibGit2, :(function tag_delete(repo::GitRepo, tag::AbstractString)
ensure_initialized()
begin
#40#err = (LibGit2.Cint)(ccall((:git_tag_delete, :libgit2), Cint, (Ptr{Cvoid}, Cstring), repo.ptr, tag))
if #40#err < 0
(LibGit2.throw)((LibGit2.Error).GitError(#40#err))
end
#40#err
end
end)), 1.534688115631e9)
Revise.Diff('+', (LibGit2, :(function tag_create(repo::GitRepo, tag::AbstractString, commit::Union{AbstractString, AbstractGitHash}; msg::AbstractString="", force::Bool=false, sig::Signature=Signature(repo))
oid_ptr = Ref(GitHash())
with(GitCommit(repo, commit)) do commit_obj
commit_obj === nothing && return oid_ptr[]
with(convert(GitSignature, sig)) do git_sig
ensure_initialized()
begin
#41#err = (LibGit2.Cint)(ccall((:git_tag_create, :libgit2), Cint, (Ptr{GitHash}, Ptr{Cvoid}, Cstring, Ptr{Cvoid}, Ptr{SignatureStruct}, Cstring, Cint), oid_ptr, repo.ptr, tag, commit_obj.ptr, git_sig.ptr, msg, Cint(force)))
if #41#err < 0
(LibGit2.throw)((LibGit2.Error).GitError(#41#err))
end
#41#err
end
end
end
return oid_ptr[]
end)), 1.534688115646e9)
Revise.Diff('+', (LibGit2, :(function name(tag::GitTag)
ensure_initialized()
begin
##370 = $(Expr(:gc_preserve_begin, :tag))
##371 = begin
str_ptr = ccall((:git_tag_name, :libgit2), Cstring, (Ptr{Cvoid},), tag.ptr)
str_ptr == C_NULL && throw(Error.GitError(Error.ERROR))
str = unsafe_string(str_ptr)
end
$(Expr(:gc_preserve_end, Symbol("##370")))
##371
end
return str
end)), 1.534688115646e9)
Revise.Diff('+', (LibGit2, :(function target(tag::GitTag)
ensure_initialized()
begin
##372 = $(Expr(:gc_preserve_begin, :tag))
##373 = begin
oid_ptr = ccall((:git_tag_target_id, :libgit2), Ptr{GitHash}, (Ptr{Cvoid},), tag.ptr)
oid_ptr == C_NULL && throw(Error.GitError(Error.ERROR))
str = unsafe_load(oid_ptr)
end
$(Expr(:gc_preserve_end, Symbol("##372")))
##373
end
return str
end)), 1.534688115646e9)
Revise.Diff('+', (Distributed, :(function clear!(syms, pids=workers(); mod=Main)
begin
let ##sync#72 = (Base.Any)[]
#44#v = for p = pids
begin
local #45#task = (Base.Task)((()->begin
remotecall_wait(clear_impl!, p, syms, mod)
end))
if $(Expr(:isdefined, Symbol("##sync#72")))
(Base.push!)(##sync#72, #45#task)
end
(Base.schedule)(#45#task)
end
end
(Base.sync_end)(##sync#72)
#44#v
end
end
end)), 1.534688115948e9)
Revise.Diff('+', (Base, :(function hex2bytes!(d::AbstractVector{UInt8}, s::Union{String, AbstractVector{UInt8}})
if 2 * length(d) != sizeof(s)
isodd(sizeof(s)) && throw(ArgumentError("input hex array must have even length"))
throw(ArgumentError("output array must be half length of input array"))
end
j = first(eachindex(d)) - 1
for i = _firstbyteidx(s):2:_lastbyteidx(s)
begin
$(Expr(:inbounds, true))
local #48#val = (d[j += 1] = number_from_hex(_nthbyte(s, i)) << 4 + number_from_hex(_nthbyte(s, i + 1)))
$(Expr(:inbounds, :pop))
#48#val
end
end
return d
end)), 1.534688116603e9)
Revise.Diff('+', (LibGit2, ERROR: deepcopy of Modules not supported
Stacktrace:
[1] error(::String) at .\error.jl:33
[2] deepcopy_internal(::Module, ::IdDict{Any,Any}) at .\deepcopy.jl:34
[3] _deepcopy_array_t(::Any, ::Type, ::IdDict{Any,Any}) at .\deepcopy.jl:91
[4] deepcopy_internal(::Array{Any,1}, ::IdDict{Any,Any}) at .\deepcopy.jl:78
[5] deepcopy_internal(::Any, ::IdDict{Any,Any}) at .\deepcopy.jl:67
[6] _deepcopy_array_t(::Any, ::Type, ::IdDict{Any,Any}) at .\deepcopy.jl:91
[7] deepcopy_internal(::Array{Any,1}, ::IdDict{Any,Any}) at .\deepcopy.jl:78
[8] deepcopy_internal(::Any, ::IdDict{Any,Any}) at .\deepcopy.jl:67
[9] _deepcopy_array_t(::Any, ::Type, ::IdDict{Any,Any}) at .\deepcopy.jl:91
[10] deepcopy_internal(::Array{Any,1}, ::IdDict{Any,Any}) at .\deepcopy.jl:78
[11] deepcopy_internal(::Any, ::IdDict{Any,Any}) at .\deepcopy.jl:67
[12] _deepcopy_array_t(::Any, ::Type, ::IdDict{Any,Any}) at .\deepcopy.jl:91
[13] deepcopy_internal(::Array{Any,1}, ::IdDict{Any,Any}) at .\deepcopy.jl:78
[14] deepcopy_internal(::Any, ::IdDict{Any,Any}) at .\deepcopy.jl:67
[15] _deepcopy_array_t(::Any, ::Type, ::IdDict{Any,Any}) at .\deepcopy.jl:91
[16] deepcopy_internal(::Array{Any,1}, ::IdDict{Any,Any}) at .\deepcopy.jl:78
[17] deepcopy_internal(::Any, ::IdDict{Any,Any}) at .\deepcopy.jl:67
[18] _deepcopy_array_t(::Any, ::Type, ::IdDict{Any,Any}) at .\deepcopy.jl:91
[19] deepcopy_internal(::Array{Any,1}, ::IdDict{Any,Any}) at .\deepcopy.jl:78
[20] deepcopy_internal(::Any, ::IdDict{Any,Any}) at .\deepcopy.jl:67
[21] _deepcopy_array_t(::Any, ::Type, ::IdDict{Any,Any}) at .\deepcopy.jl:91
[22] deepcopy_internal(::Array{Any,1}, ::IdDict{Any,Any}) at .\deepcopy.jl:78
[23] deepcopy_internal(::Any, ::IdDict{Any,Any}) at .\deepcopy.jl:67
[24] _deepcopy_array_t(::Any, ::Type, ::IdDict{Any,Any}) at .\deepcopy.jl:91
[25] deepcopy_internal(::Array{Any,1}, ::IdDict{Any,Any}) at .\deepcopy.jl:78
[26] deepcopy_internal(::Any, ::IdDict{Any,Any}) at .\deepcopy.jl:67
[27] show(::IOContext{Base.TTY}, ::Revise.RelocatableExpr) at .\deepcopy.jl:28
[28] show_delim_array(::IOContext{Base.TTY}, ::Tuple{Module,Revise.RelocatableExpr}, ::Char, ::Char, ::Char, ::Bool, ::Int64, ::Int64) at .\show.jl:695
[29] show_delim_array at .\show.jl:680 [inlined]
[30] show(::IOContext{Base.TTY}, ::Tuple{Module,Revise.RelocatableExpr}) at .\show.jl:714
[31] show_default(::Base.TTY, ::Any) at .\show.jl:332
[32] show(::Base.TTY, ::Any) at .\show.jl:315
[33] show(::Revise.Diff) at .\show.jl:313
[34] top-level scope at .\REPL[9]:2 [inlined]
[35] top-level scope at .\none:0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment