Skip to content

Instantly share code, notes, and snippets.

@pfitzseb
pfitzseb / alacritty.toml
Last active June 28, 2024 10:37
alacritty config for clickable file paths
[[hints.enabled]]
command = { program = "bash", args = ["-c", "code-insiders -g \"$(P=${0/#\\~/$HOME}; realpath ${P%:*}):$(echo $0 | cut -s -d: -f 2)\""] }
hyperlinks = true
post_processing = true
persist = false
mouse = { enabled = true, mods = "Control" }
regex = "[^\u0000-\u001F\u007F-\u009F<>\"\\s{-}\\^⟨⟩`]+(:\\d+)?"
@pfitzseb
pfitzseb / lint_me.jl
Last active April 25, 2023 09:24
Lint a Julia project
using LanguageServer, StaticLint, SymbolServer
path = abspath(ARGS[1])
root_file = if length(ARGS) > 1
abspath(ARGS[2])
else
joinpath(path, "src", string(basename(path), ".jl"))
end
s = LanguageServerInstance(Pipe(), stdout, path)
@pfitzseb
pfitzseb / encode_uri_component.jl
Last active June 24, 2020 11:53
encodeURIcomponent
using Printf
UNESCAPED = Set(codeunits("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.!~*'()"))
# https://tc39.es/ecma262/#sec-encodeuricomponent-uricomponent
function encode_uri_component(uri)
isvalid(uri) || throw(ArgumentError("`encode_uri_component` can only handle valid UTF8 strings."))
io = IOBuffer()
for cp in codeunits(uri)
@pfitzseb
pfitzseb / id.jl
Last active August 24, 2021 13:54
Julia Identifier Regex
Regex("""(?:[
[:alpha:]_\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}\u2140-\u2144\u223f\u22be
\u22bf\u22a4\u22a5\u2202\u2205-\u2207\u220e\u220f\u2210\u2211\u221e\u221f\u222b-\u2233
\u22c0-\u22c3\u25f8-\u25ff\u266f\u27d8\u27d9\u27c0\u27c1\u29b0-\u29b4\u2a00-\u2a06
\u2a09-\u2a16\u2a1b\u2a1c\U1d6c1\U1d6db\U1d6fb\U1d715\U1d735\U1d74f\U1d76f\U1d789\U1d7a9
\U1d7c3\u2071-\u207e\u2081-\u208e\u2220-\u2222\u299b-\u29af\u2118\u212e\u309b-\u309c
\U1d7ce-\U1d7e1
]|[^\\P{So}\u2190-\u21FF])
(?:[
[:word:]_!\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}\\p{Nl}\\p{Sc}\u2140-\u2144\u223f\u22be
~
λ mv ~/.julia/packages .julia/packages_old
~
λ mkdir jenvtest
~
λ cd jenvtest
~/jenvtest
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 November 27, 2019 12:03
timeperiod parsing
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
Last active May 13, 2020 16:02
open nvim when pressing enter on empty prompt
using REPL
using REPL: LineEdit
atreplinit() do repl
repl.interface = REPL.setup_interface(repl)
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)
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
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