Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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)
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 / keyboardmacro.jl
Created June 16, 2019 07:46
keyboard macro prototype
using REPL
using REPL.LineEdit
macro keyboard()
quote
debugprompt(@__MODULE__, Base.@locals)
println()
end
end
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
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