Skip to content

Instantly share code, notes, and snippets.

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 February 22, 2021 15:38
edit in existing tmux pane that runs `vim`
# 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)
@pfitzseb
pfitzseb / juno_demo.jl
Created February 12, 2019 19:32
Juno Demo
# 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 December 17, 2018 15:10
TraceCalls.jl with Cassette
module TraceCalls
using Cassette
mutable struct Trace
level::Int
cutoff::Int
end
Cassette.@context TraceCtx
@pfitzseb
pfitzseb / sleep_ns.jl
Created December 5, 2018 20:49
sleep ns julialang
# adapted from https://github.com/ArchieCall/AccurateSleep/blob/master/src/hybrid_sleep.jl
function sleep_ns(sleep_time::Float64, threshold::Float64 = 0.001)
tics_per_sec = 1_000_000_000.0
nano1 = time_ns()
nano2 = nano1 + (sleep_time * tics_per_sec)
min_true_sleep = 0.001
# normal sleep
if sleep_time > threshold
actual_sleep_time = max(min_true_sleep, sleep_time - threshold)
@pfitzseb
pfitzseb / Project.toml
Created November 9, 2018 10:06
LanguageServer setup
[deps]
CSTParser = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
DocumentFormat = "ffa9a821-9c82-50df-894e-fbcef3ed31cd"
LanguageServer = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7"
StaticLint = "b3cc710f-9c33-5bdb-a03d-a94903873e97"
SymbolServer = "4cc854a7-cf14-540f-aa0e-47853c5fab2f"
@pfitzseb
pfitzseb / init.vim
Last active March 7, 2019 11:06
LanguageServer setup
call plug#begin('~/.config/nvim/plugged')
Plug 'JuliaEditorSupport/julia-vim'
Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'}
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
call plug#end()
let g:deoplete#enable_at_startup = 1
" julia
let g:default_julia_version = '1.0'
@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+"
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
julia> tryprint.(f[1].kwargs[:oldexprs])
call
Base.Docs.doc!
Libdl
call
Base.Docs.Binding
Libdl
:RTLD_NODELETE
call