Skip to content

Instantly share code, notes, and snippets.

Sebastian Pfitzner pfitzseb

Block or report user

Report or block pfitzseb

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
View gist:cd09671e4b0d1f2557f8e4649064df44
julia> @enter wrapper()
In wrapper() at /home/pfitzseb/.julia/dev/Atom/test.jl:2
1 function wrapper()
>2 mktempdir() do dir
3 open(joinpath(dir, "test.txt"), "w") do io
4 println(io, "data")
5 end
6 end
7 end
@pfitzseb
pfitzseb / timeperiod.jl
Created Nov 27, 2019
timeperiod parsing
View timeperiod.jl
using Dates
period(::Dates.DatePart{T}, val) where T = Dates.CONVERSION_SPECIFIERS[T](val)
period(::Dates.Delim, val) = Millisecond(0)
Base.parse(t::Type{TimePeriod}, str::AbstractString, df::AbstractString) = parse(t, str, DateFormat(df))
function Base.parse(t::Type{TimePeriod}, str::AbstractString, df::DateFormat)
out = Millisecond(0)
len = length(str)
i = 1
@pfitzseb
pfitzseb / gist:37adca96a13c7097631c15e1af4b7409
Created Sep 18, 2019
open nvim when pressing enter on empty prompt
View gist:37adca96a13c7097631c15e1af4b7409
using REPL: LineEdit
Base.active_repl.interface.modes[1].on_enter = function (s)
mktemp() do path, io
input = chomp(String(take!(copy(LineEdit.buffer(s)))))
if isempty(input)
run(`nvim $(path)`)
sleep(0.1)
input = read(io, String)
write(LineEdit.buffer(s), chomp(input))
end
View pkgcompiler_error_linux
PackageCompiler on  pathfix [?]
λ j1 juliac.jl -vasji `pwd`/hello.jl
Julia program file:
"/home/pfitzseb/.julia/dev/PackageCompiler/hello.jl"
Build directory:
"/home/pfitzseb/.julia/dev/PackageCompiler/builddir"
Build static library "hello.a":
atexit_hook_copy = copy(Base.atexit_hooks) # make backup
# clean state so that any package we use can carelessly call atexit
View gist:e5baab5b400df6c30d1a8366c4972ccc
MbedTLS on  jq/1.2
λ rm -rf ./deps/usr
MbedTLS on  jq/1.2
λ julia -e 'using Pkg; Pkg.build("MbedTLS")'
Building MbedTLS → `~/.julia/dev/MbedTLS/deps/build.log`
Resolving package versions...
MbedTLS on  jq/1.2
λ ls -l ./deps/usr/lib
@pfitzseb
pfitzseb / keyboardmacro.jl
Created Jun 16, 2019
keyboard macro prototype
View keyboardmacro.jl
using REPL
using REPL.LineEdit
macro keyboard()
quote
debugprompt(@__MODULE__, Base.@locals)
println()
end
end
View gist:d4ae4010877ba553811d84f145f4702b
julia> using Revise, JuliaInterpreter, CodeTracking
julia> bps=breakpoint(min);
^[[B
julia> bps[1].framecode.scope
min(x::BigFloat, y::BigFloat) in Base.MPFR at mpfr.jl:693
julia> whereis(bps[1].framecode.scope)
[ Info: tracking Base
┌ Warning: error evaluating in module Base.MPFR: for (fJ, fC) = ((:si, :Clong), (:ui, :Culong))
@pfitzseb
pfitzseb / tmuxedit.jl
Last active Jul 27, 2019
edit in existing tmux pane that runs `vim`
View tmuxedit.jl
# put this in your startup.jl
using InteractiveUtils
let
tmuxsession = nothing
sessions = split(String(read(`tmux list-panes -a -F '#{pane_tty} #{session_name}'`)), '\n')
io = IOBuffer()
run(pipeline(`tty`, stdout=io))
tty = chomp(String(take!(io)))
for session in sessions
if occursin(tty, session)
View juno_demo.jl
# Juno
# http://junolab.org/
# http://docs.junolab.org/latest/man/installation.html
## Inline Evaluation
1+1
println(2+2)
rand(3)
@pfitzseb
pfitzseb / TraceCalls.jl
Created Dec 17, 2018
TraceCalls.jl with Cassette
View TraceCalls.jl
module TraceCalls
using Cassette
mutable struct Trace
level::Int
cutoff::Int
end
Cassette.@context TraceCtx
You can’t perform that action at this time.