Przeglądaj źródła

hello, julia. you're interesting.

inspiration to try it again: http://www.evanmiller.org/why-im-betting-on-julia.html
Lucas Stadler 12 lat temu
rodzic
commit
e094a27a58
2 zmienionych plików z 21 dodań i 0 usunięć
  1. BIN
      jl/created_vs_push.png
  2. 21 0
      jl/github-created-vs-push.jl

BIN
jl/created_vs_push.png


+ 21 - 0
jl/github-created-vs-push.jl

@ -0,0 +1,21 @@
1
using HTTPClient
2
using JSON
3
using DataFrames
4
using Gadfly
5
6
github_get(path) = takebuf_string(get(string("https://api.github.com", path), headers=[("User-Agent", "Julia-Experiment")]).body)
7
8
function toDataFrame(dicts, keys = keys(dicts[1]))
9
    df = DataFrame()
10
    for k in keys
11
        df[k] = map(d -> d[k], dicts)
12
    end
13
    return df
14
end
15
16
repos_str = github_get("/users/mbostock/repos")
17
repos = JSON.parse(repos_str)
18
repos_df = toDataFrame(repos, filter(k -> search(k, "url") == 0:-1, keys(repos[1])))
19
20
p = plot(toDataFrame(repos), y = "pushed_at", x = "created_at", label = "name", Geom.point, Geom.label(;hide_overlaps=false))
21
draw(PNG("created_vs_push.png", 9inch, 9inch/golden), p)