This file contains hidden or 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 StableRNGs | |
| function validate2(res, n) | |
| cnt = 0 | |
| for i in res | |
| for j in res | |
| cnt += (i != j) & (i + j == n) | |
| end | |
| end | |
| cnt == 2 |
This file contains hidden or 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 | |
| using StableRNGs | |
| using Random | |
| using ThreadsX | |
| function randomwalk!(tbl, i; rng = rng) | |
| len = size(tbl, 1) | |
| tbl[1, i] = rand(rng) | |
| @inbounds for j in 2:len | |
| tbl[j, i] = (tbl[j - 1, i]) + rand(rng) |
This file contains hidden or 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 Telegram | |
| using Luxor | |
| token = ENV["TELEGRAM_BOT"] | |
| client = TelegramClient(token) | |
| useglobally!(client) | |
| function draw_turtle(angles) | |
| d = Drawing(600, 400, :png) |
This file contains hidden or 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 ParallelKMeans | |
| using BenchmarkTools | |
| using Distances | |
| using Random | |
| using UnsafeArrays | |
| Random.seed!(2020) | |
| X = rand(100, 1000) # 1000 points | |
| locations = rand(100, 10) # 10 cluster |
This file contains hidden or 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
| struct NeuralNet | |
| NetDimensions::Array | |
| LossFunction::String | |
| params::Dict | |
| end | |
| function NeuralNet(dims, loss="someloss") | |
| param = Dict() | |
| for l=2:length(dims) | |
| param["W_$(l-1)"] = rand(dims[l], dims[l-1]) * 0.1 |
This file contains hidden or 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 HTTP, DataFrames, CSV | |
| confirmed_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv" | |
| deaths_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Deaths.csv" | |
| recovered_url = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Recovered.csv" | |
| confirmed_df = CSV.File(IOBuffer(HTTP.get(confirmed_url).body)) |> DataFrame | |
| deaths_df = CSV.File(IOBuffer(HTTP.get(deaths_url).body)) |> DataFrame | |
| recovered_df = CSV.File(IOBuffer(HTTP.get(recovered_url).body)) |> DataFrame | |
| ncols = size(confirmed_df, 2) |
This file contains hidden or 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 Primes | |
| using DataFrames | |
| using VegaLite | |
| from_polar(t::Tuple) = (t[1]*cos(t[2]), t[1]*sin(t[2])) | |
| dots = primes(100000) |> z -> map(x -> (x, x), z) |> x -> from_polar.(x) | |
| DataFrame(dots) |> df -> rename!(df, [:x, :y]) |> | |
| @vlplot(mark={ | |
| type=:circle, | |
| size = 5, color = "gold" | |
| }, encoding={x = {:x, axis={grid=false}}, y = {:y, axis={grid=false}}}, |
This file contains hidden or 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 | |
| using Distributed | |
| using Base.Threads | |
| addprocs(4) | |
| nworkers() # should be 4 | |
| function f1() | |
| nheads = @distributed (+) for i = 1:200000000 | |
| Int(rand(Bool)) |
This file contains hidden or 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 PyCall | |
| using LinearAlgebra | |
| using Statistics | |
| using StatsBase | |
| using BenchmarkTools | |
| using Distances | |
| # import the same data | |
| data = pyimport("sklearn.datasets") |
This file contains hidden or 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 | |
| using StatsBase: median | |
| using DataFrames | |
| using VegaLite | |
| versioninfo() | |
| # Julia Version 1.3.1 | |
| # Commit 2d5741174c (2019-12-30 21:36 UTC) | |
| # Platform Info: | |
| # OS: Linux (x86_64-pc-linux-gnu) |