Skip to content

Instantly share code, notes, and snippets.

Morten Piibeleht mortenpi

  • Massey University
  • Auckland, New Zealand
Block or report user

Report or block mortenpi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mortenpi / Markdown2.printmd2.jl
Created Jun 2, 2018
printmd2() functions to print Markdown2 trees in Documenter
View Markdown2.printmd2.jl
# printmd2
const INDENT = ". "
printmd2(xs :: Markdown2.MD) = printmd2(xs.nodes)
function printmd2(xs :: Vector; indent=0)
for x in xs
printmd2(x; indent = indent)
View json-escape-benchmark.jl
function jsonescape(s)
s = replace(s, '\\' => "\\\\")
s = replace(s, '\n' => "\\n")
replace(s, '"' => "\\\"")
@static if VERSION < v"0.7.0-DEV.3734" #
function iobuffer(sizehint)
b = IOBuffer(Base.StringVector(floor(Int, 1.2*sizehint)), true, true)
truncate(b, 0)
mortenpi / documenter-api-updates.jl
Last active Apr 11, 2018
Some speculation about the future of Documenter's user-facing API.
View documenter-api-updates.jl
# This would be make.jl.
# The user can then interact with this configuration through the
# command line:
# julia docs/make.jl doctest
# julia docs/make.jl build --html
# julia docs/make.jl deploy --latex --html
using Documenter, DocumenterLaTeX
mortenpi / 0 Dropbox
Last active Aug 1, 2017
Setup for second Dropbox folder
mortenpi / clean-urls.diff
Created May 25, 2017
search.html (v0.10.3) vs search/index.html (v0.11.0)
View clean-urls.diff
< "|Ubuntu+Mono" rel=
> "|Roboto+Mono" rel=
< documenterBaseURL="."
> documenterBaseURL=".."
< data-main="assets/documenter.js"></script>
mortenpi / documenter-world-counter.patch
Last active May 19, 2017
Work around the world counter issue in Documenter
View documenter-world-counter.patch
diff --git a/src/Expanders.jl b/src/Expanders.jl
index 484622f..f7025f4 100644
--- a/src/Expanders.jl
+++ b/src/Expanders.jl
@@ -471,11 +471,7 @@ function Selectors.runner(::Type{ExampleBlocks}, x, page, doc)
# Splice the input and output into the document.
content = []
input = droplines(x.code)
- # Special-case support for displaying SVG graphics. TODO: make this more general.
mortenpi / handle_segfault.c
Last active Feb 7, 2020
Recover gracefully from a segmentation fault (SIGSEGV) in C due to invalid pointer.
View handle_segfault.c
Credits to:
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <signal.h>
julia> Pkg.update()
INFO: Updating METADATA...
ERROR: METADATA cannot be updated. Resolve problems manually in /home/morten/Julia/pkg/v0.5/METADATA.
GitError(Code:ERROR, Class:Net, Failed to resolve address for https: Name or service not known)
 in macro expansion at ./libgit2/error.jl:99 [inlined]
 in #fetch#52(::Base.LibGit2.FetchOptions, ::String, ::Function, ::Base.LibGit2.GitRemote, ::Array{AbstractString,1}) at ./libgit2/remote.jl:70
 in (::Base.LibGit2.#kw##fetch)(::Array{Any,1}, ::Base.LibGit2.#fetch, ::Base.LibGit2.GitRemote, ::Array{AbstractString,1}) at ./<missing>:0
 in #fetch#93(::String, ::String, ::Array{AbstractString,1}, ::Nullable{Base.LibGit2.AbstractCredentials}, ::Function, ::Base.LibGit2.GitRepo) at ./libgit2/libgit2.jl:164
 in (::Base.Pkg.Entry.##35#41)(::Base.LibGit2.GitRepo) at ./pkg/entry.jl:371
mortenpi / capture-streams.jl
Last active Feb 18, 2020
Example code to capture STDOUT and STDERR in Julia.
View capture-streams.jl
# A wrapper function to capture STDOUT and STDERR into strings.
# Heavily inspired by
# referred to by the issue comment
# The Base.start_reading(stream, cb) requires fixes in Base.
View gadfly-spy-test.jl
if length(ARGS) != 1
error("Output file name not provided!")
ofile = ARGS[1]
println("Writing the plot to: $ofile")
using Gadfly
M,N = 22,30
matrix = zeros(Float64, (M,N))
for i=1:M, j=1:N
You can’t perform that action at this time.