Skip to content

Instantly share code, notes, and snippets.

Shuhei Kadowaki aviatesk

  • Recruit Co., Ltd.
  • Tokyo
View GitHub Profile
aviatesk / scratched_graph.jl
Last active Jul 5, 2020
graph scratching
View scratched_graph.jl
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)
View vscode_markdown_command.js
// 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) => {
return `command:${cmd}${args}`
View BQUtils.jl
module BQUtils
using CSV
using MacroTools: @>, @>>
struct Query
Query(q::Query) = q
aviatesk / collectgen-standalone.jl
Last active May 18, 2020
`@collect` and `@generator` macro, standalone implementation
View collectgen-standalone.jl
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
function recompose_to_comprehension(forblk, cond = nothing; gen = false)
body, v, itr = decompose_forblk(forblk)
aviatesk / dfchain.jl
Created May 9, 2020
dataframe chaining while plotting
View dfchain.jl
# 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
df = DataFrame(x = randn(100), y = rand(Int, 100))
aviatesk / linqplot.jl
Created Apr 22, 2020
plotting `@linq` chain
View linqplot.jl
using DataFrames, DataFramesMeta, Plots, StatsPlots, StatsBase
# 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)
aviatesk / cloudSettings
Last active Jul 16, 2020
Visual Studio Code Settings Sync Gist
View cloudSettings
aviatesk / collectgen.jl
Last active May 4, 2020
`@collect` and `@generator` macro -- might be useful in competitive programming, etc...
View collectgen.jl
using MacroTools
function decompose_forblk(forblk)
spec, body = forblk.args
i, itr = spec.args
return i, itr, body
aviatesk / objmethods.jl
Last active Dec 9, 2019
methods on objects
View objmethods.jl
const ACS = Union{AbstractChar, AbstractString}
(l::ACS)(f::Function, rs::ACS...) = f(l, rs...)
(l::ACS)(rs::ACS...) = l(*, rs...)
'1'("23") # "123"
']' .|> collect("julia") .|> '[' |> join # "[j][u][l][i][a]"
aviatesk / quine.jl
Last active Dec 4, 2019
Julia one liner quine
View quine.jl
(q = :(println("(q = $(repr(q))) |> eval"))) |> eval
You can’t perform that action at this time.