This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BQUtils | |
using CSV | |
using MacroTools: @>, @>> | |
struct Query | |
s::String | |
end | |
Query(q::Query) = q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// maybe handled by other client | |
s = ` | |
foo [linktext](vscode-command:language-julia.openFile?${JSON.stringify({ file: 'foo', line: 10 })} "footitle") | |
bar [linktext](vscode-command:language-julia.openFile "bartitle") | |
` | |
s.replace(/vscode-command\:(.+)(|\?[\w\:\"\{\}\,]+)/g, (s, cmd, args) => { | |
console.log(args) | |
return `command:${cmd}${args}` | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using LightGraphs, SparseArrays, GraphPlot | |
get_adj(g, v) = first(findnz(adjacency_matrix(g)[v, :])) | |
function dfs(g::AbstractGraph{T}, s::T, | |
visited = Set{T}(), | |
ret = T[]) where T | |
push!.((visited, ret), s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# %% | |
using LanguageServer, CSTParser, StaticLint, SymbolServer | |
using LanguageServer: Range, TextDocumentIdentifier, TextDocumentPositionParams | |
const LS = LanguageServer | |
const SS = SymbolServer | |
server = let | |
pi = IOBuffer() | |
po = IOBuffer() | |
env = normpath(@__DIR__, "..", "scripts", "environments", "development") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools, Cthulhu | |
f(a, b) = collect(Iterators.flatten((a, b))) | |
a = rand(10^6) | |
b = rand(10^6) | |
@btime f($a, $b) # 14.402 ms (21 allocations: 17.00 MiB) | |
# @descend f(a, b) | |
(@code_typed iterate(Iterators.flatten((a,b)))) |> last # ::Union{Nothing, Tuple{Float64, Tuple{Int64, Vector{Float64}, Int64}}} -> unwidened |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dates, DataFrames, Pipe, Plots | |
df = let | |
ds = DateTime[] | |
r = r"# time: (?<datetime>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})" | |
for line in readlines(normpath(homedir(), ".julia/logs/repl_history.jl")) | |
m = match(r, line) | |
isnothing(m) || push!(ds, DateTime(m[:datetime], dateformat"Y-m-d H:M:S")) | |
end | |
DataFrame(datetime = ds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# %% | |
import Base: | |
uniontypes, | |
get_world_counter, | |
_methods_by_ftype | |
import Core: | |
Const, | |
MethodMatch, | |
MethodInstance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> ] add Revise | |
julia> using Revise | |
julia> Revise.track(Core.Compiler) | |
# typeinf_local(interp::AbstractInterpreter, frame::InferenceState)の1行目に以下の変更を加えてsave | |
# println(frame.slottypes) | |
julia> code_typed(use_tvar_info, (Union{Int,Nothing},Int); optimize=false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> using JET, JET.JETInterfaces | |
julia> get_module(sv::Core.Compiler.InferenceState) = sv.mod | |
get_module (generic function with 2 methods) | |
julia> function get_module(linfo::Core.MethodInstance) | |
def = linfo.def | |
return isa(def, Module) ? def : def.module | |
end | |
get_module (generic function with 2 methods) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# adapted from https://github.com/JuliaCompilerPlugins/Mixtape.jl/blob/75fc4aa25e918f92bfd0ba706236f61a466efc11/examples/dynamic_overlay.jl | |
module DynamicOverlay | |
using Mixtape | |
import Mixtape: CompilationContext, transform, allow | |
using MacroTools | |
using CodeInfoTools | |
using BenchmarkTools |