Skip to content

Instantly share code, notes, and snippets.

Avatar

Shuhei Kadowaki aviatesk

  • Recruit Co., Ltd.
  • Tokyo
View GitHub Profile
@aviatesk
aviatesk / benchmarks.ipynb
Created Jul 24, 2019
Benchmarks for Traceur.jl: Cassette.jl to Vinyl.jl
View benchmarks.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aviatesk
aviatesk / mdbranch.jl
Last active Aug 15, 2019
isa vs. multiple dispatch branching
View mdbranch.jl
# %% defines
function isabranch(numsary)
s = 0
for (n1, n2) numsary
if n1 isa Int8 && n2 isa Int8
s += 1
elseif n1 isa Int8 && n2 isa Int16
s += 2
elseif n1 isa Int8 && n2 isa Int32
s += 3
@aviatesk
aviatesk / nospecialize.ipynb
Created Sep 1, 2019
Benchmarks for `@nospecialize`
View nospecialize.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aviatesk
aviatesk / quine.jl
Last active Dec 4, 2019
Julia one liner quine
View quine.jl
(q = :(println("(q = $(repr(q))) |> eval"))) |> eval
@aviatesk
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
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
end
"""
@aviatesk
aviatesk / cloudSettings
Last active Aug 11, 2020
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2020-08-11T09:37:45.650Z","extensionVersion":"v3.4.3"}
@aviatesk
aviatesk / linqplot.jl
Created Apr 22, 2020
plotting `@linq` chain
View linqplot.jl
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)
@aviatesk
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
theme(:juno)
df = DataFrame(x = randn(100), y = rand(Int, 100))
@aviatesk
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
end
function recompose_to_comprehension(forblk, cond = nothing; gen = false)
body, v, itr = decompose_forblk(forblk)
You can’t perform that action at this time.