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
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
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 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 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
// 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
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
function decompose_forblk(forblk) | |
@assert Meta.isexpr(forblk, :for) "for block expression should be given" | |
itrspec, body = forblk.args | |
@assert Meta.isexpr(itrspec, :(=)) "invalid for loop specification" | |
v, itr = itrspec.args | |
return body, v, itr | |
end | |
function recompose_to_comprehension(forblk, cond = nothing; gen = false) | |
body, v, itr = decompose_forblk(forblk) |
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
# what I will do here: | |
# - dataframe chain | |
# - keep to pass dataframe while plotting with `StatsPlots.@df` | |
# - pass columns names as variables | |
using DataFrames, Pipe, StatsPlots | |
theme(:juno) | |
df = DataFrame(x = randn(100), y = rand(Int, 100)) |
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 DataFrames, DataFramesMeta, Plots, StatsPlots, StatsBase | |
# HACK: | |
# integrate StatsPlots.@df into @linq chain in a way data frame keeps to be passed even after plot | |
# but, the `names` part might be too dangerous | |
for n in names(StatsPlots) | |
function DataFramesMeta.linq(::DataFramesMeta.SymbolParameter{n}, d, args...) | |
plotcall = Expr(:call, n, args...) | |
return quote let d = $d | |
display(@df d $plotcall) |