├── .gitignore ├── Chapter01 ├── Chapter 1.ipynb ├── Manifest.toml └── Project.toml ├── Chapter02 ├── Chapter 2.ipynb ├── Manifest.toml └── Project.toml ├── Chapter03 ├── Chapter 3.ipynb ├── Manifest.toml ├── Project.toml └── WebCrawler │ ├── Manifest.toml │ ├── Project.toml │ └── webcrawler.jl ├── Chapter04 ├── Chapter 4.ipynb ├── Manifest.toml ├── Project.toml ├── modules │ ├── Letters.jl │ ├── Numbers.jl │ ├── module_name.jl │ └── testinclude.jl └── sixdegrees │ ├── Articles.jl │ ├── Database.jl │ ├── Gameplay.jl │ ├── Manifest.toml │ ├── Project.toml │ ├── Wikipedia.jl │ └── six_degrees.jl ├── Chapter05 ├── Chapter 5.ipynb ├── Manifest.toml ├── Project.toml ├── hello.jl └── sixdegrees │ ├── Articles.jl │ ├── Database.jl │ ├── GameSession.jl │ ├── Gameplay.jl │ ├── Manifest.toml │ ├── Project.toml │ ├── WebApp.jl │ ├── Wikipedia.jl │ └── six_degrees.jl ├── Chapter06 ├── Chapter 6.ipynb ├── Manifest.toml ├── Project.toml ├── item_based_recommendations.jl ├── top_10_movies.tsv ├── top_10_movies_user_rankings.csv ├── top_10_movies_user_rankings.tsv └── user_based_movie_recommendations.jl ├── Chapter07 ├── Chapter 7.ipynb ├── Manifest.toml ├── Project.toml └── data │ ├── BX-Book-Ratings.csv.zip │ ├── BX-Books.csv.zip │ ├── BX-Users.csv.zip │ ├── large │ ├── test_data.csv │ ├── top_ratings.csv.zip │ └── training_data.csv │ ├── test_data.csv │ ├── top_ratings.csv │ └── training_data.csv ├── Chapter08 ├── Chapter 8.ipynb ├── Manifest.toml ├── Project.toml └── data │ ├── 2017_NAICS_Index_File.xlsx │ ├── Map_of_Registered_Business_Locations.csv.zip │ ├── businesses.csv │ └── clean_df_geo.tsv.zip ├── Chapter09 ├── Chapter 9.ipynb ├── Manifest.toml └── Project.toml ├── Chapter10 ├── Chapter 10.ipynb ├── Manifest.toml ├── Project.toml └── data │ ├── UE-unemployment.tsv │ └── une_rt_m_1.tsv ├── Chapter11 ├── Chapter 11.ipynb ├── IssueReporter │ ├── .gitignore │ ├── Manifest.toml │ ├── Project.toml │ ├── README.md │ ├── docs │ │ ├── build │ │ │ ├── assets │ │ │ │ ├── arrow.svg │ │ │ │ ├── documenter.css │ │ │ │ ├── documenter.js │ │ │ │ └── search.js │ │ │ ├── index.html │ │ │ ├── search │ │ │ │ └── index.html │ │ │ └── search_index.js │ │ ├── make.jl │ │ └── src │ │ │ └── index.md │ ├── src │ │ ├── IssueReporter.jl │ │ └── secrets.jl--sample.jl │ └── test │ │ └── runtests.jl ├── Manifest.toml └── Project.toml ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vscode -------------------------------------------------------------------------------- /Chapter01/Chapter 1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "using Pkg\n", 10 | "pkg\"activate .\"" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "# Run this cell in order to download all the package dependencies with the exact versions used in the book\n", 20 | "# This is necessary if (some of) the packages have been updated and have introduced breaking changes\n", 21 | "pkg\"instantiate\"" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "2+2" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "2^3" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "println(\"Welcome to Julia\")" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "greeting = \"Hello\"" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": null, 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [ 66 | "# Oops, typo!\n", 67 | "println(greting)" 68 | ] 69 | }, 70 | { 71 | "cell_type": "code", 72 | "execution_count": null, 73 | "metadata": {}, 74 | "outputs": [], 75 | "source": [ 76 | "println(greeting)" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": null, 82 | "metadata": {}, 83 | "outputs": [], 84 | "source": [ 85 | "2^3" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": null, 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [ 94 | "ans" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": null, 100 | "metadata": { 101 | "scrolled": true 102 | }, 103 | "outputs": [], 104 | "source": [ 105 | "?println" 106 | ] 107 | }, 108 | { 109 | "cell_type": "code", 110 | "execution_count": null, 111 | "metadata": {}, 112 | "outputs": [], 113 | "source": [ 114 | "?@time" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": null, 120 | "metadata": {}, 121 | "outputs": [], 122 | "source": [ 123 | ";tail -n 10 \\~/.julia/logs/repl_history.jl" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": null, 129 | "metadata": {}, 130 | "outputs": [], 131 | "source": [ 132 | "using REPL\n", 133 | "REPL.find_hist_file()" 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": null, 139 | "metadata": { 140 | "scrolled": true 141 | }, 142 | "outputs": [], 143 | "source": [ 144 | "# run commands through Julia\n", 145 | "`mkdir $(dirname(REPL.find_hist_file()))/../config`\n", 146 | "`cd $(dirname(REPL.find_hist_file()))/../config`\n", 147 | "`touch startup.jl`" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": null, 153 | "metadata": {}, 154 | "outputs": [], 155 | "source": [ 156 | "write(\"startup.jl\", \"println(\\\"Welcome to Julia!\\\")\")" 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": null, 162 | "metadata": {}, 163 | "outputs": [], 164 | "source": [ 165 | "using Pkg\n", 166 | "pkg\"add OhMyREPL\"" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [ 175 | "pkg\"add https://github.com/JuliaLang/Example.jl.git\"" 176 | ] 177 | }, 178 | { 179 | "cell_type": "code", 180 | "execution_count": null, 181 | "metadata": {}, 182 | "outputs": [], 183 | "source": [ 184 | "pkg\"add OhMyREPL#master\"" 185 | ] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": null, 190 | "metadata": {}, 191 | "outputs": [], 192 | "source": [ 193 | "pkg\"add https://github.com/JuliaLang/Example.jl.git#master\"" 194 | ] 195 | }, 196 | { 197 | "cell_type": "code", 198 | "execution_count": null, 199 | "metadata": {}, 200 | "outputs": [], 201 | "source": [ 202 | "pkg\"free OhMyREPL\"" 203 | ] 204 | }, 205 | { 206 | "cell_type": "code", 207 | "execution_count": null, 208 | "metadata": {}, 209 | "outputs": [], 210 | "source": [ 211 | "pkg\"add Revise\"" 212 | ] 213 | }, 214 | { 215 | "cell_type": "code", 216 | "execution_count": null, 217 | "metadata": {}, 218 | "outputs": [], 219 | "source": [ 220 | "pkg\"status\"" 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": null, 226 | "metadata": {}, 227 | "outputs": [], 228 | "source": [ 229 | "pkg\"st\"" 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": null, 235 | "metadata": {}, 236 | "outputs": [], 237 | "source": [ 238 | "pkg\"update\"" 239 | ] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": null, 244 | "metadata": {}, 245 | "outputs": [], 246 | "source": [ 247 | "pkg\"update OhMyREPL Revise\"" 248 | ] 249 | }, 250 | { 251 | "cell_type": "code", 252 | "execution_count": null, 253 | "metadata": {}, 254 | "outputs": [], 255 | "source": [ 256 | "pkg\"preview update OhMyREPL\"" 257 | ] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": null, 262 | "metadata": {}, 263 | "outputs": [], 264 | "source": [ 265 | "pkg\"preview add HTTP\"" 266 | ] 267 | }, 268 | { 269 | "cell_type": "code", 270 | "execution_count": null, 271 | "metadata": {}, 272 | "outputs": [], 273 | "source": [ 274 | "pkg\"pin OhMyREPL\"" 275 | ] 276 | }, 277 | { 278 | "cell_type": "code", 279 | "execution_count": null, 280 | "metadata": {}, 281 | "outputs": [], 282 | "source": [ 283 | "pkg\"free OhMyREPL\"" 284 | ] 285 | }, 286 | { 287 | "cell_type": "code", 288 | "execution_count": null, 289 | "metadata": {}, 290 | "outputs": [], 291 | "source": [ 292 | "pkg\"st\"" 293 | ] 294 | }, 295 | { 296 | "cell_type": "code", 297 | "execution_count": null, 298 | "metadata": {}, 299 | "outputs": [], 300 | "source": [ 301 | "pkg\"remove Example\"" 302 | ] 303 | }, 304 | { 305 | "cell_type": "code", 306 | "execution_count": null, 307 | "metadata": { 308 | "scrolled": true 309 | }, 310 | "outputs": [], 311 | "source": [ 312 | "pkg\"gc\"" 313 | ] 314 | }, 315 | { 316 | "cell_type": "code", 317 | "execution_count": null, 318 | "metadata": {}, 319 | "outputs": [], 320 | "source": [] 321 | } 322 | ], 323 | "metadata": { 324 | "kernelspec": { 325 | "display_name": "Julia 1.0.1", 326 | "language": "julia", 327 | "name": "julia-1.0" 328 | }, 329 | "language_info": { 330 | "file_extension": ".jl", 331 | "mimetype": "application/julia", 332 | "name": "julia", 333 | "version": "1.0.2" 334 | } 335 | }, 336 | "nbformat": 4, 337 | "nbformat_minor": 2 338 | } 339 | -------------------------------------------------------------------------------- /Chapter01/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[Base64]] 2 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 3 | 4 | [[BinaryProvider]] 5 | deps = ["Libdl", "Pkg", "SHA", "Test"] 6 | git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" 7 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 8 | version = "0.5.3" 9 | 10 | [[Compat]] 11 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 12 | git-tree-sha1 = "ec61a16eed883ad0cfa002d7489b3ce6d039bb9a" 13 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 14 | version = "1.4.0" 15 | 16 | [[Conda]] 17 | deps = ["Compat", "JSON", "VersionParsing"] 18 | git-tree-sha1 = "fb86fe40cb5b35990e368709bfdc1b46dbb99dac" 19 | uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" 20 | version = "1.1.1" 21 | 22 | [[Crayons]] 23 | deps = ["Test"] 24 | git-tree-sha1 = "3017c662a988bcb8a3f43306a793617c6524d476" 25 | uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" 26 | version = "1.0.0" 27 | 28 | [[Dates]] 29 | deps = ["Printf"] 30 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 31 | 32 | [[DelimitedFiles]] 33 | deps = ["Mmap"] 34 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 35 | 36 | [[Distributed]] 37 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 38 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 39 | 40 | [[FileWatching]] 41 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 42 | 43 | [[IJulia]] 44 | deps = ["Base64", "Compat", "Conda", "Dates", "InteractiveUtils", "JSON", "Markdown", "MbedTLS", "Pkg", "Printf", "REPL", "Random", "SoftGlobalScope", "Test", "UUIDs", "ZMQ"] 45 | git-tree-sha1 = "38d1ce0fbbefcb67f5ab46f1093cbce0335092e0" 46 | uuid = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 47 | version = "1.14.1" 48 | 49 | [[InteractiveUtils]] 50 | deps = ["LinearAlgebra", "Markdown"] 51 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 52 | 53 | [[JSON]] 54 | deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] 55 | git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa" 56 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 57 | version = "0.20.0" 58 | 59 | [[LibGit2]] 60 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 61 | 62 | [[Libdl]] 63 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 64 | 65 | [[LinearAlgebra]] 66 | deps = ["Libdl"] 67 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 68 | 69 | [[Logging]] 70 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 71 | 72 | [[Markdown]] 73 | deps = ["Base64"] 74 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 75 | 76 | [[MbedTLS]] 77 | deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets", "Test"] 78 | git-tree-sha1 = "c93a87da4081a3de781f34e0540175795a2ce83d" 79 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 80 | version = "0.6.6" 81 | 82 | [[Mmap]] 83 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 84 | 85 | [[OhMyREPL]] 86 | deps = ["Crayons", "Logging", "Markdown", "Pkg", "Printf", "REPL", "Test", "Tokenize"] 87 | git-tree-sha1 = "c8f653694c608ea901c29622d809ef67df8ea1e2" 88 | uuid = "5fb14364-9ced-5910-84b2-373655c76a03" 89 | version = "0.4.1" 90 | 91 | [[OrderedCollections]] 92 | deps = ["Random", "Serialization", "Test"] 93 | git-tree-sha1 = "85619a3f3e17bb4761fe1b1fd47f0e979f964d5b" 94 | uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" 95 | version = "1.0.2" 96 | 97 | [[Pkg]] 98 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 99 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 100 | 101 | [[Printf]] 102 | deps = ["Unicode"] 103 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 104 | 105 | [[Profile]] 106 | deps = ["Printf"] 107 | uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" 108 | 109 | [[REPL]] 110 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 111 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 112 | 113 | [[Random]] 114 | deps = ["Serialization"] 115 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 116 | 117 | [[Revise]] 118 | deps = ["Distributed", "FileWatching", "InteractiveUtils", "LibGit2", "OrderedCollections", "Pkg", "REPL", "Random", "Test", "UUIDs", "Unicode"] 119 | git-tree-sha1 = "6e3984bb8cb0e935f75f525d70d3283298b65b3e" 120 | uuid = "295af30f-e4ad-537b-8983-00126c2a3abe" 121 | version = "0.7.14" 122 | 123 | [[SHA]] 124 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 125 | 126 | [[Serialization]] 127 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 128 | 129 | [[SharedArrays]] 130 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 131 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 132 | 133 | [[Sockets]] 134 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 135 | 136 | [[SoftGlobalScope]] 137 | deps = ["Test"] 138 | git-tree-sha1 = "97f6dfcf612b9a7260fde44170725d9ea34b1431" 139 | uuid = "b85f4697-e234-5449-a836-ec8e2f98b302" 140 | version = "1.0.7" 141 | 142 | [[SparseArrays]] 143 | deps = ["LinearAlgebra", "Random"] 144 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 145 | 146 | [[Statistics]] 147 | deps = ["LinearAlgebra", "SparseArrays"] 148 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 149 | 150 | [[Test]] 151 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 152 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 153 | 154 | [[Tokenize]] 155 | deps = ["Printf", "Test"] 156 | git-tree-sha1 = "4a9fefb5c5c831c6fc06fcc5d2ae7399918bb587" 157 | uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624" 158 | version = "0.5.2" 159 | 160 | [[UUIDs]] 161 | deps = ["Random"] 162 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 163 | 164 | [[Unicode]] 165 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 166 | 167 | [[VersionParsing]] 168 | deps = ["Compat"] 169 | git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" 170 | uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" 171 | version = "1.1.3" 172 | 173 | [[ZMQ]] 174 | deps = ["BinaryProvider", "FileWatching", "Libdl", "Sockets", "Test"] 175 | git-tree-sha1 = "34e7ac2d1d59d19d0e86bde99f1f02262bfa1613" 176 | uuid = "c2297ded-f4af-51ae-bb23-16f91089e4e1" 177 | version = "1.0.0" 178 | -------------------------------------------------------------------------------- /Chapter01/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" 3 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 4 | OhMyREPL = "5fb14364-9ced-5910-84b2-373655c76a03" 5 | Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 6 | Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" 7 | REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 8 | Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" 9 | -------------------------------------------------------------------------------- /Chapter02/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" 3 | DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" 4 | Feather = "becb17da-46f6-5d3c-ad1b-1c5fe96bc73c" 5 | Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" 6 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 7 | JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 8 | Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 9 | RDatasets = "ce6b1742-4840-55fa-b093-852dadbb1d8b" 10 | Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 11 | -------------------------------------------------------------------------------- /Chapter03/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[AbstractTrees]] 2 | deps = ["Markdown", "Test"] 3 | git-tree-sha1 = "6621d9645702c1c4e6970cc6a3eae440c768000b" 4 | uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" 5 | version = "0.2.1" 6 | 7 | [[Base64]] 8 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 9 | 10 | [[BinaryProvider]] 11 | deps = ["Libdl", "Pkg", "SHA", "Test"] 12 | git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" 13 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 14 | version = "0.5.3" 15 | 16 | [[Compat]] 17 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 18 | git-tree-sha1 = "ec61a16eed883ad0cfa002d7489b3ce6d039bb9a" 19 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 20 | version = "1.4.0" 21 | 22 | [[Conda]] 23 | deps = ["Compat", "JSON", "VersionParsing"] 24 | git-tree-sha1 = "fb86fe40cb5b35990e368709bfdc1b46dbb99dac" 25 | uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" 26 | version = "1.1.1" 27 | 28 | [[Dates]] 29 | deps = ["Printf"] 30 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 31 | 32 | [[DelimitedFiles]] 33 | deps = ["Mmap"] 34 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 35 | 36 | [[Distributed]] 37 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 38 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 39 | 40 | [[FileWatching]] 41 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 42 | 43 | [[Gumbo]] 44 | deps = ["AbstractTrees", "BinaryProvider", "Libdl", "Test"] 45 | git-tree-sha1 = "b16b6c5127e8c6be3084e6658c5fb5dd1f97d7fd" 46 | uuid = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 47 | version = "0.5.1" 48 | 49 | [[HTTP]] 50 | deps = ["Base64", "Dates", "Distributed", "IniFile", "MbedTLS", "Sockets", "Test"] 51 | git-tree-sha1 = "b881f69331e85642be315c63d05ed65d6fc8a05b" 52 | uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" 53 | version = "0.7.1" 54 | 55 | [[IJulia]] 56 | deps = ["Base64", "Compat", "Conda", "Dates", "InteractiveUtils", "JSON", "Markdown", "MbedTLS", "Pkg", "Printf", "REPL", "Random", "SoftGlobalScope", "Test", "UUIDs", "ZMQ"] 57 | git-tree-sha1 = "38d1ce0fbbefcb67f5ab46f1093cbce0335092e0" 58 | uuid = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 59 | version = "1.14.1" 60 | 61 | [[IniFile]] 62 | deps = ["Test"] 63 | git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" 64 | uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" 65 | version = "0.5.0" 66 | 67 | [[InteractiveUtils]] 68 | deps = ["LinearAlgebra", "Markdown"] 69 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 70 | 71 | [[JSON]] 72 | deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] 73 | git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa" 74 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 75 | version = "0.20.0" 76 | 77 | [[LibGit2]] 78 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 79 | 80 | [[Libdl]] 81 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 82 | 83 | [[LinearAlgebra]] 84 | deps = ["Libdl"] 85 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 86 | 87 | [[Logging]] 88 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 89 | 90 | [[Markdown]] 91 | deps = ["Base64"] 92 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 93 | 94 | [[MbedTLS]] 95 | deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets", "Test"] 96 | git-tree-sha1 = "c93a87da4081a3de781f34e0540175795a2ce83d" 97 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 98 | version = "0.6.6" 99 | 100 | [[Mmap]] 101 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 102 | 103 | [[OrderedCollections]] 104 | deps = ["Random", "Serialization", "Test"] 105 | git-tree-sha1 = "85619a3f3e17bb4761fe1b1fd47f0e979f964d5b" 106 | uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" 107 | version = "1.0.2" 108 | 109 | [[Pkg]] 110 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 111 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 112 | 113 | [[Printf]] 114 | deps = ["Unicode"] 115 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 116 | 117 | [[REPL]] 118 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 119 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 120 | 121 | [[Random]] 122 | deps = ["Serialization"] 123 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 124 | 125 | [[SHA]] 126 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 127 | 128 | [[Serialization]] 129 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 130 | 131 | [[SharedArrays]] 132 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 133 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 134 | 135 | [[Sockets]] 136 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 137 | 138 | [[SoftGlobalScope]] 139 | deps = ["Test"] 140 | git-tree-sha1 = "97f6dfcf612b9a7260fde44170725d9ea34b1431" 141 | uuid = "b85f4697-e234-5449-a836-ec8e2f98b302" 142 | version = "1.0.7" 143 | 144 | [[SparseArrays]] 145 | deps = ["LinearAlgebra", "Random"] 146 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 147 | 148 | [[Statistics]] 149 | deps = ["LinearAlgebra", "SparseArrays"] 150 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 151 | 152 | [[Test]] 153 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 154 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 155 | 156 | [[UUIDs]] 157 | deps = ["Random"] 158 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 159 | 160 | [[Unicode]] 161 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 162 | 163 | [[VersionParsing]] 164 | deps = ["Compat"] 165 | git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" 166 | uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" 167 | version = "1.1.3" 168 | 169 | [[ZMQ]] 170 | deps = ["BinaryProvider", "FileWatching", "Libdl", "Sockets", "Test"] 171 | git-tree-sha1 = "34e7ac2d1d59d19d0e86bde99f1f02262bfa1613" 172 | uuid = "c2297ded-f4af-51ae-bb23-16f91089e4e1" 173 | version = "1.0.0" 174 | -------------------------------------------------------------------------------- /Chapter03/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" 3 | Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 4 | HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" 5 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 6 | OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" 7 | Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 8 | -------------------------------------------------------------------------------- /Chapter03/WebCrawler/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[AbstractTrees]] 2 | deps = ["Markdown", "Test"] 3 | git-tree-sha1 = "feb8b2c99359901e295443c9d0c7e711604acf39" 4 | uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" 5 | version = "0.2.0" 6 | 7 | [[Base64]] 8 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 9 | 10 | [[BinaryProvider]] 11 | deps = ["Libdl", "Pkg", "SHA", "Test"] 12 | git-tree-sha1 = "b530fbeb6f41ab5a83fbe3db1fcbe879334bcd2d" 13 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 14 | version = "0.4.2" 15 | 16 | [[Compat]] 17 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 18 | git-tree-sha1 = "ae262fa91da6a74e8937add6b613f58cd56cdad4" 19 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 20 | version = "1.1.0" 21 | 22 | [[Dates]] 23 | deps = ["Printf"] 24 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 25 | 26 | [[DelimitedFiles]] 27 | deps = ["Mmap"] 28 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 29 | 30 | [[Distributed]] 31 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 32 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 33 | 34 | [[Gumbo]] 35 | deps = ["AbstractTrees", "BinaryProvider", "Libdl", "Pkg", "Test"] 36 | git-tree-sha1 = "b16b6c5127e8c6be3084e6658c5fb5dd1f97d7fd" 37 | uuid = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 38 | version = "0.5.1" 39 | 40 | [[HTTP]] 41 | deps = ["Base64", "Dates", "Distributed", "IniFile", "MbedTLS", "Sockets", "Test"] 42 | git-tree-sha1 = "8a0f75e8b09df01d9f1ba9ad3fbf8b4983595d20" 43 | uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" 44 | version = "0.6.14" 45 | 46 | [[IniFile]] 47 | deps = ["Test"] 48 | git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" 49 | uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" 50 | version = "0.5.0" 51 | 52 | [[InteractiveUtils]] 53 | deps = ["LinearAlgebra", "Markdown"] 54 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 55 | 56 | [[LibGit2]] 57 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 58 | 59 | [[Libdl]] 60 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 61 | 62 | [[LinearAlgebra]] 63 | deps = ["Libdl"] 64 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 65 | 66 | [[Logging]] 67 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 68 | 69 | [[Markdown]] 70 | deps = ["Base64"] 71 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 72 | 73 | [[MbedTLS]] 74 | deps = ["BinaryProvider", "Compat", "Libdl", "Pkg", "Sockets"] 75 | git-tree-sha1 = "17d5a81dbb1e682d4ff707c01f0afe5948068fa6" 76 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 77 | version = "0.6.0" 78 | 79 | [[Mmap]] 80 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 81 | 82 | [[Pkg]] 83 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 84 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 85 | 86 | [[Printf]] 87 | deps = ["Unicode"] 88 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 89 | 90 | [[REPL]] 91 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 92 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 93 | 94 | [[Random]] 95 | deps = ["Serialization"] 96 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 97 | 98 | [[SHA]] 99 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 100 | 101 | [[Serialization]] 102 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 103 | 104 | [[SharedArrays]] 105 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 106 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 107 | 108 | [[Sockets]] 109 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 110 | 111 | [[SparseArrays]] 112 | deps = ["LinearAlgebra", "Random"] 113 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 114 | 115 | [[Statistics]] 116 | deps = ["LinearAlgebra", "SparseArrays"] 117 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 118 | 119 | [[Test]] 120 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 121 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 122 | 123 | [[UUIDs]] 124 | deps = ["Random"] 125 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 126 | 127 | [[Unicode]] 128 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 129 | -------------------------------------------------------------------------------- /Chapter03/WebCrawler/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 3 | HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" 4 | -------------------------------------------------------------------------------- /Chapter03/WebCrawler/webcrawler.jl: -------------------------------------------------------------------------------- 1 | using HTTP, Gumbo 2 | 3 | const PAGE_URL = "https://en.wikipedia.org/wiki/Julia_(programming_language)" 4 | const LINKS = String[] 5 | 6 | function fetchpage(url) 7 | response = HTTP.get(url) 8 | if response.status == 200 && parse(Int, Dict(response.headers)["Content-Length"]) > 0 9 | String(response.body) 10 | else 11 | "" 12 | end 13 | end 14 | 15 | function extractlinks(elem) 16 | if isa(elem, HTMLElement) && 17 | tag(elem) == :a && 18 | in("href", collect(keys(attrs(elem)))) 19 | url = getattr(elem, "href") 20 | startswith(url, "/wiki/") && ! occursin(":", url) && push!(LINKS, url) 21 | end 22 | 23 | for child in children(elem) 24 | extractlinks(child) 25 | end 26 | end 27 | 28 | content = fetchpage(PAGE_URL) 29 | 30 | if ! isempty(content) 31 | dom = Gumbo.parsehtml(content) 32 | 33 | extractlinks(dom.root) 34 | end 35 | 36 | display(unique(LINKS)) 37 | -------------------------------------------------------------------------------- /Chapter04/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[AbstractTrees]] 2 | deps = ["Markdown", "Test"] 3 | git-tree-sha1 = "6621d9645702c1c4e6970cc6a3eae440c768000b" 4 | uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" 5 | version = "0.2.1" 6 | 7 | [[Base64]] 8 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 9 | 10 | [[BinDeps]] 11 | deps = ["Compat", "Libdl", "SHA", "URIParser"] 12 | git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9" 13 | uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" 14 | version = "0.8.10" 15 | 16 | [[BinaryProvider]] 17 | deps = ["Libdl", "Pkg", "SHA", "Test"] 18 | git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" 19 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 20 | version = "0.5.3" 21 | 22 | [[Cascadia]] 23 | deps = ["AbstractTrees", "Gumbo", "Test"] 24 | git-tree-sha1 = "d51428ab540880c7329c74f178a793096f4e36f0" 25 | uuid = "54eefc05-d75b-58de-a785-1a3403f0919f" 26 | version = "0.4.0" 27 | 28 | [[Compat]] 29 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 30 | git-tree-sha1 = "ec61a16eed883ad0cfa002d7489b3ce6d039bb9a" 31 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 32 | version = "1.4.0" 33 | 34 | [[Conda]] 35 | deps = ["Compat", "JSON", "VersionParsing"] 36 | git-tree-sha1 = "fb86fe40cb5b35990e368709bfdc1b46dbb99dac" 37 | uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" 38 | version = "1.1.1" 39 | 40 | [[Dates]] 41 | deps = ["Printf"] 42 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 43 | 44 | [[DecFP]] 45 | deps = ["BinaryProvider", "Compat", "Libdl", "SpecialFunctions"] 46 | git-tree-sha1 = "bb3314cdb0145ebb5bac7969b7c9e5a2a8d9ab34" 47 | uuid = "55939f99-70c6-5e9b-8bb0-5071ed7d61fd" 48 | version = "0.4.7" 49 | 50 | [[DelimitedFiles]] 51 | deps = ["Mmap"] 52 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 53 | 54 | [[Distributed]] 55 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 56 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 57 | 58 | [[FileWatching]] 59 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 60 | 61 | [[Gumbo]] 62 | deps = ["AbstractTrees", "BinaryProvider", "Libdl", "Test"] 63 | git-tree-sha1 = "b16b6c5127e8c6be3084e6658c5fb5dd1f97d7fd" 64 | uuid = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 65 | version = "0.5.1" 66 | 67 | [[HTTP]] 68 | deps = ["Base64", "Dates", "Distributed", "IniFile", "MbedTLS", "Sockets", "Test"] 69 | git-tree-sha1 = "b881f69331e85642be315c63d05ed65d6fc8a05b" 70 | uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" 71 | version = "0.7.1" 72 | 73 | [[IJulia]] 74 | deps = ["Base64", "Compat", "Conda", "Dates", "InteractiveUtils", "JSON", "Markdown", "MbedTLS", "Pkg", "Printf", "REPL", "Random", "SoftGlobalScope", "Test", "UUIDs", "ZMQ"] 75 | git-tree-sha1 = "38d1ce0fbbefcb67f5ab46f1093cbce0335092e0" 76 | uuid = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 77 | version = "1.14.1" 78 | 79 | [[IniFile]] 80 | deps = ["Test"] 81 | git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" 82 | uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" 83 | version = "0.5.0" 84 | 85 | [[InteractiveUtils]] 86 | deps = ["LinearAlgebra", "Markdown"] 87 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 88 | 89 | [[JSON]] 90 | deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] 91 | git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa" 92 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 93 | version = "0.20.0" 94 | 95 | [[LibGit2]] 96 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 97 | 98 | [[Libdl]] 99 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 100 | 101 | [[LinearAlgebra]] 102 | deps = ["Libdl"] 103 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 104 | 105 | [[Logging]] 106 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 107 | 108 | [[Markdown]] 109 | deps = ["Base64"] 110 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 111 | 112 | [[MbedTLS]] 113 | deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets", "Test"] 114 | git-tree-sha1 = "c93a87da4081a3de781f34e0540175795a2ce83d" 115 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 116 | version = "0.6.6" 117 | 118 | [[Mmap]] 119 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 120 | 121 | [[MySQL]] 122 | deps = ["BinaryProvider", "Dates", "DecFP", "Libdl", "Tables", "Test"] 123 | git-tree-sha1 = "4b9828e56c9c70a04740f5fc369bd5c65efdbd0a" 124 | uuid = "39abe10b-433b-5dbd-92d4-e302a9df00cd" 125 | version = "0.7.0" 126 | 127 | [[Pkg]] 128 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 129 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 130 | 131 | [[Printf]] 132 | deps = ["Unicode"] 133 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 134 | 135 | [[REPL]] 136 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 137 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 138 | 139 | [[Random]] 140 | deps = ["Serialization"] 141 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 142 | 143 | [[Requires]] 144 | deps = ["Test"] 145 | git-tree-sha1 = "f6fbf4ba64d295e146e49e021207993b6b48c7d1" 146 | uuid = "ae029012-a4dd-5104-9daa-d747884805df" 147 | version = "0.5.2" 148 | 149 | [[SHA]] 150 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 151 | 152 | [[Serialization]] 153 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 154 | 155 | [[SharedArrays]] 156 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 157 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 158 | 159 | [[Sockets]] 160 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 161 | 162 | [[SoftGlobalScope]] 163 | deps = ["Test"] 164 | git-tree-sha1 = "97f6dfcf612b9a7260fde44170725d9ea34b1431" 165 | uuid = "b85f4697-e234-5449-a836-ec8e2f98b302" 166 | version = "1.0.7" 167 | 168 | [[SparseArrays]] 169 | deps = ["LinearAlgebra", "Random"] 170 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 171 | 172 | [[SpecialFunctions]] 173 | deps = ["BinDeps", "BinaryProvider", "Libdl", "Test"] 174 | git-tree-sha1 = "0b45dc2e45ed77f445617b99ff2adf0f5b0f23ea" 175 | uuid = "276daf66-3868-5448-9aa4-cd146d93841b" 176 | version = "0.7.2" 177 | 178 | [[Statistics]] 179 | deps = ["LinearAlgebra", "SparseArrays"] 180 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 181 | 182 | [[Tables]] 183 | deps = ["Requires", "Test"] 184 | git-tree-sha1 = "940944e6b68a35046282897a2218891c7cf14a32" 185 | uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" 186 | version = "0.1.12" 187 | 188 | [[Test]] 189 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 190 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 191 | 192 | [[URIParser]] 193 | deps = ["Test", "Unicode"] 194 | git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" 195 | uuid = "30578b45-9adc-5946-b283-645ec420af67" 196 | version = "0.4.0" 197 | 198 | [[UUIDs]] 199 | deps = ["Random"] 200 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 201 | 202 | [[Unicode]] 203 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 204 | 205 | [[VersionParsing]] 206 | deps = ["Compat"] 207 | git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" 208 | uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" 209 | version = "1.1.3" 210 | 211 | [[ZMQ]] 212 | deps = ["BinaryProvider", "FileWatching", "Libdl", "Sockets", "Test"] 213 | git-tree-sha1 = "34e7ac2d1d59d19d0e86bde99f1f02262bfa1613" 214 | uuid = "c2297ded-f4af-51ae-bb23-16f91089e4e1" 215 | version = "1.0.0" 216 | -------------------------------------------------------------------------------- /Chapter04/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | Cascadia = "54eefc05-d75b-58de-a785-1a3403f0919f" 3 | Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 4 | HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" 5 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 6 | JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 7 | MySQL = "39abe10b-433b-5dbd-92d4-e302a9df00cd" 8 | Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 9 | Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 10 | -------------------------------------------------------------------------------- /Chapter04/modules/Letters.jl: -------------------------------------------------------------------------------- 1 | module Letters 2 | 3 | using Random 4 | 5 | export randstring 6 | 7 | const MY_NAME = "Letters" 8 | 9 | function rand() 10 | Random.rand('A':'Z') 11 | end 12 | 13 | function randstring() 14 | [rand() for _ in 1:10] |> join 15 | end 16 | 17 | include("module_name.jl") 18 | 19 | # include("Numbers.jl") 20 | 21 | end 22 | -------------------------------------------------------------------------------- /Chapter04/modules/Numbers.jl: -------------------------------------------------------------------------------- 1 | module Numbers 2 | 3 | using Random 4 | 5 | export halfrand 6 | 7 | const MY_NAME = "Numbers" 8 | 9 | function rand() 10 | Random.rand(1:1_000) 11 | end 12 | 13 | function halfrand() 14 | floor(rand() / 2) 15 | end 16 | 17 | include("module_name.jl") 18 | 19 | end 20 | -------------------------------------------------------------------------------- /Chapter04/modules/module_name.jl: -------------------------------------------------------------------------------- 1 | function myname() 2 | MY_NAME 3 | end 4 | -------------------------------------------------------------------------------- /Chapter04/modules/testinclude.jl: -------------------------------------------------------------------------------- 1 | somevar = 10 2 | -------------------------------------------------------------------------------- /Chapter04/sixdegrees/Articles.jl: -------------------------------------------------------------------------------- 1 | module Articles 2 | 3 | export Article, save, find 4 | 5 | using ...Database, MySQL, JSON 6 | 7 | struct Article 8 | content::String 9 | links::Vector{String} 10 | title::String 11 | image::String 12 | url::String 13 | 14 | Article(; content = "", links = String[], title = "", image = "", url = "") = new(content, links, title, image, url) 15 | Article(content, links, title, image, url) = new(content, links, title, image, url) 16 | end 17 | 18 | function find(url) :: Vector{Article} 19 | articles = Article[] 20 | 21 | result = MySQL.query(CONN, "SELECT * FROM `articles` WHERE url = '$url'") 22 | 23 | isempty(result.url) && return articles 24 | 25 | for i in eachindex(result.url) 26 | push!(articles, Article(result.content[i], 27 | JSON.parse(result.links[i]), 28 | result.title[i], 29 | result.image[i], 30 | result.url[i])) 31 | end 32 | 33 | articles 34 | end 35 | 36 | function save(a::Article) 37 | sql = "INSERT IGNORE INTO articles 38 | (title, content, links, image, url) VALUES (?, ?, ?, ?, ?)" 39 | stmt = MySQL.Stmt(CONN, sql) 40 | result = MySQL.execute!(stmt, 41 | [ a.title, 42 | a.content, 43 | JSON.json(a.links), 44 | a.image, 45 | a.url] 46 | ) 47 | end 48 | 49 | function createtable() 50 | sql = """ 51 | CREATE TABLE `articles` ( 52 | `title` varchar(1000), 53 | `content` text, 54 | `links` text, 55 | `image` varchar(500), 56 | `url` varchar(500), 57 | UNIQUE KEY `url` (`url`) 58 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 59 | """ 60 | 61 | MySQL.execute!(CONN, sql) 62 | end 63 | 64 | end 65 | -------------------------------------------------------------------------------- /Chapter04/sixdegrees/Database.jl: -------------------------------------------------------------------------------- 1 | module Database 2 | 3 | using MySQL 4 | 5 | const HOST = "localhost" 6 | const USER = "root" 7 | const PASS = "root" 8 | const DB = "six_degrees" 9 | 10 | const CONN = MySQL.connect(HOST, USER, PASS, db = DB) 11 | 12 | export CONN 13 | 14 | disconnect() = MySQL.disconnect(CONN) 15 | 16 | atexit(disconnect) 17 | 18 | end 19 | -------------------------------------------------------------------------------- /Chapter04/sixdegrees/Gameplay.jl: -------------------------------------------------------------------------------- 1 | module Gameplay 2 | 3 | using ..Wikipedia, ..Wikipedia.Articles 4 | 5 | export newgame 6 | 7 | const DIFFICULTY_EASY = 2 8 | const DIFFICULTY_MEDIUM = 4 9 | const DIFFICULTY_HARD = 6 10 | 11 | function newgame(difficulty = DIFFICULTY_HARD) 12 | articles = Article[] 13 | 14 | for i in 1:difficulty+1 15 | article = if i == 1 16 | article = persistedarticle(fetchrandom()...) 17 | else 18 | url = rand(articles[i-1].links) 19 | existing_articles = Articles.find(url) 20 | 21 | article = isempty(existing_articles) ? persistedarticle(fetchpage(url)...) : existing_articles[1] 22 | end 23 | 24 | push!(articles, article) 25 | end 26 | 27 | articles 28 | end 29 | 30 | end 31 | -------------------------------------------------------------------------------- /Chapter04/sixdegrees/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[AbstractTrees]] 2 | deps = ["Markdown", "Test"] 3 | git-tree-sha1 = "feb8b2c99359901e295443c9d0c7e711604acf39" 4 | uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" 5 | version = "0.2.0" 6 | 7 | [[Base64]] 8 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 9 | 10 | [[BinDeps]] 11 | deps = ["Compat", "Libdl", "SHA", "URIParser"] 12 | git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9" 13 | uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" 14 | version = "0.8.10" 15 | 16 | [[BinaryProvider]] 17 | deps = ["Libdl", "Pkg", "SHA", "Test"] 18 | git-tree-sha1 = "48c147e63431adbcee69bc40b04c3f0fec0a4982" 19 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 20 | version = "0.5.0" 21 | 22 | [[Cascadia]] 23 | deps = ["AbstractTrees", "Gumbo", "Test"] 24 | git-tree-sha1 = "d51428ab540880c7329c74f178a793096f4e36f0" 25 | uuid = "54eefc05-d75b-58de-a785-1a3403f0919f" 26 | version = "0.4.0" 27 | 28 | [[Compat]] 29 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 30 | git-tree-sha1 = "ae262fa91da6a74e8937add6b613f58cd56cdad4" 31 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 32 | version = "1.1.0" 33 | 34 | [[DataStreams]] 35 | deps = ["Dates", "Missings", "Pkg", "Test", "WeakRefStrings"] 36 | git-tree-sha1 = "69c72a1beb4fc79490c361635664e13c8e4a9548" 37 | uuid = "9a8bc11e-79be-5b39-94d7-1ccc349a1a85" 38 | version = "0.4.1" 39 | 40 | [[Dates]] 41 | deps = ["Printf"] 42 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 43 | 44 | [[DecFP]] 45 | deps = ["BinaryProvider", "Compat", "Libdl", "SpecialFunctions"] 46 | git-tree-sha1 = "5c783376875e7f7757d574945a97c3afb56ae2c5" 47 | uuid = "55939f99-70c6-5e9b-8bb0-5071ed7d61fd" 48 | version = "0.4.6" 49 | 50 | [[DelimitedFiles]] 51 | deps = ["Mmap"] 52 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 53 | 54 | [[Distributed]] 55 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 56 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 57 | 58 | [[Gumbo]] 59 | deps = ["AbstractTrees", "BinaryProvider", "Libdl", "Pkg", "Test"] 60 | git-tree-sha1 = "b16b6c5127e8c6be3084e6658c5fb5dd1f97d7fd" 61 | uuid = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 62 | version = "0.5.1" 63 | 64 | [[HTTP]] 65 | deps = ["Base64", "Dates", "Distributed", "IniFile", "MbedTLS", "Sockets", "Test"] 66 | git-tree-sha1 = "16499da36240bf80df9a7e9b0f228710be1fe37c" 67 | uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" 68 | version = "0.7.0" 69 | 70 | [[IniFile]] 71 | deps = ["Test"] 72 | git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" 73 | uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" 74 | version = "0.5.0" 75 | 76 | [[InteractiveUtils]] 77 | deps = ["LinearAlgebra", "Markdown"] 78 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 79 | 80 | [[JSON]] 81 | deps = ["Dates", "Distributed", "Mmap", "Pkg", "Sockets", "Test", "Unicode"] 82 | git-tree-sha1 = "fec8e4d433072731466d37ed0061b3ba7f70eeb9" 83 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 84 | version = "0.19.0" 85 | 86 | [[LibGit2]] 87 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 88 | 89 | [[Libdl]] 90 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 91 | 92 | [[LinearAlgebra]] 93 | deps = ["Libdl"] 94 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 95 | 96 | [[Logging]] 97 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 98 | 99 | [[Markdown]] 100 | deps = ["Base64"] 101 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 102 | 103 | [[MbedTLS]] 104 | deps = ["BinaryProvider", "Libdl", "Pkg", "Random", "Sockets", "Test"] 105 | git-tree-sha1 = "30016e3f9359f43b76cc2185efea5de5f6c9aa62" 106 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 107 | version = "0.6.2" 108 | 109 | [[Missings]] 110 | deps = ["Dates", "InteractiveUtils", "SparseArrays", "Test"] 111 | git-tree-sha1 = "adc26d2ee85a49c413464110d922cf21efc9d233" 112 | uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" 113 | version = "0.3.1" 114 | 115 | [[Mmap]] 116 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 117 | 118 | [[MySQL]] 119 | deps = ["BinaryProvider", "DataStreams", "Dates", "DecFP", "Libdl", "Missings", "Pkg", "Test"] 120 | git-tree-sha1 = "2f14118e79226c5c8f827e13c83de1368b59fede" 121 | uuid = "39abe10b-433b-5dbd-92d4-e302a9df00cd" 122 | version = "0.6.0" 123 | 124 | [[Pkg]] 125 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 126 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 127 | 128 | [[Printf]] 129 | deps = ["Unicode"] 130 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 131 | 132 | [[REPL]] 133 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 134 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 135 | 136 | [[Random]] 137 | deps = ["Serialization"] 138 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 139 | 140 | [[SHA]] 141 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 142 | 143 | [[Serialization]] 144 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 145 | 146 | [[SharedArrays]] 147 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 148 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 149 | 150 | [[Sockets]] 151 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 152 | 153 | [[SparseArrays]] 154 | deps = ["LinearAlgebra", "Random"] 155 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 156 | 157 | [[SpecialFunctions]] 158 | deps = ["BinDeps", "BinaryProvider", "Libdl", "Test"] 159 | git-tree-sha1 = "c35c9c76008babf4d658060fc64aeb369a41e7bd" 160 | uuid = "276daf66-3868-5448-9aa4-cd146d93841b" 161 | version = "0.7.1" 162 | 163 | [[Statistics]] 164 | deps = ["LinearAlgebra", "SparseArrays"] 165 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 166 | 167 | [[Test]] 168 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 169 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 170 | 171 | [[URIParser]] 172 | deps = ["Test", "Unicode"] 173 | git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" 174 | uuid = "30578b45-9adc-5946-b283-645ec420af67" 175 | version = "0.4.0" 176 | 177 | [[UUIDs]] 178 | deps = ["Random"] 179 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 180 | 181 | [[Unicode]] 182 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 183 | 184 | [[WeakRefStrings]] 185 | deps = ["Missings", "Random", "Test"] 186 | git-tree-sha1 = "1087e8be380f2c8b96434b02bb1150fc1c511135" 187 | uuid = "ea10d353-3f73-51f8-a26c-33c1cb351aa5" 188 | version = "0.5.3" 189 | -------------------------------------------------------------------------------- /Chapter04/sixdegrees/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | Cascadia = "54eefc05-d75b-58de-a785-1a3403f0919f" 3 | Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 4 | HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" 5 | JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 6 | MySQL = "39abe10b-433b-5dbd-92d4-e302a9df00cd" 7 | -------------------------------------------------------------------------------- /Chapter04/sixdegrees/Wikipedia.jl: -------------------------------------------------------------------------------- 1 | module Wikipedia 2 | 3 | using HTTP, Gumbo, Cascadia 4 | import Cascadia: matchFirst 5 | 6 | include("Articles.jl") 7 | using .Articles 8 | 9 | const PROTOCOL = "https://" 10 | const DOMAIN_NAME = "en.m.wikipedia.org" 11 | const RANDOM_PAGE_URL = PROTOCOL * DOMAIN_NAME * "/wiki/Special:Random" 12 | 13 | export fetchrandom, fetchpage, articleinfo, persistedarticle 14 | 15 | # function fetchpage(url) 16 | # url = startswith(url, "/") ? buildurl(url) : url 17 | # 18 | # response = HTTP.get(url) 19 | # 20 | # if response.status == 200 && length(response.body) > 0 21 | # String(response.body) 22 | # else 23 | # "" 24 | # end 25 | # end 26 | 27 | function fetchpage(url) 28 | url = startswith(url, "/") ? buildurl(url) : url 29 | response = HTTP.get(url) 30 | content = if response.status == 200 && length(response.body) > 0 31 | String(response.body) 32 | else 33 | "" 34 | end 35 | relative_url = collect(eachmatch(r"/wiki/(.*)$", (response.request.parent == nothing ? url : Dict(response.request.parent.headers)["Location"])))[1].match 36 | 37 | content, relative_url 38 | end 39 | 40 | 41 | function extractlinks(elem) 42 | map(eachmatch(Selector("a[href^='/wiki/']:not(a[href*=':'])"), elem)) do e 43 | e.attributes["href"] 44 | end |> unique 45 | end 46 | 47 | function extracttitle(elem) 48 | matchFirst(Selector("#section_0"), elem) |> nodeText 49 | end 50 | 51 | function extractimage(elem) 52 | e = matchFirst(Selector(".content a.image img"), elem) 53 | isa(e, Nothing) ? "" : e.attributes["src"] 54 | end 55 | 56 | function fetchrandom() 57 | fetchpage(RANDOM_PAGE_URL) 58 | end 59 | 60 | function articledom(content) 61 | if ! isempty(content) 62 | return Gumbo.parsehtml(content) 63 | end 64 | 65 | error("Article content can not be parsed into DOM") 66 | end 67 | 68 | # function articleinfo(content) 69 | # dom = articledom(content) 70 | # 71 | # Dict( :content => content, 72 | # :links => extractlinks(dom.root), 73 | # :title => extracttitle(dom.root), 74 | # :image => extractimage(dom.root) 75 | # ) 76 | # end 77 | 78 | # function articleinfo(content) 79 | # dom = articledom(content) 80 | # Article(content, 81 | # extractlinks(dom.root), 82 | # extracttitle(dom.root), 83 | # extractimage(dom.root)) 84 | # end 85 | 86 | function articleinfo(content) 87 | dom = articledom(content) 88 | (content, extractlinks(dom.root), extracttitle(dom.root), extractimage(dom.root)) 89 | end 90 | 91 | function persistedarticle(article_content, url) 92 | article = Article(articleinfo(article_content)..., url) 93 | save(article) 94 | 95 | article 96 | end 97 | 98 | function buildurl(article_url) 99 | PROTOCOL * DOMAIN_NAME * article_url 100 | end 101 | 102 | end 103 | -------------------------------------------------------------------------------- /Chapter04/sixdegrees/six_degrees.jl: -------------------------------------------------------------------------------- 1 | using Pkg 2 | pkg"activate ." 3 | 4 | include("Database.jl") 5 | include("Wikipedia.jl") 6 | include("Gameplay.jl") 7 | 8 | using .Wikipedia, .Gameplay 9 | 10 | articles = newgame(Gameplay.DIFFICULTY_EASY) 11 | 12 | for article in articles 13 | println(article.title) 14 | end 15 | -------------------------------------------------------------------------------- /Chapter05/Chapter 5.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "using Pkg\n", 10 | "pkg\"activate .\"" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "# Run this cell in order to download all the package dependencies with the exact versions used in the book\n", 20 | "# This is necessary if (some of) the packages have been updated and have introduced breaking changes\n", 21 | "pkg\"instantiate\"" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "using HTTP, Sockets\n", 31 | "\n", 32 | "const HOST = ip\"0.0.0.0\"\n", 33 | "const PORT = 9999\n", 34 | "\n", 35 | "router = HTTP.Router()\n", 36 | "server = HTTP.Server(router)\n", 37 | "\n", 38 | "HTTP.register!(router, \"/\", HTTP.HandlerFunction(req -> HTTP.Messages.Response(200, \"Hello World\")))\n", 39 | "HTTP.register!(router, \"/bye\", HTTP.HandlerFunction(req -> HTTP.Messages.Response(200, \"Bye\")))\n", 40 | "HTTP.register!(router, \"*\", HTTP.HandlerFunction(req -> HTTP.Messages.Response(404, \"Not found\")))\n", 41 | "\n", 42 | "HTTP.serve(server, HOST, PORT)" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": null, 48 | "metadata": {}, 49 | "outputs": [], 50 | "source": [] 51 | } 52 | ], 53 | "metadata": { 54 | "kernelspec": { 55 | "display_name": "Julia 1.0.1", 56 | "language": "julia", 57 | "name": "julia-1.0" 58 | }, 59 | "language_info": { 60 | "file_extension": ".jl", 61 | "mimetype": "application/julia", 62 | "name": "julia", 63 | "version": "1.0.2" 64 | } 65 | }, 66 | "nbformat": 4, 67 | "nbformat_minor": 2 68 | } 69 | -------------------------------------------------------------------------------- /Chapter05/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[AbstractTrees]] 2 | deps = ["Markdown", "Test"] 3 | git-tree-sha1 = "6621d9645702c1c4e6970cc6a3eae440c768000b" 4 | uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" 5 | version = "0.2.1" 6 | 7 | [[Base64]] 8 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 9 | 10 | [[BinaryProvider]] 11 | deps = ["Libdl", "Pkg", "SHA", "Test"] 12 | git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" 13 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 14 | version = "0.5.3" 15 | 16 | [[Cascadia]] 17 | deps = ["AbstractTrees", "Gumbo", "Test"] 18 | git-tree-sha1 = "d51428ab540880c7329c74f178a793096f4e36f0" 19 | uuid = "54eefc05-d75b-58de-a785-1a3403f0919f" 20 | version = "0.4.0" 21 | 22 | [[Compat]] 23 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 24 | git-tree-sha1 = "ec61a16eed883ad0cfa002d7489b3ce6d039bb9a" 25 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 26 | version = "1.4.0" 27 | 28 | [[Conda]] 29 | deps = ["Compat", "JSON", "VersionParsing"] 30 | git-tree-sha1 = "fb86fe40cb5b35990e368709bfdc1b46dbb99dac" 31 | uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" 32 | version = "1.1.1" 33 | 34 | [[Dates]] 35 | deps = ["Printf"] 36 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 37 | 38 | [[DelimitedFiles]] 39 | deps = ["Mmap"] 40 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 41 | 42 | [[Distributed]] 43 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 44 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 45 | 46 | [[FileWatching]] 47 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 48 | 49 | [[Gumbo]] 50 | deps = ["AbstractTrees", "BinaryProvider", "Libdl", "Test"] 51 | git-tree-sha1 = "b16b6c5127e8c6be3084e6658c5fb5dd1f97d7fd" 52 | uuid = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 53 | version = "0.5.1" 54 | 55 | [[HTTP]] 56 | deps = ["Base64", "Dates", "Distributed", "IniFile", "MbedTLS", "Sockets", "Test"] 57 | git-tree-sha1 = "b881f69331e85642be315c63d05ed65d6fc8a05b" 58 | uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" 59 | version = "0.7.1" 60 | 61 | [[IJulia]] 62 | deps = ["Base64", "Compat", "Conda", "Dates", "InteractiveUtils", "JSON", "Markdown", "MbedTLS", "Pkg", "Printf", "REPL", "Random", "SoftGlobalScope", "Test", "UUIDs", "ZMQ"] 63 | git-tree-sha1 = "38d1ce0fbbefcb67f5ab46f1093cbce0335092e0" 64 | uuid = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 65 | version = "1.14.1" 66 | 67 | [[IniFile]] 68 | deps = ["Test"] 69 | git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" 70 | uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" 71 | version = "0.5.0" 72 | 73 | [[InteractiveUtils]] 74 | deps = ["LinearAlgebra", "Markdown"] 75 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 76 | 77 | [[JSON]] 78 | deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] 79 | git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa" 80 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 81 | version = "0.20.0" 82 | 83 | [[LibGit2]] 84 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 85 | 86 | [[Libdl]] 87 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 88 | 89 | [[LinearAlgebra]] 90 | deps = ["Libdl"] 91 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 92 | 93 | [[Logging]] 94 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 95 | 96 | [[Markdown]] 97 | deps = ["Base64"] 98 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 99 | 100 | [[MbedTLS]] 101 | deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets", "Test"] 102 | git-tree-sha1 = "c93a87da4081a3de781f34e0540175795a2ce83d" 103 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 104 | version = "0.6.6" 105 | 106 | [[Mmap]] 107 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 108 | 109 | [[Pkg]] 110 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 111 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 112 | 113 | [[Printf]] 114 | deps = ["Unicode"] 115 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 116 | 117 | [[REPL]] 118 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 119 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 120 | 121 | [[Random]] 122 | deps = ["Serialization"] 123 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 124 | 125 | [[SHA]] 126 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 127 | 128 | [[Serialization]] 129 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 130 | 131 | [[SharedArrays]] 132 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 133 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 134 | 135 | [[Sockets]] 136 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 137 | 138 | [[SoftGlobalScope]] 139 | deps = ["Test"] 140 | git-tree-sha1 = "97f6dfcf612b9a7260fde44170725d9ea34b1431" 141 | uuid = "b85f4697-e234-5449-a836-ec8e2f98b302" 142 | version = "1.0.7" 143 | 144 | [[SparseArrays]] 145 | deps = ["LinearAlgebra", "Random"] 146 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 147 | 148 | [[Statistics]] 149 | deps = ["LinearAlgebra", "SparseArrays"] 150 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 151 | 152 | [[Test]] 153 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 154 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 155 | 156 | [[UUIDs]] 157 | deps = ["Random"] 158 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 159 | 160 | [[Unicode]] 161 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 162 | 163 | [[VersionParsing]] 164 | deps = ["Compat"] 165 | git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" 166 | uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" 167 | version = "1.1.3" 168 | 169 | [[ZMQ]] 170 | deps = ["BinaryProvider", "FileWatching", "Libdl", "Sockets", "Test"] 171 | git-tree-sha1 = "34e7ac2d1d59d19d0e86bde99f1f02262bfa1613" 172 | uuid = "c2297ded-f4af-51ae-bb23-16f91089e4e1" 173 | version = "1.0.0" 174 | -------------------------------------------------------------------------------- /Chapter05/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | Cascadia = "54eefc05-d75b-58de-a785-1a3403f0919f" 3 | Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 4 | HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" 5 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 6 | Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 7 | Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 8 | Sockets = "6462fe0b-24de-5631-8697-dd941f90decc" 9 | -------------------------------------------------------------------------------- /Chapter05/hello.jl: -------------------------------------------------------------------------------- 1 | using HTTP, Sockets 2 | 3 | const HOST = ip"0.0.0.0" 4 | const PORT = 9999 5 | 6 | router = HTTP.Router() 7 | server = HTTP.Server(router) 8 | 9 | HTTP.register!(router, "/", HTTP.HandlerFunction(req -> HTTP.Messages.Response(200, "Hello World"))) 10 | HTTP.register!(router, "/bye", HTTP.HandlerFunction(req -> HTTP.Messages.Response(200, "Bye"))) 11 | HTTP.register!(router, "*", HTTP.HandlerFunction(req -> HTTP.Messages.Response(404, "Not found"))) 12 | 13 | HTTP.serve(server, HOST, PORT) 14 | -------------------------------------------------------------------------------- /Chapter05/sixdegrees/Articles.jl: -------------------------------------------------------------------------------- 1 | module Articles 2 | 3 | export Article, save, find 4 | 5 | using ...Database, MySQL, JSON 6 | 7 | struct Article 8 | content::String 9 | links::Vector{String} 10 | title::String 11 | image::String 12 | url::String 13 | 14 | Article(; content = "", links = String[], title = "", image = "", url = "") = new(content, links, title, image, url) 15 | Article(content, links, title, image, url) = new(content, links, title, image, url) 16 | end 17 | 18 | function find(url) :: Vector{Article} 19 | articles = Article[] 20 | 21 | result = MySQL.query(CONN, "SELECT * FROM `articles` WHERE url = '$url'") 22 | 23 | isempty(result.url) && return articles 24 | 25 | for i in eachindex(result.url) 26 | push!(articles, Article(result.content[i], 27 | JSON.parse(result.links[i]), 28 | result.title[i], 29 | result.image[i], 30 | result.url[i])) 31 | end 32 | 33 | articles 34 | end 35 | 36 | function save(a::Article) 37 | sql = "INSERT IGNORE INTO articles 38 | (title, content, links, image, url) VALUES (?, ?, ?, ?, ?)" 39 | stmt = MySQL.Stmt(CONN, sql) 40 | result = MySQL.execute!(stmt, 41 | [ a.title, 42 | a.content, 43 | JSON.json(a.links), 44 | a.image, 45 | a.url] 46 | ) 47 | end 48 | 49 | function createtable() 50 | sql = """ 51 | CREATE TABLE `articles` ( 52 | `title` varchar(1000), 53 | `content` text, 54 | `links` text, 55 | `image` varchar(500), 56 | `url` varchar(500), 57 | UNIQUE KEY `url` (`url`) 58 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 59 | """ 60 | 61 | MySQL.execute!(CONN, sql) 62 | end 63 | 64 | end 65 | -------------------------------------------------------------------------------- /Chapter05/sixdegrees/Database.jl: -------------------------------------------------------------------------------- 1 | module Database 2 | 3 | using MySQL 4 | 5 | const HOST = "127.0.0.1" 6 | const USER = "root" 7 | const PASS = "root" 8 | const DB = "six_degrees" 9 | const PORT = 8889 10 | 11 | const CONN = MySQL.connect(HOST, USER, PASS, db = DB, port = PORT) 12 | 13 | export CONN 14 | 15 | disconnect() = MySQL.disconnect(CONN) 16 | 17 | atexit(disconnect) 18 | 19 | end 20 | -------------------------------------------------------------------------------- /Chapter05/sixdegrees/GameSession.jl: -------------------------------------------------------------------------------- 1 | module GameSession 2 | 3 | using ..Gameplay, ..Wikipedia, ..Wikipedia.Articles 4 | using Random 5 | 6 | mutable struct Game 7 | id::String 8 | articles::Vector{Article} 9 | history::Vector{Article} 10 | steps_taken::UInt8 11 | difficulty::UInt8 12 | 13 | Game(game_difficulty) = new(randstring(), newgame(game_difficulty), Article[], 0, game_difficulty) 14 | end 15 | 16 | const GAMES = Dict{String,Game}() 17 | 18 | export newgamesession, gamesession, destroygamesession 19 | 20 | function newgamesession(difficulty) 21 | game = Game(difficulty) 22 | GAMES[game.id] = game 23 | 24 | game 25 | end 26 | 27 | function gamesession(id) 28 | GAMES[id] 29 | end 30 | 31 | function destroygamesession(id) 32 | delete!(GAMES, id) 33 | end 34 | 35 | end 36 | -------------------------------------------------------------------------------- /Chapter05/sixdegrees/Gameplay.jl: -------------------------------------------------------------------------------- 1 | module Gameplay 2 | 3 | using ..Wikipedia, ..Wikipedia.Articles 4 | 5 | export newgame 6 | 7 | const DIFFICULTY_EASY = 2 8 | const DIFFICULTY_MEDIUM = 4 9 | const DIFFICULTY_HARD = 6 10 | 11 | const MAX_NUMBER_OF_STEPS = 10 12 | 13 | function newgame(difficulty = DIFFICULTY_HARD) 14 | articles = Article[] 15 | 16 | for i in 1:difficulty+1 17 | article = if i == 1 18 | article = persistedarticle(fetchrandom()...) 19 | else 20 | url = rand(articles[i-1].links) 21 | existing_articles = Articles.find(url) 22 | 23 | article = isempty(existing_articles) ? persistedarticle(fetchpage(url)...) : existing_articles[1] 24 | end 25 | 26 | push!(articles, article) 27 | end 28 | 29 | articles 30 | end 31 | 32 | end 33 | -------------------------------------------------------------------------------- /Chapter05/sixdegrees/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[AbstractTrees]] 2 | deps = ["Markdown", "Test"] 3 | git-tree-sha1 = "feb8b2c99359901e295443c9d0c7e711604acf39" 4 | uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" 5 | version = "0.2.0" 6 | 7 | [[Base64]] 8 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 9 | 10 | [[BinDeps]] 11 | deps = ["Compat", "Libdl", "SHA", "URIParser"] 12 | git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9" 13 | uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" 14 | version = "0.8.10" 15 | 16 | [[BinaryProvider]] 17 | deps = ["Libdl", "Pkg", "SHA", "Test"] 18 | git-tree-sha1 = "48c147e63431adbcee69bc40b04c3f0fec0a4982" 19 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 20 | version = "0.5.0" 21 | 22 | [[Cascadia]] 23 | deps = ["AbstractTrees", "Gumbo", "Test"] 24 | git-tree-sha1 = "d51428ab540880c7329c74f178a793096f4e36f0" 25 | uuid = "54eefc05-d75b-58de-a785-1a3403f0919f" 26 | version = "0.4.0" 27 | 28 | [[Compat]] 29 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 30 | git-tree-sha1 = "ff2595695fc4f14427358ce2593f867085c45dcb" 31 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 32 | version = "1.2.0" 33 | 34 | [[Dates]] 35 | deps = ["Printf"] 36 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 37 | 38 | [[DecFP]] 39 | deps = ["BinaryProvider", "Compat", "Libdl", "SpecialFunctions"] 40 | git-tree-sha1 = "5c783376875e7f7757d574945a97c3afb56ae2c5" 41 | uuid = "55939f99-70c6-5e9b-8bb0-5071ed7d61fd" 42 | version = "0.4.6" 43 | 44 | [[DelimitedFiles]] 45 | deps = ["Mmap"] 46 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 47 | 48 | [[Distributed]] 49 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 50 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 51 | 52 | [[Gumbo]] 53 | deps = ["AbstractTrees", "BinaryProvider", "Libdl", "Pkg", "Test"] 54 | git-tree-sha1 = "b16b6c5127e8c6be3084e6658c5fb5dd1f97d7fd" 55 | uuid = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 56 | version = "0.5.1" 57 | 58 | [[HTTP]] 59 | deps = ["Base64", "Dates", "Distributed", "IniFile", "MbedTLS", "Sockets", "Test"] 60 | git-tree-sha1 = "b881f69331e85642be315c63d05ed65d6fc8a05b" 61 | uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" 62 | version = "0.7.1" 63 | 64 | [[IniFile]] 65 | deps = ["Test"] 66 | git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" 67 | uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" 68 | version = "0.5.0" 69 | 70 | [[InteractiveUtils]] 71 | deps = ["LinearAlgebra", "Markdown"] 72 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 73 | 74 | [[JSON]] 75 | deps = ["Dates", "Distributed", "Mmap", "Pkg", "Sockets", "Test", "Unicode"] 76 | git-tree-sha1 = "fec8e4d433072731466d37ed0061b3ba7f70eeb9" 77 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 78 | version = "0.19.0" 79 | 80 | [[LibGit2]] 81 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 82 | 83 | [[Libdl]] 84 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 85 | 86 | [[LinearAlgebra]] 87 | deps = ["Libdl"] 88 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 89 | 90 | [[Logging]] 91 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 92 | 93 | [[Markdown]] 94 | deps = ["Base64"] 95 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 96 | 97 | [[MbedTLS]] 98 | deps = ["BinaryProvider", "Libdl", "Pkg", "Random", "Sockets", "Test"] 99 | git-tree-sha1 = "3775d205b09b624aa06d39012a8920ba99cb3b8b" 100 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 101 | version = "0.6.3" 102 | 103 | [[Mmap]] 104 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 105 | 106 | [[MySQL]] 107 | deps = ["BinaryProvider", "Dates", "DecFP", "Libdl", "Pkg", "Tables", "Test"] 108 | git-tree-sha1 = "4b9828e56c9c70a04740f5fc369bd5c65efdbd0a" 109 | uuid = "39abe10b-433b-5dbd-92d4-e302a9df00cd" 110 | version = "0.7.0" 111 | 112 | [[Pkg]] 113 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 114 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 115 | 116 | [[Printf]] 117 | deps = ["Unicode"] 118 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 119 | 120 | [[REPL]] 121 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 122 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 123 | 124 | [[Random]] 125 | deps = ["Serialization"] 126 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 127 | 128 | [[Requires]] 129 | deps = ["Test"] 130 | git-tree-sha1 = "f6fbf4ba64d295e146e49e021207993b6b48c7d1" 131 | uuid = "ae029012-a4dd-5104-9daa-d747884805df" 132 | version = "0.5.2" 133 | 134 | [[SHA]] 135 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 136 | 137 | [[Serialization]] 138 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 139 | 140 | [[SharedArrays]] 141 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 142 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 143 | 144 | [[Sockets]] 145 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 146 | 147 | [[SparseArrays]] 148 | deps = ["LinearAlgebra", "Random"] 149 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 150 | 151 | [[SpecialFunctions]] 152 | deps = ["BinDeps", "BinaryProvider", "Libdl", "Test"] 153 | git-tree-sha1 = "c35c9c76008babf4d658060fc64aeb369a41e7bd" 154 | uuid = "276daf66-3868-5448-9aa4-cd146d93841b" 155 | version = "0.7.1" 156 | 157 | [[Statistics]] 158 | deps = ["LinearAlgebra", "SparseArrays"] 159 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 160 | 161 | [[Tables]] 162 | deps = ["Pkg", "Requires", "Test"] 163 | git-tree-sha1 = "277464179bc7cfb1b4d5a4f3ccde0fc75792157f" 164 | uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" 165 | version = "0.1.8" 166 | 167 | [[Test]] 168 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 169 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 170 | 171 | [[URIParser]] 172 | deps = ["Test", "Unicode"] 173 | git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" 174 | uuid = "30578b45-9adc-5946-b283-645ec420af67" 175 | version = "0.4.0" 176 | 177 | [[UUIDs]] 178 | deps = ["Random"] 179 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 180 | 181 | [[Unicode]] 182 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 183 | -------------------------------------------------------------------------------- /Chapter05/sixdegrees/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | Cascadia = "54eefc05-d75b-58de-a785-1a3403f0919f" 3 | Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a" 4 | HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" 5 | JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 6 | MySQL = "39abe10b-433b-5dbd-92d4-e302a9df00cd" 7 | -------------------------------------------------------------------------------- /Chapter05/sixdegrees/WebApp.jl: -------------------------------------------------------------------------------- 1 | module WebApp 2 | 3 | using HTTP, Sockets 4 | using ..Gameplay, ..GameSession, ..Wikipedia, ..Wikipedia.Articles 5 | 6 | # Configuration 7 | const HOST = ip"0.0.0.0" 8 | const PORT = 8888 9 | const ROUTER = HTTP.Router() 10 | const SERVER = HTTP.Server(ROUTER) 11 | 12 | # Functions 13 | function wikiarticle(game, article) 14 | html = """ 15 | 16 | 17 | $(head()) 18 | 19 | 20 | $(objective(game)) 21 |
22 | $( 23 | if losinggame(game) 24 | "

You Lost :(

" 25 | else 26 | puzzlesolved(game, article) ? "

You Won!

" : "" 27 | end 28 | ) 29 | 30 |

$(article.title)

31 |
32 | $(replace(article.content, "/wiki/"=>"/$(game.id)/wiki/")) 33 |
34 | 35 | 36 | """ 37 | end 38 | 39 | function history(game) 40 | html = """
    """ 41 | iter = 0 42 | for a in game.history 43 | html *= """ 44 |
  1. 45 | $(a.title) 46 |
  2. 47 | """ 48 | iter += 1 49 | end 50 | 51 | html * "
" 52 | end 53 | 54 | function objective(game) 55 | """ 56 |
57 |

Go from 58 | $(game.articles[1].title) 59 | to 60 | $(game.articles[end].title) 61 |

62 |
63 |
64 | Progress: 65 | $(size(game.history, 1) - 1) 66 | out of maximum 67 | $(size(game.articles, 1) - 1) 68 | links in 69 | $(game.steps_taken) 70 | steps 71 |
72 | $(history(game)) 73 |
74 |
75 | Solution? | 76 | New game 77 |
78 |
79 | """ 80 | end 81 | 82 | function head() 83 | """ 84 | 85 | 86 | 87 | 6 Degrees of Wikipedia 88 | 89 | """ 90 | end 91 | 92 | function puzzlesolved(game, article) 93 | article.url == game.articles[end].url 94 | end 95 | 96 | function losinggame(game) 97 | game.steps_taken >= Gameplay.MAX_NUMBER_OF_STEPS 98 | end 99 | 100 | function parseuri(uri) 101 | map(x -> String(x), split(uri, "/", keepempty = false)) 102 | end 103 | 104 | 105 | # Routes handlers 106 | const landingpage = HTTP.HandlerFunction() do req 107 | html = """ 108 | 109 | 110 | $(head()) 111 | 112 | 113 |
114 |

Six degrees of Wikipedia

115 |

116 | The goal of the game is to find the shortest path between two random Wikipedia articles.
117 | Depending on the difficulty level you choose, the Wiki pages will be further apart and less related.
118 | If you can’t find the solution, you can always go back up the articles chain, but you need to find the solution within the maximum number of steps, otherwise you lose.
119 | If you get stuck, you can always check the solution, but you'll lose.
120 | Good luck and enjoy! 121 |

122 | 123 |
124 | 125 |
126 |

New game

127 | Easy ($(Gameplay.DIFFICULTY_EASY) links away) | 128 | Medium ($(Gameplay.DIFFICULTY_MEDIUM) links away) | 129 | Hard ($(Gameplay.DIFFICULTY_HARD) links away) 130 |
131 |
132 | 133 | 134 | """ 135 | 136 | HTTP.Messages.Response(200, html) 137 | end 138 | 139 | const newgamepage = HTTP.HandlerFunction() do req 140 | game = parse(UInt8, (replace(req.target, "/new/"=>""))) |> newgamesession 141 | article = game.articles[1] 142 | push!(game.history, article) 143 | 144 | HTTP.Messages.Response(200, wikiarticle(game, article)) 145 | end 146 | 147 | const articlepage = HTTP.HandlerFunction() do req 148 | uri_parts = parseuri(req.target) 149 | game = gamesession(uri_parts[1]) 150 | article_uri = "/wiki/$(uri_parts[end])" 151 | 152 | existing_articles = Articles.find(article_uri) 153 | article = isempty(existing_articles) ? persistedarticle(fetchpage(article_uri)...) : existing_articles[1] 154 | 155 | push!(game.history, article) 156 | game.steps_taken += 1 157 | 158 | puzzlesolved(game, article) && destroygamesession(game.id) 159 | 160 | HTTP.Messages.Response(200, wikiarticle(game, article)) 161 | end 162 | 163 | const backpage = HTTP.HandlerFunction() do req 164 | uri_parts = parseuri(req.target) 165 | game = gamesession(uri_parts[1]) 166 | history_index = parse(UInt8, uri_parts[end]) 167 | 168 | article = game.history[history_index] 169 | game.history = game.history[1:history_index] 170 | 171 | HTTP.Messages.Response(200, wikiarticle(game, article)) 172 | end 173 | 174 | const solutionpage = HTTP.HandlerFunction() do req 175 | uri_parts = parseuri(req.target) 176 | game = gamesession(uri_parts[1]) 177 | game.history = game.articles 178 | game.steps_taken = Gameplay.MAX_NUMBER_OF_STEPS 179 | article = game.articles[end] 180 | 181 | HTTP.Messages.Response(200, wikiarticle(game, article)) 182 | end 183 | 184 | const notfoundpage = HTTP.HandlerFunction() do req 185 | HTTP.Messages.Response(404, "Sorry, this can't be found") 186 | end 187 | 188 | # Routes definitions 189 | HTTP.register!(ROUTER, "/", landingpage) # root page 190 | HTTP.register!(ROUTER, "/new/*", newgamepage) # /new/$difficulty_level -- new game 191 | HTTP.register!(ROUTER, "/*/wiki/*", articlepage) # /$session_id/wiki/$wikipedia_article_url -- article page 192 | HTTP.register!(ROUTER, "/*/back/*", backpage) # /$session_id/back/$number_of_steps -- go back the navigation history 193 | HTTP.register!(ROUTER, "/*/solution", solutionpage) # /$session_id/solution -- display the solution 194 | HTTP.register!(ROUTER, "*", notfoundpage) # everything else -- not found 195 | 196 | # Start server 197 | HTTP.serve(SERVER, HOST, PORT) 198 | 199 | end 200 | -------------------------------------------------------------------------------- /Chapter05/sixdegrees/Wikipedia.jl: -------------------------------------------------------------------------------- 1 | module Wikipedia 2 | 3 | using HTTP, Gumbo, Cascadia 4 | import Cascadia: matchFirst 5 | 6 | include("Articles.jl") 7 | using .Articles 8 | 9 | const PROTOCOL = "https://" 10 | const DOMAIN_NAME = "en.m.wikipedia.org" 11 | const RANDOM_PAGE_URL = PROTOCOL * DOMAIN_NAME * "/wiki/Special:Random" 12 | 13 | export fetchrandom, fetchpage, articleinfo, persistedarticle 14 | 15 | # function fetchpage(url) 16 | # url = startswith(url, "/") ? buildurl(url) : url 17 | # 18 | # response = HTTP.get(url) 19 | # 20 | # if response.status == 200 && length(response.body) > 0 21 | # String(response.body) 22 | # else 23 | # "" 24 | # end 25 | # end 26 | 27 | function fetchpage(url) 28 | url = startswith(url, "/") ? buildurl(url) : url 29 | response = HTTP.get(url) 30 | content = if response.status == 200 && length(response.body) > 0 31 | String(response.body) 32 | else 33 | "" 34 | end 35 | relative_url = collect(eachmatch(r"/wiki/(.*)$", (response.request.parent == nothing ? url : Dict(response.request.parent.headers)["Location"])))[1].match 36 | 37 | content, relative_url 38 | end 39 | 40 | 41 | function extractlinks(elem) 42 | map(eachmatch(Selector("a[href^='/wiki/']:not(a[href*=':'])"), elem)) do e 43 | e.attributes["href"] 44 | end |> unique 45 | end 46 | 47 | function extracttitle(elem) 48 | matchFirst(Selector("#section_0"), elem) |> nodeText 49 | end 50 | 51 | function extractimage(elem) 52 | e = matchFirst(Selector(".content a.image img"), elem) 53 | isa(e, Nothing) ? "" : e.attributes["src"] 54 | end 55 | 56 | function extractcontent(elem) 57 | matchFirst(Selector("#bodyContent"), elem) |> string 58 | end 59 | 60 | function fetchrandom() 61 | fetchpage(RANDOM_PAGE_URL) 62 | end 63 | 64 | function articledom(content) 65 | if ! isempty(content) 66 | return Gumbo.parsehtml(content) 67 | end 68 | 69 | error("Article content can not be parsed into DOM") 70 | end 71 | 72 | # function articleinfo(content) 73 | # dom = articledom(content) 74 | # 75 | # Dict( :content => content, 76 | # :links => extractlinks(dom.root), 77 | # :title => extracttitle(dom.root), 78 | # :image => extractimage(dom.root) 79 | # ) 80 | # end 81 | 82 | # function articleinfo(content) 83 | # dom = articledom(content) 84 | # Article(content, 85 | # extractlinks(dom.root), 86 | # extracttitle(dom.root), 87 | # extractimage(dom.root)) 88 | # end 89 | 90 | # function articleinfo(content) 91 | # dom = articledom(content) 92 | # (content, extractlinks(dom.root), extracttitle(dom.root), extractimage(dom.root)) 93 | # end 94 | 95 | function articleinfo(content) 96 | dom = articledom(content) 97 | (extractcontent(dom.root), extractlinks(dom.root), extracttitle(dom.root), extractimage(dom.root)) 98 | end 99 | 100 | function persistedarticle(article_content, url) 101 | article = Article(articleinfo(article_content)..., url) 102 | save(article) 103 | 104 | article 105 | end 106 | 107 | function buildurl(article_url) 108 | PROTOCOL * DOMAIN_NAME * article_url 109 | end 110 | 111 | end 112 | -------------------------------------------------------------------------------- /Chapter05/sixdegrees/six_degrees.jl: -------------------------------------------------------------------------------- 1 | using Pkg 2 | pkg"activate ." 3 | 4 | include("Database.jl") 5 | include("Wikipedia.jl") 6 | include("Gameplay.jl") 7 | include("GameSession.jl") 8 | include("WebApp.jl") 9 | 10 | using .Wikipedia, .Gameplay, .GameSession, .WebApp 11 | -------------------------------------------------------------------------------- /Chapter06/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" 3 | DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" 4 | DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" 5 | Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" 6 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 7 | Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 8 | Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" 9 | StatPlots = "60ddc479-9b66-56df-82fc-76a74619b69c" 10 | Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 11 | -------------------------------------------------------------------------------- /Chapter06/item_based_recommendations.jl: -------------------------------------------------------------------------------- 1 | using CSV, DataFrames, DelimitedFiles, Statistics 2 | 3 | const minimum_similarity = 0.8 4 | 5 | function setup_data() 6 | movies = readdlm("top_10_movies_user_rankings.tsv", '\t') 7 | movies = permutedims(movies, (2,1)) 8 | movies = convert(DataFrame, movies) 9 | 10 | names = convert(Array, movies[1, :])[1,:] 11 | 12 | names!(movies, [Symbol(name) for name in names]) 13 | deleterows!(movies, 1) 14 | rename!(movies, [Symbol("Movie title") => :User]) 15 | end 16 | 17 | function movie_similarity(target_movie) 18 | similarity = Dict{Symbol,Float64}() 19 | 20 | for movie in names(movies[:, 2:end]) 21 | movie == target_movie && continue 22 | ratings = movies[:, [movie, target_movie]] 23 | 24 | common_users = ratings[(ratings[movie] .>= 0) .& (ratings[target_movie] .> 0), :] 25 | 26 | correlation = try 27 | cor(common_users[movie], common_users[target_movie]) 28 | catch 29 | 0.0 30 | end 31 | 32 | similarity[movie] = correlation 33 | end 34 | 35 | # println("The movie $target_movie is similar to $similarity") 36 | similarity 37 | end 38 | 39 | function recommendations(target_movie) 40 | recommended = Dict{String,Vector{Tuple{String,Float64}}}() 41 | 42 | # @show target_movie 43 | # @show movie_similarity(target_movie) 44 | 45 | for (movie, similarity) in movie_similarity(target_movie) 46 | movie == target_movie && continue 47 | similarity > minimum_similarity || continue 48 | 49 | # println("Checking to which users we can recommend $movie") 50 | 51 | recommended["$movie"] = Vector{Tuple{String,Float64}}() 52 | 53 | for user_row in eachrow(movies) 54 | if user_row[target_movie] >= 5 55 | # println("$(user_row[:User]) has watched $target_movie so we can recommend similar movies") 56 | 57 | if user_row[movie] == 0 58 | # println("$(user_row[:User]) has not watched $movie so we can recommend it") 59 | # println("Recommending $(user_row[:User]) the movie $movie") 60 | 61 | push!(recommended["$movie"], (user_row[:User], user_row[target_movie] * similarity)) 62 | end 63 | end 64 | end 65 | end 66 | 67 | recommended 68 | end 69 | 70 | const movies = setup_data() 71 | println("Recommendations for users that watched Finding Dory (2016): $(recommendations(Symbol("Finding Dory (2016)")))") -------------------------------------------------------------------------------- /Chapter06/top_10_movies.tsv: -------------------------------------------------------------------------------- 1 | Movie title Action Animation Comedy Drama Kids Mistery Musical SF 2 | Moonlight (2016) 0 0 0 1 0 0 0 0 3 | Zootopia (2016) 1 1 1 0 0 0 0 0 4 | Arrival (2016) 0 0 0 1 0 1 0 1 5 | Hell or High Water (2016) 0 0 0 1 0 1 0 0 6 | La La Land (2016) 0 0 1 1 0 0 1 0 7 | The Jungle Book (2016) 1 0 0 0 1 0 0 0 8 | Manchester by the Sea (2016) 0 0 0 1 0 0 0 0 9 | Finding Dory (2016) 0 1 0 0 0 0 0 0 10 | Captain America: Civil War (2016) 1 0 0 0 0 0 0 1 11 | Moana (2016) 1 1 0 0 0 0 0 0 -------------------------------------------------------------------------------- /Chapter06/top_10_movies_user_rankings.csv: -------------------------------------------------------------------------------- 1 | Movie title;Acton;Annie;Comey;Dean;Kit;Missie;Musk;Sam 2 | Moonlight (2016);;3;;10;;9;2; 3 | Zootopia (2016);9;10;7;;10;;5; 4 | Arrival (2016);5;;6;10;;9;;10 5 | Hell or High Water (2016);3;;3;10;;8;; 6 | La La Land (2016);6;;8;9;;;10; 7 | The Jungle Book (2016);8;7;;2;9;;6; 8 | Manchester by the Sea (2016);;;2;8;;;; 9 | Finding Dory (2016);7;8;5;4;10;;; 10 | Captain America: Civil War (2016);10;;5;6;;;;9 11 | Moana (2016);8;9;;;10;;7; -------------------------------------------------------------------------------- /Chapter06/top_10_movies_user_rankings.tsv: -------------------------------------------------------------------------------- 1 | Movie title Acton Annie Comey Dean Kit Missie Musk Sam 2 | Moonlight (2016) 0 3 0 10 0 9 2 0 3 | Zootopia (2016) 9 10 7 0 10 0 5 0 4 | Arrival (2016) 5 0 6 10 0 9 0 10 5 | Hell or High Water (2016) 3 0 3 10 0 8 0 0 6 | La La Land (2016) 6 0 8 9 0 0 10 0 7 | The Jungle Book (2016) 8 7 0 2 9 0 6 0 8 | Manchester by the Sea (2016) 0 0 2 8 0 0 0 0 9 | Finding Dory (2016) 7 8 5 4 10 0 0 0 10 | Captain America: Civil War (2016) 10 0 5 6 0 0 0 9 11 | Moana (2016) 8 9 0 0 10 0 7 0 12 | -------------------------------------------------------------------------------- /Chapter06/user_based_movie_recommendations.jl: -------------------------------------------------------------------------------- 1 | using CSV, DataFrames, Statistics 2 | 3 | const minimum_similarity = 0.8 4 | const movies = CSV.read("top_10_movies_user_rankings.tsv", delim = '\t') 5 | 6 | function user_similarity(target_user) 7 | similarity = Dict{Symbol,Float64}() 8 | 9 | for user in names(movies[:, 2:end]) 10 | user == target_user && continue 11 | 12 | ratings = movies[:, [user, target_user]] 13 | common_movies = ratings[(ratings[user] .> 0) .& (ratings[target_user] .> 0), :] 14 | # common_movies = ratings[(ratings[user] .> 7) .& (ratings[target_user] .> 0), :] 15 | 16 | correlation = try 17 | cor(common_movies[user], common_movies[target_user]) 18 | catch 19 | 0.0 20 | end 21 | 22 | similarity[user] = correlation 23 | end 24 | 25 | similarity 26 | end 27 | 28 | function recommendations(target_user) 29 | recommended = Dict{String,Float64}() 30 | 31 | for (user,similarity) in user_similarity(target_user) 32 | similarity > minimum_similarity || continue 33 | 34 | ratings = movies[:, [Symbol("Movie title"), user, target_user]] 35 | recommended_movies = ratings[(ratings[user] .>= 7) .& (ratings[target_user] .== 0), :] 36 | 37 | for movie in eachrow(recommended_movies) 38 | recommended[movie[Symbol("Movie title")]] = movie[user] * similarity 39 | end 40 | end 41 | 42 | recommended 43 | end 44 | 45 | for user in names(movies)[2:end] 46 | println("Recommendations for $user: $(recommendations(user))") 47 | end -------------------------------------------------------------------------------- /Chapter07/Chapter 7.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "using Pkg\n", 10 | "pkg\"activate .\"" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "# Run this cell in order to download all the package dependencies with the exact versions used in the book\n", 20 | "# This is necessary if (some of) the packages have been updated and have introduced breaking changes\n", 21 | "pkg\"instantiate\"" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "using CSV" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "users = CSV.read(\"data/BX-Users.csv\", header = 1, delim = ';', missingstring = \"NULL\", escapechar = '\\\\')" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "books = CSV.read(\"data/BX-Books.csv\", header = 1, delim = ';', missingstring = \"NULL\", escapechar = '\\\\')" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "books_ratings = CSV.read(\"data/BX-Book-Ratings.csv\", header = 1, delim = ';', missingstring = \"NULL\", escapechar = '\\\\')" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": null, 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [ 66 | "using DataFrames" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": null, 72 | "metadata": {}, 73 | "outputs": [], 74 | "source": [ 75 | "describe(users, stats = [:min, :max, :nmissing, :nunique, :eltype])" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [ 84 | "using Gadfly" 85 | ] 86 | }, 87 | { 88 | "cell_type": "code", 89 | "execution_count": null, 90 | "metadata": {}, 91 | "outputs": [], 92 | "source": [ 93 | "plot(users, x = :Age, Geom.histogram(bincount = 15))" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": null, 99 | "metadata": {}, 100 | "outputs": [], 101 | "source": [ 102 | "users = users[users[:Age] .< 100, :]" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": null, 108 | "metadata": {}, 109 | "outputs": [], 110 | "source": [ 111 | "using Statistics" 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": null, 117 | "metadata": {}, 118 | "outputs": [], 119 | "source": [ 120 | "mean(skipmissing(users[:Age]))" 121 | ] 122 | }, 123 | { 124 | "cell_type": "code", 125 | "execution_count": null, 126 | "metadata": {}, 127 | "outputs": [], 128 | "source": [ 129 | "users[:Age] = coalesce.(users[:Age], mean(skipmissing(users[:Age])))" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": null, 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [ 138 | "users = users[users[:Age] .< 100, :]" 139 | ] 140 | }, 141 | { 142 | "cell_type": "code", 143 | "execution_count": null, 144 | "metadata": {}, 145 | "outputs": [], 146 | "source": [ 147 | "head(users)" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": null, 153 | "metadata": {}, 154 | "outputs": [], 155 | "source": [ 156 | "describe(books, stats = [:nmissing, :nunique, :eltype])" 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": null, 162 | "metadata": {}, 163 | "outputs": [], 164 | "source": [ 165 | "maximum(skipmissing(books[Symbol(\"Year-Of-Publication\")]))" 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": null, 171 | "metadata": {}, 172 | "outputs": [], 173 | "source": [ 174 | "minimum(skipmissing(books[Symbol(\"Year-Of-Publication\")]))" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": null, 180 | "metadata": {}, 181 | "outputs": [], 182 | "source": [ 183 | "plot(books, x = Symbol(\"Year-Of-Publication\"), Geom.histogram)" 184 | ] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "execution_count": null, 189 | "metadata": {}, 190 | "outputs": [], 191 | "source": [ 192 | "unique(books[Symbol(\"Year-Of-Publication\")]) |> sort" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": null, 198 | "metadata": {}, 199 | "outputs": [], 200 | "source": [ 201 | "books = books[books[Symbol(\"Year-Of-Publication\")] .>= 1970, :]" 202 | ] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "execution_count": null, 207 | "metadata": {}, 208 | "outputs": [], 209 | "source": [ 210 | "books = books[books[Symbol(\"Year-Of-Publication\")] .<= 2004, :]" 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": null, 216 | "metadata": {}, 217 | "outputs": [], 218 | "source": [ 219 | "plot(books, x = Symbol(\"Year-Of-Publication\"), Geom.histogram)" 220 | ] 221 | }, 222 | { 223 | "cell_type": "code", 224 | "execution_count": null, 225 | "metadata": {}, 226 | "outputs": [], 227 | "source": [ 228 | "describe(books_ratings)" 229 | ] 230 | }, 231 | { 232 | "cell_type": "code", 233 | "execution_count": null, 234 | "metadata": {}, 235 | "outputs": [], 236 | "source": [ 237 | "plot(books_ratings, x = Symbol(\"Book-Rating\"), Geom.histogram)" 238 | ] 239 | }, 240 | { 241 | "cell_type": "code", 242 | "execution_count": null, 243 | "metadata": {}, 244 | "outputs": [], 245 | "source": [ 246 | "books_ratings = books_ratings[books_ratings[Symbol(\"Book-Rating\")] .> 0, :]" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": null, 252 | "metadata": {}, 253 | "outputs": [], 254 | "source": [ 255 | "plot(books_ratings, x = Symbol(\"Book-Rating\"), Geom.histogram)" 256 | ] 257 | }, 258 | { 259 | "cell_type": "code", 260 | "execution_count": null, 261 | "metadata": {}, 262 | "outputs": [], 263 | "source": [ 264 | "books_ratings_books = join(books_ratings, books, on = :ISBN, kind = :inner)" 265 | ] 266 | }, 267 | { 268 | "cell_type": "code", 269 | "execution_count": null, 270 | "metadata": {}, 271 | "outputs": [], 272 | "source": [ 273 | "books_ratings_books_users = join(books_ratings_books, users, on = Symbol(\"User-ID\"), kind = :inner)" 274 | ] 275 | }, 276 | { 277 | "cell_type": "code", 278 | "execution_count": null, 279 | "metadata": {}, 280 | "outputs": [], 281 | "source": [ 282 | "top_ratings = books_ratings_books_users[books_ratings_books_users[Symbol(\"Book-Rating\")] .>= 8, :]" 283 | ] 284 | }, 285 | { 286 | "cell_type": "code", 287 | "execution_count": null, 288 | "metadata": {}, 289 | "outputs": [], 290 | "source": [ 291 | "for n in names(top_ratings)\n", 292 | " rename!(top_ratings, n => Symbol(replace(string(n), \"-\"=>\"\")))\n", 293 | "end" 294 | ] 295 | }, 296 | { 297 | "cell_type": "code", 298 | "execution_count": null, 299 | "metadata": {}, 300 | "outputs": [], 301 | "source": [ 302 | "names(top_ratings)" 303 | ] 304 | }, 305 | { 306 | "cell_type": "code", 307 | "execution_count": null, 308 | "metadata": {}, 309 | "outputs": [], 310 | "source": [ 311 | "ratings_count = by(top_ratings, :UserID, df -> size(df[:UserID])[1])" 312 | ] 313 | }, 314 | { 315 | "cell_type": "code", 316 | "execution_count": null, 317 | "metadata": {}, 318 | "outputs": [], 319 | "source": [ 320 | "describe(ratings_count)" 321 | ] 322 | }, 323 | { 324 | "cell_type": "code", 325 | "execution_count": null, 326 | "metadata": {}, 327 | "outputs": [], 328 | "source": [ 329 | "ratings_count = ratings_count[ratings_count[:x1] .>= 5, :]" 330 | ] 331 | }, 332 | { 333 | "cell_type": "code", 334 | "execution_count": null, 335 | "metadata": {}, 336 | "outputs": [], 337 | "source": [ 338 | "plot(ratings_count, x = :x1, Geom.histogram(maxbincount = 6))" 339 | ] 340 | }, 341 | { 342 | "cell_type": "code", 343 | "execution_count": null, 344 | "metadata": {}, 345 | "outputs": [], 346 | "source": [ 347 | "ratings_count[ratings_count[:x1] .> 1000, :]" 348 | ] 349 | }, 350 | { 351 | "cell_type": "code", 352 | "execution_count": null, 353 | "metadata": {}, 354 | "outputs": [], 355 | "source": [ 356 | "ratings_count = ratings_count[ratings_count[:x1] .<= 1000, :]" 357 | ] 358 | }, 359 | { 360 | "cell_type": "code", 361 | "execution_count": null, 362 | "metadata": {}, 363 | "outputs": [], 364 | "source": [ 365 | "top_ratings = join(top_ratings, ratings_count, on = :UserID, kind = :inner)" 366 | ] 367 | }, 368 | { 369 | "cell_type": "code", 370 | "execution_count": null, 371 | "metadata": {}, 372 | "outputs": [], 373 | "source": [ 374 | "CSV.write(\"top_ratings.csv\", top_ratings)" 375 | ] 376 | }, 377 | { 378 | "cell_type": "code", 379 | "execution_count": null, 380 | "metadata": {}, 381 | "outputs": [], 382 | "source": [] 383 | } 384 | ], 385 | "metadata": { 386 | "kernelspec": { 387 | "display_name": "Julia 1.0.1", 388 | "language": "julia", 389 | "name": "julia-1.0" 390 | }, 391 | "language_info": { 392 | "file_extension": ".jl", 393 | "mimetype": "application/julia", 394 | "name": "julia", 395 | "version": "1.0.2" 396 | } 397 | }, 398 | "nbformat": 4, 399 | "nbformat_minor": 2 400 | } 401 | -------------------------------------------------------------------------------- /Chapter07/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" 3 | DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" 4 | Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" 5 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 6 | Recommendation = "d27d45ae-66f1-5d53-80d2-11744f5c9556" 7 | Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 8 | -------------------------------------------------------------------------------- /Chapter07/data/BX-Book-Ratings.csv.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-Programming-Projects/c9887753d1eb9023d362a07b35baa24bd7780287/Chapter07/data/BX-Book-Ratings.csv.zip -------------------------------------------------------------------------------- /Chapter07/data/BX-Books.csv.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-Programming-Projects/c9887753d1eb9023d362a07b35baa24bd7780287/Chapter07/data/BX-Books.csv.zip -------------------------------------------------------------------------------- /Chapter07/data/BX-Users.csv.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-Programming-Projects/c9887753d1eb9023d362a07b35baa24bd7780287/Chapter07/data/BX-Users.csv.zip -------------------------------------------------------------------------------- /Chapter07/data/large/top_ratings.csv.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-Programming-Projects/c9887753d1eb9023d362a07b35baa24bd7780287/Chapter07/data/large/top_ratings.csv.zip -------------------------------------------------------------------------------- /Chapter07/data/top_ratings.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-Programming-Projects/c9887753d1eb9023d362a07b35baa24bd7780287/Chapter07/data/top_ratings.csv -------------------------------------------------------------------------------- /Chapter08/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" 3 | DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" 4 | DataValues = "e7dc6d0d-1eca-5fa6-8ad6-5aecde8b7ea5" 5 | Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" 6 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 7 | Query = "1a8c2f83-1ff3-5112-b086-8aa67b057ba1" 8 | -------------------------------------------------------------------------------- /Chapter08/data/2017_NAICS_Index_File.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-Programming-Projects/c9887753d1eb9023d362a07b35baa24bd7780287/Chapter08/data/2017_NAICS_Index_File.xlsx -------------------------------------------------------------------------------- /Chapter08/data/Map_of_Registered_Business_Locations.csv.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-Programming-Projects/c9887753d1eb9023d362a07b35baa24bd7780287/Chapter08/data/Map_of_Registered_Business_Locations.csv.zip -------------------------------------------------------------------------------- /Chapter08/data/clean_df_geo.tsv.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Julia-Programming-Projects/c9887753d1eb9023d362a07b35baa24bd7780287/Chapter08/data/clean_df_geo.tsv.zip -------------------------------------------------------------------------------- /Chapter09/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[Base64]] 2 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 3 | 4 | [[BinaryProvider]] 5 | deps = ["Libdl", "Pkg", "SHA", "Test"] 6 | git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" 7 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 8 | version = "0.5.3" 9 | 10 | [[ColorTypes]] 11 | deps = ["FixedPointNumbers", "Random", "Test"] 12 | git-tree-sha1 = "f73b0e10f2a5756de7019818a41654686da06b09" 13 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" 14 | version = "0.7.5" 15 | 16 | [[Colors]] 17 | deps = ["ColorTypes", "FixedPointNumbers", "InteractiveUtils", "Printf", "Reexport", "Test"] 18 | git-tree-sha1 = "9f0a0210450acb91c730b730a994f8eef1d3d543" 19 | uuid = "5ae59095-9a9b-59fe-a467-6f913c188581" 20 | version = "0.9.5" 21 | 22 | [[Compat]] 23 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 24 | git-tree-sha1 = "ec61a16eed883ad0cfa002d7489b3ce6d039bb9a" 25 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 26 | version = "1.4.0" 27 | 28 | [[Conda]] 29 | deps = ["Compat", "JSON", "VersionParsing"] 30 | git-tree-sha1 = "fb86fe40cb5b35990e368709bfdc1b46dbb99dac" 31 | uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" 32 | version = "1.1.1" 33 | 34 | [[Contour]] 35 | deps = ["LinearAlgebra", "StaticArrays", "Test"] 36 | git-tree-sha1 = "b974e164358fea753ef853ce7bad97afec15bb80" 37 | uuid = "d38c429a-6771-53c6-b99e-75d170b6e991" 38 | version = "0.5.1" 39 | 40 | [[DataStructures]] 41 | deps = ["InteractiveUtils", "OrderedCollections", "Random", "Serialization", "Test"] 42 | git-tree-sha1 = "8fc6e166e24fda04b2b648d4260cdad241788c54" 43 | uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" 44 | version = "0.14.0" 45 | 46 | [[Dates]] 47 | deps = ["Printf"] 48 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 49 | 50 | [[DelimitedFiles]] 51 | deps = ["Mmap"] 52 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 53 | 54 | [[Distributed]] 55 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 56 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 57 | 58 | [[EzXML]] 59 | deps = ["BinaryProvider", "Libdl", "Printf", "Test"] 60 | git-tree-sha1 = "5623d1486bfaadd815f5c4ca501adda02b5337f1" 61 | uuid = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615" 62 | version = "0.9.0" 63 | 64 | [[FileWatching]] 65 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 66 | 67 | [[FixedPointNumbers]] 68 | deps = ["Test"] 69 | git-tree-sha1 = "b8045033701c3b10bf2324d7203404be7aef88ba" 70 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" 71 | version = "0.5.3" 72 | 73 | [[GR]] 74 | deps = ["Base64", "DelimitedFiles", "Pkg", "Random", "Serialization", "Sockets", "Test"] 75 | git-tree-sha1 = "d12425c0187189a6f2fabc5eea9f22f25d365049" 76 | uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" 77 | version = "0.36.0" 78 | 79 | [[HTTP]] 80 | deps = ["Base64", "Dates", "Distributed", "IniFile", "MbedTLS", "Sockets", "Test"] 81 | git-tree-sha1 = "b881f69331e85642be315c63d05ed65d6fc8a05b" 82 | uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" 83 | version = "0.7.1" 84 | 85 | [[IJulia]] 86 | deps = ["Base64", "Compat", "Conda", "Dates", "InteractiveUtils", "JSON", "Markdown", "MbedTLS", "Pkg", "Printf", "REPL", "Random", "SoftGlobalScope", "Test", "UUIDs", "ZMQ"] 87 | git-tree-sha1 = "38d1ce0fbbefcb67f5ab46f1093cbce0335092e0" 88 | uuid = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 89 | version = "1.14.1" 90 | 91 | [[IniFile]] 92 | deps = ["Test"] 93 | git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" 94 | uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" 95 | version = "0.5.0" 96 | 97 | [[InteractiveUtils]] 98 | deps = ["LinearAlgebra", "Markdown"] 99 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 100 | 101 | [[JSON]] 102 | deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] 103 | git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa" 104 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 105 | version = "0.20.0" 106 | 107 | [[LibGit2]] 108 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 109 | 110 | [[Libdl]] 111 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 112 | 113 | [[LinearAlgebra]] 114 | deps = ["Libdl"] 115 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 116 | 117 | [[Logging]] 118 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 119 | 120 | [[Markdown]] 121 | deps = ["Base64"] 122 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 123 | 124 | [[MarketData]] 125 | deps = ["HTTP", "Reexport", "Test", "TimeSeries"] 126 | git-tree-sha1 = "ee1bde9351cc4f42387b33bd3996a7081e24e4e6" 127 | uuid = "945b72a4-3b13-509d-9b46-1525bb5c06de" 128 | version = "0.11.0" 129 | 130 | [[MbedTLS]] 131 | deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets", "Test"] 132 | git-tree-sha1 = "c93a87da4081a3de781f34e0540175795a2ce83d" 133 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 134 | version = "0.6.6" 135 | 136 | [[Measures]] 137 | deps = ["Test"] 138 | git-tree-sha1 = "ddfd6d13e330beacdde2c80de27c1c671945e7d9" 139 | uuid = "442fdcdd-2543-5da2-b0f3-8c86c306513e" 140 | version = "0.3.0" 141 | 142 | [[Missings]] 143 | deps = ["Dates", "InteractiveUtils", "SparseArrays", "Test"] 144 | git-tree-sha1 = "adc26d2ee85a49c413464110d922cf21efc9d233" 145 | uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" 146 | version = "0.3.1" 147 | 148 | [[Mmap]] 149 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 150 | 151 | [[Mocking]] 152 | deps = ["Compat", "Dates"] 153 | git-tree-sha1 = "4bf69aaf823b119b034e091e16b18311aa191663" 154 | uuid = "78c3b35d-d492-501b-9361-3d52fe80e533" 155 | version = "0.5.7" 156 | 157 | [[NaNMath]] 158 | deps = ["Compat"] 159 | git-tree-sha1 = "ce3b85e484a5d4c71dd5316215069311135fa9f2" 160 | uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" 161 | version = "0.3.2" 162 | 163 | [[Nullables]] 164 | deps = ["Compat"] 165 | git-tree-sha1 = "ae1a63457e14554df2159b0b028f48536125092d" 166 | uuid = "4d1e1d77-625e-5b40-9113-a560ec7a8ecd" 167 | version = "0.0.8" 168 | 169 | [[OrderedCollections]] 170 | deps = ["Random", "Serialization", "Test"] 171 | git-tree-sha1 = "85619a3f3e17bb4761fe1b1fd47f0e979f964d5b" 172 | uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" 173 | version = "1.0.2" 174 | 175 | [[Pkg]] 176 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 177 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 178 | 179 | [[PlotThemes]] 180 | deps = ["PlotUtils", "Requires", "Test"] 181 | git-tree-sha1 = "f3afd2d58e1f6ac9be2cea46e4a9083ccc1d990b" 182 | uuid = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a" 183 | version = "0.3.0" 184 | 185 | [[PlotUtils]] 186 | deps = ["Colors", "Dates", "Printf", "Random", "Reexport", "Test"] 187 | git-tree-sha1 = "fd28f30a294a38ec847de95d8ac7ac916ccd7c06" 188 | uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043" 189 | version = "0.5.5" 190 | 191 | [[Plots]] 192 | deps = ["Base64", "Contour", "Dates", "FixedPointNumbers", "GR", "JSON", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "Printf", "Random", "RecipesBase", "Reexport", "Requires", "Showoff", "SparseArrays", "StaticArrays", "Statistics", "StatsBase", "Test", "UUIDs"] 193 | git-tree-sha1 = "5a0455fdc5d2af70bf81d5d7eb9a98704223224e" 194 | uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" 195 | version = "0.22.0" 196 | 197 | [[Printf]] 198 | deps = ["Unicode"] 199 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 200 | 201 | [[REPL]] 202 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 203 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 204 | 205 | [[Random]] 206 | deps = ["Serialization"] 207 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 208 | 209 | [[RecipesBase]] 210 | deps = ["Random", "Test"] 211 | git-tree-sha1 = "0b3cb370ee4dc00f47f1193101600949f3dcf884" 212 | uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" 213 | version = "0.6.0" 214 | 215 | [[Reexport]] 216 | deps = ["Pkg"] 217 | git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0" 218 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 219 | version = "0.2.0" 220 | 221 | [[Requires]] 222 | deps = ["Test"] 223 | git-tree-sha1 = "f6fbf4ba64d295e146e49e021207993b6b48c7d1" 224 | uuid = "ae029012-a4dd-5104-9daa-d747884805df" 225 | version = "0.5.2" 226 | 227 | [[SHA]] 228 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 229 | 230 | [[Serialization]] 231 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 232 | 233 | [[SharedArrays]] 234 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 235 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 236 | 237 | [[Showoff]] 238 | deps = ["Compat"] 239 | git-tree-sha1 = "276b24f3ace98bec911be7ff2928d497dc759085" 240 | uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f" 241 | version = "0.2.1" 242 | 243 | [[Sockets]] 244 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 245 | 246 | [[SoftGlobalScope]] 247 | deps = ["Test"] 248 | git-tree-sha1 = "97f6dfcf612b9a7260fde44170725d9ea34b1431" 249 | uuid = "b85f4697-e234-5449-a836-ec8e2f98b302" 250 | version = "1.0.7" 251 | 252 | [[SortingAlgorithms]] 253 | deps = ["DataStructures", "Random", "Test"] 254 | git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd" 255 | uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" 256 | version = "0.3.1" 257 | 258 | [[SparseArrays]] 259 | deps = ["LinearAlgebra", "Random"] 260 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 261 | 262 | [[StaticArrays]] 263 | deps = ["InteractiveUtils", "LinearAlgebra", "Random", "Statistics", "Test"] 264 | git-tree-sha1 = "97c4bf0f647488dd7ac01ea12be5885f88762938" 265 | uuid = "90137ffa-7385-5640-81b9-e52037218182" 266 | version = "0.10.0" 267 | 268 | [[Statistics]] 269 | deps = ["LinearAlgebra", "SparseArrays"] 270 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 271 | 272 | [[StatsBase]] 273 | deps = ["DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "Test"] 274 | git-tree-sha1 = "2722397d88f8ffef551948f6c20e1d74a743298c" 275 | uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" 276 | version = "0.26.0" 277 | 278 | [[Test]] 279 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 280 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 281 | 282 | [[TimeSeries]] 283 | deps = ["Dates", "DelimitedFiles", "Random", "RecipesBase", "Statistics", "Test"] 284 | git-tree-sha1 = "5a7bcdfbdac440ad5395b97701a21f423b338fc5" 285 | uuid = "9e3dc215-6440-5c97-bce1-76c03772f85e" 286 | version = "0.14.0" 287 | 288 | [[TimeZones]] 289 | deps = ["Compat", "EzXML", "Mocking", "Nullables"] 290 | git-tree-sha1 = "4a4ab113913e19ad62b67e6c5c056509eac00c19" 291 | uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53" 292 | version = "0.8.2" 293 | 294 | [[UUIDs]] 295 | deps = ["Random"] 296 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 297 | 298 | [[Unicode]] 299 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 300 | 301 | [[VersionParsing]] 302 | deps = ["Compat"] 303 | git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" 304 | uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" 305 | version = "1.1.3" 306 | 307 | [[ZMQ]] 308 | deps = ["BinaryProvider", "FileWatching", "Libdl", "Sockets", "Test"] 309 | git-tree-sha1 = "34e7ac2d1d59d19d0e86bde99f1f02262bfa1613" 310 | uuid = "c2297ded-f4af-51ae-bb23-16f91089e4e1" 311 | version = "1.0.0" 312 | -------------------------------------------------------------------------------- /Chapter09/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" 3 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 4 | MarketData = "945b72a4-3b13-509d-9b46-1525bb5c06de" 5 | Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 6 | Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" 7 | Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 8 | TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" 9 | -------------------------------------------------------------------------------- /Chapter10/Chapter 10.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "using Pkg\n", 10 | "pkg\"activate .\"" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "# Run this cell in order to download all the package dependencies with the exact versions used in the book\n", 20 | "# This is necessary if (some of) the packages have been updated and have introduced breaking changes\n", 21 | "pkg\"instantiate\"" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "using CSV, DataFrames" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "df = CSV.read(\"data/une_rt_m_1.tsv\", header = true, delim = '\\t')" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "values = convert(Array, df[1, 2:end])" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "metadata": {}, 55 | "outputs": [], 56 | "source": [ 57 | "values = map(x -> parse(Int, replace(x, \" \"=>\"\")), values)[:]" 58 | ] 59 | }, 60 | { 61 | "cell_type": "code", 62 | "execution_count": null, 63 | "metadata": {}, 64 | "outputs": [], 65 | "source": [ 66 | "dates = names(df)[2:end]" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": null, 72 | "metadata": {}, 73 | "outputs": [], 74 | "source": [ 75 | "dates = map(x -> replace(string(x), \"M\"=>\"-\"), dates)" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "metadata": {}, 82 | "outputs": [], 83 | "source": [ 84 | "using Dates\n", 85 | "dateformat = DateFormat(\"y-m\")" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": null, 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [ 94 | "dates = map(x -> Date(x, dateformat), dates)" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": null, 100 | "metadata": {}, 101 | "outputs": [], 102 | "source": [ 103 | "df2 = DataFrame(Dates = dates, Values = values)" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": null, 109 | "metadata": {}, 110 | "outputs": [], 111 | "source": [ 112 | "CSV.write(\"UE-unemployment.tsv\", df2)" 113 | ] 114 | }, 115 | { 116 | "cell_type": "code", 117 | "execution_count": null, 118 | "metadata": {}, 119 | "outputs": [], 120 | "source": [ 121 | "using TimeSeries\n", 122 | "unemployment_data = readtimearray(\"UE-unemployment.tsv\")" 123 | ] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": null, 128 | "metadata": {}, 129 | "outputs": [], 130 | "source": [ 131 | "TimeSeries.head(unemployment_data, 10)" 132 | ] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "execution_count": null, 137 | "metadata": {}, 138 | "outputs": [], 139 | "source": [ 140 | "using Pkg\n", 141 | "pkg\"add PyCall LaTeXStrings\"" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": null, 147 | "metadata": {}, 148 | "outputs": [], 149 | "source": [ 150 | "using Plots\n", 151 | "pyplot()" 152 | ] 153 | }, 154 | { 155 | "cell_type": "code", 156 | "execution_count": null, 157 | "metadata": {}, 158 | "outputs": [], 159 | "source": [ 160 | "plot(unemployment_data)" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": null, 166 | "metadata": {}, 167 | "outputs": [], 168 | "source": [ 169 | "plot()\n", 170 | "for y in 2005:2017\n", 171 | "\tTimeSeries.values(when(unemployment_data, year, y))[:] |> plot!\n", 172 | " gui()\n", 173 | "end" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": null, 179 | "metadata": {}, 180 | "outputs": [], 181 | "source": [ 182 | "using Statistics\n", 183 | "moving_avg = moving(mean, unemployment_data, 12)" 184 | ] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "execution_count": null, 189 | "metadata": {}, 190 | "outputs": [], 191 | "source": [ 192 | "moving(mean, unemployment_data, 12, padding = true)" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": null, 198 | "metadata": {}, 199 | "outputs": [], 200 | "source": [ 201 | "plot(unemployment_data)\n", 202 | "plot!(moving_avg)" 203 | ] 204 | }, 205 | { 206 | "cell_type": "code", 207 | "execution_count": null, 208 | "metadata": {}, 209 | "outputs": [], 210 | "source": [ 211 | "sn = unemployment_data ./ moving_avg" 212 | ] 213 | }, 214 | { 215 | "cell_type": "code", 216 | "execution_count": null, 217 | "metadata": {}, 218 | "outputs": [], 219 | "source": [ 220 | "plot(sn)" 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "execution_count": null, 226 | "metadata": {}, 227 | "outputs": [], 228 | "source": [ 229 | "month_avg = Float64[]" 230 | ] 231 | }, 232 | { 233 | "cell_type": "code", 234 | "execution_count": null, 235 | "metadata": {}, 236 | "outputs": [], 237 | "source": [ 238 | "for m in 1:12\n", 239 | "\tmd = when(sn, month, m)\n", 240 | "\tpush!(month_avg, mean(TimeSeries.values(md)[:]))\n", 241 | "end" 242 | ] 243 | }, 244 | { 245 | "cell_type": "code", 246 | "execution_count": null, 247 | "metadata": {}, 248 | "outputs": [], 249 | "source": [ 250 | "month_avg" 251 | ] 252 | }, 253 | { 254 | "cell_type": "code", 255 | "execution_count": null, 256 | "metadata": {}, 257 | "outputs": [], 258 | "source": [ 259 | "s = sum(month_avg)" 260 | ] 261 | }, 262 | { 263 | "cell_type": "code", 264 | "execution_count": null, 265 | "metadata": {}, 266 | "outputs": [], 267 | "source": [ 268 | "norm_month_avg = map(m -> 12m/s, month_avg)" 269 | ] 270 | }, 271 | { 272 | "cell_type": "code", 273 | "execution_count": null, 274 | "metadata": {}, 275 | "outputs": [], 276 | "source": [ 277 | "sum(norm_month_avg)" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": null, 283 | "metadata": {}, 284 | "outputs": [], 285 | "source": [ 286 | "adj_unemployment_data = deepcopy(unemployment_data)" 287 | ] 288 | }, 289 | { 290 | "cell_type": "code", 291 | "execution_count": null, 292 | "metadata": {}, 293 | "outputs": [], 294 | "source": [ 295 | "map(adj_unemployment_data) do d,v\n", 296 | "\tv[1] /= norm_month_avg[month(d)]\n", 297 | "\td,v\n", 298 | "end" 299 | ] 300 | }, 301 | { 302 | "cell_type": "code", 303 | "execution_count": null, 304 | "metadata": {}, 305 | "outputs": [], 306 | "source": [ 307 | "using Dates\n", 308 | "ts1 = TimeArray(Date(today()) - Week(1):Day(1):Date(today()) |> collect, rand(8))" 309 | ] 310 | }, 311 | { 312 | "cell_type": "code", 313 | "execution_count": null, 314 | "metadata": {}, 315 | "outputs": [], 316 | "source": [ 317 | "ts2 = TimeArray(Date(today()) - Week(1):Day(1):Date(today()) |> collect, rand(8))" 318 | ] 319 | }, 320 | { 321 | "cell_type": "code", 322 | "execution_count": null, 323 | "metadata": {}, 324 | "outputs": [], 325 | "source": [ 326 | "tsc = ts1 .> ts2" 327 | ] 328 | }, 329 | { 330 | "cell_type": "code", 331 | "execution_count": null, 332 | "metadata": {}, 333 | "outputs": [], 334 | "source": [ 335 | "tsc .== false" 336 | ] 337 | }, 338 | { 339 | "cell_type": "code", 340 | "execution_count": null, 341 | "metadata": {}, 342 | "outputs": [], 343 | "source": [ 344 | "diffts = diff(unemployment_data)" 345 | ] 346 | }, 347 | { 348 | "cell_type": "code", 349 | "execution_count": null, 350 | "metadata": {}, 351 | "outputs": [], 352 | "source": [ 353 | "bar(diffts)" 354 | ] 355 | }, 356 | { 357 | "cell_type": "code", 358 | "execution_count": null, 359 | "metadata": {}, 360 | "outputs": [], 361 | "source": [ 362 | "ts1" 363 | ] 364 | }, 365 | { 366 | "cell_type": "code", 367 | "execution_count": null, 368 | "metadata": {}, 369 | "outputs": [], 370 | "source": [ 371 | "lag(ts1)" 372 | ] 373 | }, 374 | { 375 | "cell_type": "code", 376 | "execution_count": null, 377 | "metadata": {}, 378 | "outputs": [], 379 | "source": [ 380 | "lagged = lag(unemployment_data, 12)" 381 | ] 382 | }, 383 | { 384 | "cell_type": "code", 385 | "execution_count": null, 386 | "metadata": {}, 387 | "outputs": [], 388 | "source": [ 389 | "common = merge(unemployment_data, lagged)" 390 | ] 391 | }, 392 | { 393 | "cell_type": "code", 394 | "execution_count": null, 395 | "metadata": {}, 396 | "outputs": [], 397 | "source": [ 398 | "plot(unemployment_data)\n", 399 | "plot!(lagged)" 400 | ] 401 | }, 402 | { 403 | "cell_type": "code", 404 | "execution_count": null, 405 | "metadata": {}, 406 | "outputs": [], 407 | "source": [ 408 | "update(unemployment_data, Date(2018, 1, 1), TimeSeries.values(adj_unemployment_data[end])[:][end] * norm_month_avg[1] |> round)" 409 | ] 410 | }, 411 | { 412 | "cell_type": "code", 413 | "execution_count": null, 414 | "metadata": {}, 415 | "outputs": [], 416 | "source": [ 417 | "mean(TimeSeries.values(adj_unemployment_data)[:])" 418 | ] 419 | }, 420 | { 421 | "cell_type": "code", 422 | "execution_count": null, 423 | "metadata": {}, 424 | "outputs": [], 425 | "source": [ 426 | "findall(adj_unemployment_data[:Values] .== maximum(TimeSeries.values(adj_unemployment_data)[:]))" 427 | ] 428 | }, 429 | { 430 | "cell_type": "code", 431 | "execution_count": null, 432 | "metadata": {}, 433 | "outputs": [], 434 | "source": [ 435 | "adj_unemployment_data[98]" 436 | ] 437 | }, 438 | { 439 | "cell_type": "code", 440 | "execution_count": null, 441 | "metadata": {}, 442 | "outputs": [], 443 | "source": [ 444 | "last_trend = from(adj_unemployment_data, Date(2013, 2, 1))" 445 | ] 446 | }, 447 | { 448 | "cell_type": "code", 449 | "execution_count": null, 450 | "metadata": {}, 451 | "outputs": [], 452 | "source": [ 453 | "x = 1:length(last_trend)" 454 | ] 455 | }, 456 | { 457 | "cell_type": "code", 458 | "execution_count": null, 459 | "metadata": {}, 460 | "outputs": [], 461 | "source": [ 462 | "y = TimeSeries.values(last_trend)[:]" 463 | ] 464 | }, 465 | { 466 | "cell_type": "code", 467 | "execution_count": null, 468 | "metadata": {}, 469 | "outputs": [], 470 | "source": [ 471 | "linreg(x, y) = reverse([x ones(length(x))]\\y)\n", 472 | "a, b = linreg(x, y)" 473 | ] 474 | }, 475 | { 476 | "cell_type": "code", 477 | "execution_count": null, 478 | "metadata": {}, 479 | "outputs": [], 480 | "source": [ 481 | "y = a+b*60" 482 | ] 483 | }, 484 | { 485 | "cell_type": "code", 486 | "execution_count": null, 487 | "metadata": {}, 488 | "outputs": [], 489 | "source": [ 490 | "y = y * norm_month_avg[1] |> round" 491 | ] 492 | }, 493 | { 494 | "cell_type": "code", 495 | "execution_count": null, 496 | "metadata": {}, 497 | "outputs": [], 498 | "source": [ 499 | "update(unemployment_data, Date(2018, 1, 1), y) |> plot\n", 500 | "plot!(unemployment_data)" 501 | ] 502 | }, 503 | { 504 | "cell_type": "code", 505 | "execution_count": null, 506 | "metadata": {}, 507 | "outputs": [], 508 | "source": [] 509 | } 510 | ], 511 | "metadata": { 512 | "kernelspec": { 513 | "display_name": "Julia 1.0.1", 514 | "language": "julia", 515 | "name": "julia-1.0" 516 | }, 517 | "language_info": { 518 | "file_extension": ".jl", 519 | "mimetype": "application/julia", 520 | "name": "julia", 521 | "version": "1.0.2" 522 | } 523 | }, 524 | "nbformat": 4, 525 | "nbformat_minor": 2 526 | } 527 | -------------------------------------------------------------------------------- /Chapter10/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[Base64]] 2 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 3 | 4 | [[BinaryProvider]] 5 | deps = ["Libdl", "Pkg", "SHA", "Test"] 6 | git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" 7 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 8 | version = "0.5.3" 9 | 10 | [[CSV]] 11 | deps = ["CategoricalArrays", "DataFrames", "DataStreams", "Dates", "Mmap", "Parsers", "Profile", "Random", "Tables", "Test", "Unicode", "WeakRefStrings"] 12 | git-tree-sha1 = "b92c6f626a044cc9619156d54994b94084d40abe" 13 | uuid = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" 14 | version = "0.4.3" 15 | 16 | [[CategoricalArrays]] 17 | deps = ["Compat", "Future", "Missings", "Printf", "Reexport", "Requires"] 18 | git-tree-sha1 = "94d16e77dfacc59f6d6c1361866906dbb65b6f6b" 19 | uuid = "324d7699-5711-5eae-9e2f-1d82baa6b597" 20 | version = "0.5.2" 21 | 22 | [[CodecZlib]] 23 | deps = ["BinaryProvider", "Libdl", "Test", "TranscodingStreams"] 24 | git-tree-sha1 = "e3df104c84dfc108f0ca203fd7f5bbdc98641ae9" 25 | uuid = "944b1d66-785c-5afd-91f1-9de20f533193" 26 | version = "0.5.1" 27 | 28 | [[ColorTypes]] 29 | deps = ["FixedPointNumbers", "Random", "Test"] 30 | git-tree-sha1 = "f73b0e10f2a5756de7019818a41654686da06b09" 31 | uuid = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" 32 | version = "0.7.5" 33 | 34 | [[Colors]] 35 | deps = ["ColorTypes", "FixedPointNumbers", "InteractiveUtils", "Printf", "Reexport", "Test"] 36 | git-tree-sha1 = "9f0a0210450acb91c730b730a994f8eef1d3d543" 37 | uuid = "5ae59095-9a9b-59fe-a467-6f913c188581" 38 | version = "0.9.5" 39 | 40 | [[Compat]] 41 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 42 | git-tree-sha1 = "ec61a16eed883ad0cfa002d7489b3ce6d039bb9a" 43 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 44 | version = "1.4.0" 45 | 46 | [[Conda]] 47 | deps = ["Compat", "JSON", "VersionParsing"] 48 | git-tree-sha1 = "fb86fe40cb5b35990e368709bfdc1b46dbb99dac" 49 | uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" 50 | version = "1.1.1" 51 | 52 | [[Contour]] 53 | deps = ["LinearAlgebra", "StaticArrays", "Test"] 54 | git-tree-sha1 = "b974e164358fea753ef853ce7bad97afec15bb80" 55 | uuid = "d38c429a-6771-53c6-b99e-75d170b6e991" 56 | version = "0.5.1" 57 | 58 | [[DataFrames]] 59 | deps = ["CategoricalArrays", "CodecZlib", "Compat", "DataStreams", "Dates", "InteractiveUtils", "IteratorInterfaceExtensions", "LinearAlgebra", "Missings", "Printf", "Random", "Reexport", "SortingAlgorithms", "Statistics", "StatsBase", "TableTraits", "Tables", "Test", "TranscodingStreams", "Unicode", "WeakRefStrings"] 60 | git-tree-sha1 = "41ec35bcf49a860706924b9b3e322eed03164c83" 61 | uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" 62 | version = "0.15.2" 63 | 64 | [[DataStreams]] 65 | deps = ["Dates", "Missings", "Test", "WeakRefStrings"] 66 | git-tree-sha1 = "69c72a1beb4fc79490c361635664e13c8e4a9548" 67 | uuid = "9a8bc11e-79be-5b39-94d7-1ccc349a1a85" 68 | version = "0.4.1" 69 | 70 | [[DataStructures]] 71 | deps = ["InteractiveUtils", "OrderedCollections", "Random", "Serialization", "Test"] 72 | git-tree-sha1 = "8fc6e166e24fda04b2b648d4260cdad241788c54" 73 | uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" 74 | version = "0.14.0" 75 | 76 | [[Dates]] 77 | deps = ["Printf"] 78 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 79 | 80 | [[DelimitedFiles]] 81 | deps = ["Mmap"] 82 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 83 | 84 | [[Distributed]] 85 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 86 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 87 | 88 | [[FileWatching]] 89 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 90 | 91 | [[FixedPointNumbers]] 92 | deps = ["Test"] 93 | git-tree-sha1 = "b8045033701c3b10bf2324d7203404be7aef88ba" 94 | uuid = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" 95 | version = "0.5.3" 96 | 97 | [[Future]] 98 | deps = ["Random"] 99 | uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" 100 | 101 | [[GR]] 102 | deps = ["Base64", "DelimitedFiles", "Pkg", "Random", "Serialization", "Sockets", "Test"] 103 | git-tree-sha1 = "d12425c0187189a6f2fabc5eea9f22f25d365049" 104 | uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" 105 | version = "0.36.0" 106 | 107 | [[IJulia]] 108 | deps = ["Base64", "Compat", "Conda", "Dates", "InteractiveUtils", "JSON", "Markdown", "MbedTLS", "Pkg", "Printf", "REPL", "Random", "SoftGlobalScope", "Test", "UUIDs", "ZMQ"] 109 | git-tree-sha1 = "38d1ce0fbbefcb67f5ab46f1093cbce0335092e0" 110 | uuid = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 111 | version = "1.14.1" 112 | 113 | [[InteractiveUtils]] 114 | deps = ["LinearAlgebra", "Markdown"] 115 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 116 | 117 | [[IteratorInterfaceExtensions]] 118 | deps = ["Test"] 119 | git-tree-sha1 = "5484e5ede2a4137b9643f4d646e8e7b87b794415" 120 | uuid = "82899510-4779-5014-852e-03e436cf321d" 121 | version = "0.1.1" 122 | 123 | [[JSON]] 124 | deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] 125 | git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa" 126 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 127 | version = "0.20.0" 128 | 129 | [[LibGit2]] 130 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 131 | 132 | [[Libdl]] 133 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 134 | 135 | [[LinearAlgebra]] 136 | deps = ["Libdl"] 137 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 138 | 139 | [[Logging]] 140 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 141 | 142 | [[Markdown]] 143 | deps = ["Base64"] 144 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 145 | 146 | [[MbedTLS]] 147 | deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets", "Test"] 148 | git-tree-sha1 = "c93a87da4081a3de781f34e0540175795a2ce83d" 149 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 150 | version = "0.6.6" 151 | 152 | [[Measures]] 153 | deps = ["Test"] 154 | git-tree-sha1 = "ddfd6d13e330beacdde2c80de27c1c671945e7d9" 155 | uuid = "442fdcdd-2543-5da2-b0f3-8c86c306513e" 156 | version = "0.3.0" 157 | 158 | [[Missings]] 159 | deps = ["Dates", "InteractiveUtils", "SparseArrays", "Test"] 160 | git-tree-sha1 = "adc26d2ee85a49c413464110d922cf21efc9d233" 161 | uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" 162 | version = "0.3.1" 163 | 164 | [[Mmap]] 165 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 166 | 167 | [[NaNMath]] 168 | deps = ["Compat"] 169 | git-tree-sha1 = "ce3b85e484a5d4c71dd5316215069311135fa9f2" 170 | uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" 171 | version = "0.3.2" 172 | 173 | [[OrderedCollections]] 174 | deps = ["Random", "Serialization", "Test"] 175 | git-tree-sha1 = "85619a3f3e17bb4761fe1b1fd47f0e979f964d5b" 176 | uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" 177 | version = "1.0.2" 178 | 179 | [[Parsers]] 180 | deps = ["Dates", "Mmap", "Test", "WeakRefStrings"] 181 | git-tree-sha1 = "9c2b96d07344f9f716fee1c4a7258ac327d08a6c" 182 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 183 | version = "0.2.15" 184 | 185 | [[Pkg]] 186 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 187 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 188 | 189 | [[PlotThemes]] 190 | deps = ["PlotUtils", "Requires", "Test"] 191 | git-tree-sha1 = "f3afd2d58e1f6ac9be2cea46e4a9083ccc1d990b" 192 | uuid = "ccf2f8ad-2431-5c83-bf29-c5338b663b6a" 193 | version = "0.3.0" 194 | 195 | [[PlotUtils]] 196 | deps = ["Colors", "Dates", "Printf", "Random", "Reexport", "Test"] 197 | git-tree-sha1 = "fd28f30a294a38ec847de95d8ac7ac916ccd7c06" 198 | uuid = "995b91a9-d308-5afd-9ec6-746e21dbc043" 199 | version = "0.5.5" 200 | 201 | [[Plots]] 202 | deps = ["Base64", "Contour", "Dates", "FixedPointNumbers", "GR", "JSON", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "Printf", "Random", "RecipesBase", "Reexport", "Requires", "Showoff", "SparseArrays", "StaticArrays", "Statistics", "StatsBase", "Test", "UUIDs"] 203 | git-tree-sha1 = "5a0455fdc5d2af70bf81d5d7eb9a98704223224e" 204 | uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" 205 | version = "0.22.0" 206 | 207 | [[Printf]] 208 | deps = ["Unicode"] 209 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 210 | 211 | [[Profile]] 212 | deps = ["Printf"] 213 | uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79" 214 | 215 | [[REPL]] 216 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 217 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 218 | 219 | [[Random]] 220 | deps = ["Serialization"] 221 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 222 | 223 | [[RecipesBase]] 224 | deps = ["Random", "Test"] 225 | git-tree-sha1 = "0b3cb370ee4dc00f47f1193101600949f3dcf884" 226 | uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" 227 | version = "0.6.0" 228 | 229 | [[Reexport]] 230 | deps = ["Pkg"] 231 | git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0" 232 | uuid = "189a3867-3050-52da-a836-e630ba90ab69" 233 | version = "0.2.0" 234 | 235 | [[Requires]] 236 | deps = ["Test"] 237 | git-tree-sha1 = "f6fbf4ba64d295e146e49e021207993b6b48c7d1" 238 | uuid = "ae029012-a4dd-5104-9daa-d747884805df" 239 | version = "0.5.2" 240 | 241 | [[SHA]] 242 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 243 | 244 | [[Serialization]] 245 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 246 | 247 | [[SharedArrays]] 248 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 249 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 250 | 251 | [[Showoff]] 252 | deps = ["Compat"] 253 | git-tree-sha1 = "276b24f3ace98bec911be7ff2928d497dc759085" 254 | uuid = "992d4aef-0814-514b-bc4d-f2e9a6c4116f" 255 | version = "0.2.1" 256 | 257 | [[Sockets]] 258 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 259 | 260 | [[SoftGlobalScope]] 261 | deps = ["Test"] 262 | git-tree-sha1 = "97f6dfcf612b9a7260fde44170725d9ea34b1431" 263 | uuid = "b85f4697-e234-5449-a836-ec8e2f98b302" 264 | version = "1.0.7" 265 | 266 | [[SortingAlgorithms]] 267 | deps = ["DataStructures", "Random", "Test"] 268 | git-tree-sha1 = "03f5898c9959f8115e30bc7226ada7d0df554ddd" 269 | uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" 270 | version = "0.3.1" 271 | 272 | [[SparseArrays]] 273 | deps = ["LinearAlgebra", "Random"] 274 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 275 | 276 | [[StaticArrays]] 277 | deps = ["InteractiveUtils", "LinearAlgebra", "Random", "Statistics", "Test"] 278 | git-tree-sha1 = "97c4bf0f647488dd7ac01ea12be5885f88762938" 279 | uuid = "90137ffa-7385-5640-81b9-e52037218182" 280 | version = "0.10.0" 281 | 282 | [[Statistics]] 283 | deps = ["LinearAlgebra", "SparseArrays"] 284 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 285 | 286 | [[StatsBase]] 287 | deps = ["DataStructures", "LinearAlgebra", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "Test"] 288 | git-tree-sha1 = "2722397d88f8ffef551948f6c20e1d74a743298c" 289 | uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" 290 | version = "0.26.0" 291 | 292 | [[TableTraits]] 293 | deps = ["IteratorInterfaceExtensions", "Test"] 294 | git-tree-sha1 = "da062a2c31f16178f68190243c24140801720a43" 295 | uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" 296 | version = "0.4.0" 297 | 298 | [[Tables]] 299 | deps = ["Requires", "Test"] 300 | git-tree-sha1 = "940944e6b68a35046282897a2218891c7cf14a32" 301 | uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" 302 | version = "0.1.12" 303 | 304 | [[Test]] 305 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 306 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 307 | 308 | [[TimeSeries]] 309 | deps = ["Dates", "DelimitedFiles", "Random", "RecipesBase", "Statistics", "Test"] 310 | git-tree-sha1 = "5a7bcdfbdac440ad5395b97701a21f423b338fc5" 311 | uuid = "9e3dc215-6440-5c97-bce1-76c03772f85e" 312 | version = "0.14.0" 313 | 314 | [[TranscodingStreams]] 315 | deps = ["Pkg", "Random", "Test"] 316 | git-tree-sha1 = "a34a2d588e2d2825602bf14a24216d5c8b0921ec" 317 | uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" 318 | version = "0.8.1" 319 | 320 | [[UUIDs]] 321 | deps = ["Random"] 322 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 323 | 324 | [[Unicode]] 325 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 326 | 327 | [[VersionParsing]] 328 | deps = ["Compat"] 329 | git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" 330 | uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" 331 | version = "1.1.3" 332 | 333 | [[WeakRefStrings]] 334 | deps = ["Missings", "Random", "Test"] 335 | git-tree-sha1 = "1087e8be380f2c8b96434b02bb1150fc1c511135" 336 | uuid = "ea10d353-3f73-51f8-a26c-33c1cb351aa5" 337 | version = "0.5.3" 338 | 339 | [[ZMQ]] 340 | deps = ["BinaryProvider", "FileWatching", "Libdl", "Sockets", "Test"] 341 | git-tree-sha1 = "34e7ac2d1d59d19d0e86bde99f1f02262bfa1613" 342 | uuid = "c2297ded-f4af-51ae-bb23-16f91089e4e1" 343 | version = "1.0.0" 344 | -------------------------------------------------------------------------------- /Chapter10/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" 3 | DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" 4 | Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" 5 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 6 | Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 7 | Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" 8 | Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 9 | TimeSeries = "9e3dc215-6440-5c97-bce1-76c03772f85e" 10 | -------------------------------------------------------------------------------- /Chapter10/data/UE-unemployment.tsv: -------------------------------------------------------------------------------- 1 | Dates,Values 2 | 2005-01-01,21974 3 | 2005-02-01,22303 4 | 2005-03-01,22085 5 | 2005-04-01,21036 6 | 2005-05-01,20849 7 | 2005-06-01,20549 8 | 2005-07-01,19873 9 | 2005-08-01,20210 10 | 2005-09-01,20554 11 | 2005-10-01,20919 12 | 2005-11-01,20599 13 | 2005-12-01,20470 14 | 2006-01-01,21140 15 | 2006-02-01,20980 16 | 2006-03-01,20578 17 | 2006-04-01,19687 18 | 2006-05-01,19047 19 | 2006-06-01,18859 20 | 2006-07-01,18517 21 | 2006-08-01,18649 22 | 2006-09-01,18708 23 | 2006-10-01,18706 24 | 2006-11-01,18727 25 | 2006-12-01,18316 26 | 2007-01-01,18552 27 | 2007-02-01,18559 28 | 2007-03-01,17842 29 | 2007-04-01,17051 30 | 2007-05-01,16758 31 | 2007-06-01,16420 32 | 2007-07-01,16497 33 | 2007-08-01,16475 34 | 2007-09-01,16470 35 | 2007-10-01,16406 36 | 2007-11-01,16449 37 | 2007-12-01,16510 38 | 2008-01-01,16989 39 | 2008-02-01,16904 40 | 2008-03-01,16597 41 | 2008-04-01,16392 42 | 2008-05-01,16051 43 | 2008-06-01,16430 44 | 2008-07-01,16142 45 | 2008-08-01,16284 46 | 2008-09-01,16499 47 | 2008-10-01,16985 48 | 2008-11-01,17582 49 | 2008-12-01,18328 50 | 2009-01-01,19940 51 | 2009-02-01,21067 52 | 2009-03-01,21327 53 | 2009-04-01,21243 54 | 2009-05-01,20940 55 | 2009-06-01,20972 56 | 2009-07-01,21131 57 | 2009-08-01,21305 58 | 2009-09-01,21796 59 | 2009-10-01,22089 60 | 2009-11-01,22308 61 | 2009-12-01,22479 62 | 2010-01-01,23920 63 | 2010-02-01,24383 64 | 2010-03-01,23912 65 | 2010-04-01,23410 66 | 2010-05-01,22880 67 | 2010-06-01,22336 68 | 2010-07-01,22209 69 | 2010-08-01,22036 70 | 2010-09-01,22475 71 | 2010-10-01,22946 72 | 2010-11-01,22829 73 | 2010-12-01,22840 74 | 2011-01-01,23614 75 | 2011-02-01,23644 76 | 2011-03-01,23407 77 | 2011-04-01,22626 78 | 2011-05-01,22464 79 | 2011-06-01,22282 80 | 2011-07-01,22365 81 | 2011-08-01,22590 82 | 2011-09-01,22990 83 | 2011-10-01,23524 84 | 2011-11-01,24098 85 | 2011-12-01,24196 86 | 2012-01-01,25278 87 | 2012-02-01,25596 88 | 2012-03-01,25565 89 | 2012-04-01,25028 90 | 2012-05-01,24946 91 | 2012-06-01,24669 92 | 2012-07-01,24696 93 | 2012-08-01,24652 94 | 2012-09-01,25144 95 | 2012-10-01,25799 96 | 2012-11-01,26176 97 | 2012-12-01,25979 98 | 2013-01-01,27577 99 | 2013-02-01,27790 100 | 2013-03-01,27292 101 | 2013-04-01,26755 102 | 2013-05-01,26292 103 | 2013-06-01,25805 104 | 2013-07-01,25501 105 | 2013-08-01,25459 106 | 2013-09-01,25813 107 | 2013-10-01,25918 108 | 2013-11-01,26144 109 | 2013-12-01,25629 110 | 2014-01-01,26785 111 | 2014-02-01,26804 112 | 2014-03-01,26226 113 | 2014-04-01,25242 114 | 2014-05-01,24692 115 | 2014-06-01,23898 116 | 2014-07-01,23668 117 | 2014-08-01,23648 118 | 2014-09-01,24058 119 | 2014-10-01,24410 120 | 2014-11-01,24755 121 | 2014-12-01,23792 122 | 2015-01-01,24626 123 | 2015-02-01,24798 124 | 2015-03-01,24365 125 | 2015-04-01,23566 126 | 2015-05-01,22989 127 | 2015-06-01,22652 128 | 2015-07-01,21902 129 | 2015-08-01,21594 130 | 2015-09-01,21962 131 | 2015-10-01,22226 132 | 2015-11-01,22201 133 | 2015-12-01,21941 134 | 2016-01-01,22430 135 | 2016-02-01,22560 136 | 2016-03-01,22097 137 | 2016-04-01,21345 138 | 2016-05-01,20957 139 | 2016-06-01,20611 140 | 2016-07-01,20215 141 | 2016-08-01,20082 142 | 2016-09-01,20257 143 | 2016-10-01,20343 144 | 2016-11-01,20477 145 | 2016-12-01,19893 146 | 2017-01-01,20512 147 | 2017-02-01,20443 148 | 2017-03-01,19929 149 | 2017-04-01,19203 150 | 2017-05-01,18713 151 | 2017-06-01,18155 152 | 2017-07-01,18172 153 | 2017-08-01,18155 154 | 2017-09-01,18121 155 | 2017-10-01,18199 156 | 2017-11-01,18027 157 | 2017-12-01,17705 158 | -------------------------------------------------------------------------------- /Chapter10/data/une_rt_m_1.tsv: -------------------------------------------------------------------------------- 1 | GEO,S_ADJ,AGE,UNIT,SEX\TIME 2005M01 2005M02 2005M03 2005M04 2005M05 2005M06 2005M07 2005M08 2005M09 2005M10 2005M11 2005M12 2006M01 2006M02 2006M03 2006M04 2006M05 2006M06 2006M07 2006M08 2006M09 2006M10 2006M11 2006M12 2007M01 2007M02 2007M03 2007M04 2007M05 2007M06 2007M07 2007M08 2007M09 2007M10 2007M11 2007M12 2008M01 2008M02 2008M03 2008M04 2008M05 2008M06 2008M07 2008M08 2008M09 2008M10 2008M11 2008M12 2009M01 2009M02 2009M03 2009M04 2009M05 2009M06 2009M07 2009M08 2009M09 2009M10 2009M11 2009M12 2010M01 2010M02 2010M03 2010M04 2010M05 2010M06 2010M07 2010M08 2010M09 2010M10 2010M11 2010M12 2011M01 2011M02 2011M03 2011M04 2011M05 2011M06 2011M07 2011M08 2011M09 2011M10 2011M11 2011M12 2012M01 2012M02 2012M03 2012M04 2012M05 2012M06 2012M07 2012M08 2012M09 2012M10 2012M11 2012M12 2013M01 2013M02 2013M03 2013M04 2013M05 2013M06 2013M07 2013M08 2013M09 2013M10 2013M11 2013M12 2014M01 2014M02 2014M03 2014M04 2014M05 2014M06 2014M07 2014M08 2014M09 2014M10 2014M11 2014M12 2015M01 2015M02 2015M03 2015M04 2015M05 2015M06 2015M07 2015M08 2015M09 2015M10 2015M11 2015M12 2016M01 2016M02 2016M03 2016M04 2016M05 2016M06 2016M07 2016M08 2016M09 2016M10 2016M11 2016M12 2017M01 2017M02 2017M03 2017M04 2017M05 2017M06 2017M07 2017M08 2017M09 2017M10 2017M11 2017M12 2 | European Union (current composition),Unadjusted data (i.e. neither seasonally adjusted nor calendar adjusted data),Total,Thousand persons,Total 21 974 22 303 22 085 21 036 20 849 20 549 19 873 20 210 20 554 20 919 20 599 20 470 21 140 20 980 20 578 19 687 19 047 18 859 18 517 18 649 18 708 18 706 18 727 18 316 18 552 18 559 17 842 17 051 16 758 16 420 16 497 16 475 16 470 16 406 16 449 16 510 16 989 16 904 16 597 16 392 16 051 16 430 16 142 16 284 16 499 16 985 17 582 18 328 19 940 21 067 21 327 21 243 20 940 20 972 21 131 21 305 21 796 22 089 22 308 22 479 23 920 24 383 23 912 23 410 22 880 22 336 22 209 22 036 22 475 22 946 22 829 22 840 23 614 23 644 23 407 22 626 22 464 22 282 22 365 22 590 22 990 23 524 24 098 24 196 25 278 25 596 25 565 25 028 24 946 24 669 24 696 24 652 25 144 25 799 26 176 25 979 27 577 27 790 27 292 26 755 26 292 25 805 25 501 25 459 25 813 25 918 26 144 25 629 26 785 26 804 26 226 25 242 24 692 23 898 23 668 23 648 24 058 24 410 24 755 23 792 24 626 24 798 24 365 23 566 22 989 22 652 21 902 21 594 21 962 22 226 22 201 21 941 22 430 22 560 22 097 21 345 20 957 20 611 20 215 20 082 20 257 20 343 20 477 19 893 20 512 20 443 19 929 19 203 18 713 18 155 18 172 18 155 18 121 18 199 18 027 17 705 3 | -------------------------------------------------------------------------------- /Chapter11/Chapter 11.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "using Pkg\n", 10 | "pkg\"activate .\"" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "# Run this cell in order to download all the package dependencies with the exact versions used in the book\n", 20 | "# This is necessary if (some of) the packages have been updated and have introduced breaking changes\n", 21 | "pkg\"instantiate\"" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": null, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "using Test" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "metadata": { 37 | "inputHidden": false, 38 | "outputHidden": false 39 | }, 40 | "outputs": [], 41 | "source": [ 42 | "@test 1 == 1" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": null, 48 | "metadata": { 49 | "inputHidden": false, 50 | "outputHidden": false 51 | }, 52 | "outputs": [], 53 | "source": [ 54 | "@test 'A' == 'a'" 55 | ] 56 | }, 57 | { 58 | "cell_type": "code", 59 | "execution_count": null, 60 | "metadata": { 61 | "inputHidden": false, 62 | "outputHidden": false 63 | }, 64 | "outputs": [], 65 | "source": [ 66 | "@testset \"Example\" begin\n", 67 | " @test :a == :a\n", 68 | " @test 'x' == 'y'\n", 69 | "end" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": null, 75 | "metadata": { 76 | "inputHidden": false, 77 | "outputHidden": false 78 | }, 79 | "outputs": [], 80 | "source": [ 81 | "@testset \"Example\" begin\n", 82 | " error(\"Oh no!\")\n", 83 | "end" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": null, 89 | "metadata": { 90 | "inputHidden": false, 91 | "outputHidden": false 92 | }, 93 | "outputs": [], 94 | "source": [ 95 | "using Pkg\n", 96 | "pkg\"add BenchmarkTools\"\n", 97 | "using BenchmarkTools" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": null, 103 | "metadata": { 104 | "inputHidden": false, 105 | "outputHidden": false 106 | }, 107 | "outputs": [], 108 | "source": [ 109 | "function f1()\n", 110 | " x = 0\n", 111 | "\n", 112 | " for i in 1:10\n", 113 | " x += sin(i)\n", 114 | " end\n", 115 | " \t\n", 116 | " x\n", 117 | "end" 118 | ] 119 | }, 120 | { 121 | "cell_type": "code", 122 | "execution_count": null, 123 | "metadata": { 124 | "inputHidden": false, 125 | "outputHidden": false 126 | }, 127 | "outputs": [], 128 | "source": [ 129 | "@code_warntype f1()" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": null, 135 | "metadata": { 136 | "inputHidden": false, 137 | "outputHidden": false 138 | }, 139 | "outputs": [], 140 | "source": [ 141 | "pkg\"add Traceur\"\n", 142 | "using Traceur" 143 | ] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": null, 148 | "metadata": { 149 | "inputHidden": false, 150 | "outputHidden": false 151 | }, 152 | "outputs": [], 153 | "source": [ 154 | "@trace f1()" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": null, 160 | "metadata": { 161 | "inputHidden": false, 162 | "outputHidden": false 163 | }, 164 | "outputs": [], 165 | "source": [ 166 | "function f2()\n", 167 | " x = 0.0\n", 168 | "\n", 169 | " for i in 1:10\n", 170 | " x += sin(i)\n", 171 | " end\n", 172 | " \n", 173 | " x\n", 174 | "end" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": null, 180 | "metadata": { 181 | "inputHidden": false, 182 | "outputHidden": false 183 | }, 184 | "outputs": [], 185 | "source": [ 186 | "@trace f2()" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": null, 192 | "metadata": { 193 | "inputHidden": false, 194 | "outputHidden": false 195 | }, 196 | "outputs": [], 197 | "source": [ 198 | "@btime f1()" 199 | ] 200 | }, 201 | { 202 | "cell_type": "code", 203 | "execution_count": null, 204 | "metadata": { 205 | "inputHidden": false, 206 | "outputHidden": false 207 | }, 208 | "outputs": [], 209 | "source": [ 210 | "@btime f2()" 211 | ] 212 | }, 213 | { 214 | "cell_type": "code", 215 | "execution_count": null, 216 | "metadata": { 217 | "inputHidden": false, 218 | "outputHidden": false 219 | }, 220 | "outputs": [], 221 | "source": [] 222 | } 223 | ], 224 | "metadata": { 225 | "kernel_info": { 226 | "name": "julia-1.0" 227 | }, 228 | "kernelspec": { 229 | "display_name": "Julia 1.0.1", 230 | "language": "julia", 231 | "name": "julia-1.0" 232 | }, 233 | "language_info": { 234 | "file_extension": ".jl", 235 | "mimetype": "application/julia", 236 | "name": "julia", 237 | "version": "1.0.2" 238 | }, 239 | "nteract": { 240 | "version": "0.12.3" 241 | } 242 | }, 243 | "nbformat": 4, 244 | "nbformat_minor": 2 245 | } 246 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/.gitignore: -------------------------------------------------------------------------------- 1 | secrets.jl -------------------------------------------------------------------------------- /Chapter11/IssueReporter/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[Base64]] 2 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 3 | 4 | [[BenchmarkTools]] 5 | deps = ["JSON", "Printf", "Statistics", "Test"] 6 | git-tree-sha1 = "e686f1754227e4748259f400839b83a1e8773e02" 7 | uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" 8 | version = "0.4.1" 9 | 10 | [[BinaryProvider]] 11 | deps = ["Libdl", "Pkg", "SHA", "Test"] 12 | git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" 13 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 14 | version = "0.5.3" 15 | 16 | [[Cassette]] 17 | deps = ["InteractiveUtils", "LinearAlgebra", "Test"] 18 | git-tree-sha1 = "dac71009ded2090e014098c566cfae447cfd686b" 19 | uuid = "7057c7e9-c182-5462-911a-8362d720325c" 20 | version = "0.1.4" 21 | 22 | [[Compat]] 23 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 24 | git-tree-sha1 = "ec61a16eed883ad0cfa002d7489b3ce6d039bb9a" 25 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 26 | version = "1.4.0" 27 | 28 | [[Dates]] 29 | deps = ["Printf"] 30 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 31 | 32 | [[DelimitedFiles]] 33 | deps = ["Mmap"] 34 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 35 | 36 | [[Distributed]] 37 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 38 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 39 | 40 | [[DocStringExtensions]] 41 | deps = ["LibGit2", "Markdown", "Pkg", "Test"] 42 | git-tree-sha1 = "1df01539a1c952cef21f2d2d1c092c2bcf0177d7" 43 | uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" 44 | version = "0.6.0" 45 | 46 | [[Documenter]] 47 | deps = ["Base64", "DocStringExtensions", "InteractiveUtils", "LibGit2", "Logging", "Markdown", "Pkg", "REPL", "Random", "Test", "Unicode"] 48 | git-tree-sha1 = "9f2135e0e7ecb63f9c3ef73ea15a31d8cdb79bb7" 49 | uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" 50 | version = "0.20.0" 51 | 52 | [[GitHub]] 53 | deps = ["Base64", "Compat", "Dates", "HTTP", "JSON", "MbedTLS", "Test"] 54 | git-tree-sha1 = "b988ce46c9b682acfeed4801cbaafa1ef954ad31" 55 | uuid = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26" 56 | version = "5.0.2" 57 | 58 | [[HTTP]] 59 | deps = ["Base64", "Dates", "Distributed", "IniFile", "MbedTLS", "Sockets", "Test"] 60 | git-tree-sha1 = "b881f69331e85642be315c63d05ed65d6fc8a05b" 61 | uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" 62 | version = "0.7.1" 63 | 64 | [[IniFile]] 65 | deps = ["Test"] 66 | git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" 67 | uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" 68 | version = "0.5.0" 69 | 70 | [[InteractiveUtils]] 71 | deps = ["LinearAlgebra", "Markdown"] 72 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 73 | 74 | [[JSON]] 75 | deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] 76 | git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa" 77 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 78 | version = "0.20.0" 79 | 80 | [[LibGit2]] 81 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 82 | 83 | [[Libdl]] 84 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 85 | 86 | [[LinearAlgebra]] 87 | deps = ["Libdl"] 88 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 89 | 90 | [[Logging]] 91 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 92 | 93 | [[MacroTools]] 94 | deps = ["Compat"] 95 | git-tree-sha1 = "c443e1c8d58a4e9f61b708ad0a88286c7042145b" 96 | uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" 97 | version = "0.4.4" 98 | 99 | [[Markdown]] 100 | deps = ["Base64"] 101 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 102 | 103 | [[MbedTLS]] 104 | deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets", "Test"] 105 | git-tree-sha1 = "c93a87da4081a3de781f34e0540175795a2ce83d" 106 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 107 | version = "0.6.6" 108 | 109 | [[Mmap]] 110 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 111 | 112 | [[Pkg]] 113 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 114 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 115 | 116 | [[Printf]] 117 | deps = ["Unicode"] 118 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 119 | 120 | [[REPL]] 121 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 122 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 123 | 124 | [[Random]] 125 | deps = ["Serialization"] 126 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 127 | 128 | [[SHA]] 129 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 130 | 131 | [[Serialization]] 132 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 133 | 134 | [[SharedArrays]] 135 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 136 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 137 | 138 | [[Sockets]] 139 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 140 | 141 | [[SparseArrays]] 142 | deps = ["LinearAlgebra", "Random"] 143 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 144 | 145 | [[Statistics]] 146 | deps = ["LinearAlgebra", "SparseArrays"] 147 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 148 | 149 | [[Test]] 150 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 151 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 152 | 153 | [[Traceur]] 154 | deps = ["Cassette", "InteractiveUtils", "Logging", "MacroTools", "Test"] 155 | git-tree-sha1 = "d46ea4a2575f896e90c8a4b52ce2841e6db7d059" 156 | uuid = "37b6cedf-1f77-55f8-9503-c64b63398394" 157 | version = "0.2.0" 158 | 159 | [[URIParser]] 160 | deps = ["Test", "Unicode"] 161 | git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" 162 | uuid = "30578b45-9adc-5946-b283-645ec420af67" 163 | version = "0.4.0" 164 | 165 | [[UUIDs]] 166 | deps = ["Random"] 167 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 168 | 169 | [[Unicode]] 170 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 171 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/Project.toml: -------------------------------------------------------------------------------- 1 | name = "IssueReporter" 2 | uuid = "7b29c13e-f3eb-11e8-2be5-fb20b77ad364" 3 | authors = ["Adrian Salceanu "] 4 | version = "0.1.0" 5 | 6 | [deps] 7 | BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" 8 | DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" 9 | Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" 10 | GitHub = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26" 11 | Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 12 | Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 13 | Traceur = "37b6cedf-1f77-55f8-9503-c64b63398394" 14 | URIParser = "30578b45-9adc-5946-b283-645ec420af67" 15 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/README.md: -------------------------------------------------------------------------------- 1 | # IssueReporter.jl 2 | 3 | `IssueReporter.jl` is a Julia package which makes it easy to report a new issue with a registered package. 4 | In order to use it, it needs to be configured with a valid GitHub authenti-cation token. Follow the instructions at 5 | https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ to generate a new token -- make sure 6 | that it has the `repo` access. 7 | 8 | Once you have the token, add it to the secrets.jl file. 9 | 10 | You can now open issues by invoking: 11 | `IssueReporter.report("Julia package name", "issue title", "issue body") 12 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/docs/build/assets/arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 39 | 41 | 42 | 44 | image/svg+xml 45 | 47 | 48 | 49 | 50 | 51 | 56 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/docs/build/assets/documenter.css: -------------------------------------------------------------------------------- 1 | /* 2 | * The default CSS style for Documenter.jl generated sites 3 | * 4 | * Heavily inspired by the Julia Sphinx theme 5 | * https://github.com/JuliaLang/JuliaDoc 6 | * which extends the sphinx_rtd_theme 7 | * https://github.com/snide/sphinx_rtd_theme 8 | * 9 | * Part of Documenter.jl 10 | * https://github.com/JuliaDocs/Documenter.jl 11 | * 12 | * License: MIT 13 | */ 14 | 15 | /* fonts */ 16 | body, input { 17 | font-family: 'Lato', 'Helvetica Neue', Arial, sans-serif; 18 | font-size: 16px; 19 | color: #222; 20 | text-rendering: optimizeLegibility; 21 | } 22 | 23 | pre, code, kbd { 24 | font-family: 'Roboto Mono', Monaco, courier, monospace; 25 | font-size: 0.90em; 26 | } 27 | 28 | pre code { 29 | font-size: 1em; 30 | } 31 | 32 | a { 33 | color: #2980b9; 34 | text-decoration: none; 35 | } 36 | 37 | a:hover { 38 | color: #3091d1; 39 | } 40 | 41 | a:visited { 42 | color: #9b59b6; 43 | } 44 | 45 | body { 46 | line-height: 1.5; 47 | } 48 | 49 | h1 { 50 | font-size: 1.75em; 51 | } 52 | 53 | /* Unless the

the is very first thing on the page (i.e. the second element 54 | * in the
, * after the
, we add some additional styling to it 55 | * to make it stand out a bit more. This way we get a reasonable fallback if CSS3 56 | * selectors are not supported in the browser. 57 | */ 58 | article > h1:not(:nth-child(2)) { 59 | margin: 2.5em 0 0; 60 | padding-bottom: 0.30em; 61 | border-bottom: 1px solid #e5e5e5; 62 | } 63 | h2 { 64 | font-size: 1.50em; 65 | margin: 2.3em 0 0; 66 | padding-bottom: 0.25em; 67 | border-bottom: 1px solid #e5e5e5; 68 | } 69 | h3 { 70 | font-size: 1.25em; 71 | margin: 2.0em 0 0; 72 | } 73 | h4 { font-size: 1.15em; } 74 | h5 { font-size: 1.10em; } 75 | h6 { font-size: 1em; } 76 | 77 | h4, h5, h6 { 78 | margin-top: 1.5em; 79 | margin-bottom: 1em; 80 | } 81 | 82 | img { 83 | max-width: 100%; 84 | } 85 | 86 | table { 87 | border-collapse: collapse; 88 | margin: 1em 0; 89 | } 90 | 91 | th, td { 92 | border: 1px solid #e1e4e5; 93 | padding: 0.5em 1em; 94 | } 95 | 96 | th { 97 | border-bottom-width: 2px; 98 | } 99 | 100 | tr:nth-child(even) { 101 | background-color: #f3f6f6; 102 | } 103 | 104 | hr { 105 | border: 0; 106 | border-top: 1px solid #e5e5e5; 107 | } 108 | 109 | /* Inline code and code blocks */ 110 | 111 | code { 112 | padding: 0.1em; 113 | background-color: rgba(0,0,0,.04); 114 | border-radius: 3px; 115 | } 116 | 117 | pre { 118 | background-color: #f5f5f5; 119 | border: 1px solid #dddddd; 120 | border-radius: 3px; 121 | padding: 0.5em; 122 | overflow: auto; 123 | } 124 | 125 | pre code { 126 | padding: 0; 127 | background-color: initial; 128 | } 129 | 130 | kbd { 131 | font-size: 0.70em; 132 | display: inline-block; 133 | padding: 0.1em 0.5em 0.4em 0.5em; 134 | line-height: 1.0em; 135 | color: #444d56; 136 | vertical-align: middle; 137 | background-color: #fafbfc; 138 | border: solid 1px #c6cbd1; 139 | border-bottom-color: #959da5; 140 | border-radius: 3px; 141 | box-shadow: inset 0 -1px 0 #959da5; 142 | } 143 | 144 | /* Headers in admonitions and docstrings */ 145 | .admonition h1, 146 | article section.docstring h1 { 147 | font-size: 1.25em; 148 | } 149 | 150 | .admonition h2, 151 | article section.docstring h2 { 152 | font-size: 1.10em; 153 | } 154 | 155 | .admonition h3, 156 | .admonition h4, 157 | .admonition h5, 158 | .admonition h6, 159 | article section.docstring h3, 160 | article section.docstring h4, 161 | article section.docstring h5, 162 | article section.docstring h6 { 163 | font-size: 1em; 164 | } 165 | 166 | /* Navigation */ 167 | nav.toc { 168 | position: fixed; 169 | top: 0; 170 | left: 0; 171 | bottom: 0; 172 | width: 20em; 173 | display: flex; 174 | flex-flow: column nowrap; 175 | overflow-y: auto; 176 | padding: 1em 0 0 0; 177 | background-color: #fcfcfc; 178 | box-shadow: inset -14px 0px 5px -12px rgb(210,210,210); 179 | } 180 | 181 | nav.toc .logo { 182 | margin: 0 auto; 183 | display: block; 184 | max-height: 6em; 185 | max-width: 18em; 186 | } 187 | 188 | nav.toc h1 { 189 | text-align: center; 190 | margin-top: .57em; 191 | margin-bottom: 0; 192 | } 193 | 194 | nav.toc select { 195 | display: block; 196 | height: 2em; 197 | flex-shrink: 0; 198 | padding: 0 1.6em 0 1em; 199 | min-width: 7em; 200 | max-width: 90%; 201 | max-width: calc(100% - 5em); 202 | margin: 0 auto; 203 | font-size: .83em; 204 | border: 1px solid #c9c9c9; 205 | border-radius: 1em; 206 | 207 | /* TODO: doesn't seem to be centered on Safari */ 208 | text-align: center; 209 | text-align-last: center; 210 | 211 | appearance: none; 212 | -moz-appearance: none; 213 | -webkit-appearance: none; 214 | 215 | background: white url("arrow.svg"); 216 | background-size: 1.155em; 217 | background-repeat: no-repeat; 218 | background-position: right; 219 | } 220 | 221 | nav.toc select:hover { 222 | border: 1px solid #a0a0a0; 223 | } 224 | 225 | nav.toc select option { 226 | text-align: center; 227 | } 228 | 229 | nav.toc input { 230 | display: block; 231 | height: 2em; 232 | width: 90%; 233 | width: calc(100% - 5em); 234 | margin: 1.2em auto; 235 | padding: 0 1em; 236 | border: 1px solid #c9c9c9; 237 | border-radius: 1em; 238 | font-size: .83em; 239 | } 240 | 241 | nav.toc > ul * { 242 | margin: 0; 243 | } 244 | 245 | nav.toc > ul { 246 | min-height: 2em; 247 | overflow-y: auto; 248 | margin: 0; 249 | } 250 | 251 | nav.toc > ul > li:last-child { 252 | padding-bottom: 1em; 253 | } 254 | 255 | nav.toc ul { 256 | color: #404040; 257 | padding: 0; 258 | list-style: none; 259 | } 260 | 261 | nav.toc ul .toctext { 262 | color: inherit; 263 | display: block; 264 | } 265 | 266 | nav.toc ul a:hover { 267 | color: #fcfcfc; 268 | background-color: #4e4a4a; 269 | } 270 | 271 | nav.toc ul.internal a { 272 | color: inherit; 273 | display: block; 274 | } 275 | 276 | nav.toc ul.internal a:hover { 277 | background-color: #d6d6d6; 278 | } 279 | 280 | nav.toc ul.internal { 281 | background-color: #e3e3e3; 282 | box-shadow: inset -14px 0px 5px -12px rgb(210,210,210); 283 | list-style: none; 284 | } 285 | 286 | nav.toc ul.internal li.toplevel { 287 | border-top: 1px solid #909090; 288 | font-weight: bold; 289 | } 290 | 291 | nav.toc ul.internal li.toplevel:first-child { 292 | border-top: none; 293 | } 294 | 295 | nav.toc .toctext { 296 | padding-top: 0.3em; 297 | padding-bottom: 0.3em; 298 | padding-right: 1em; 299 | } 300 | 301 | nav.toc ul .toctext { 302 | padding-left: 1em; 303 | } 304 | 305 | nav.toc ul ul .toctext { 306 | padding-left: 2em; 307 | } 308 | 309 | nav.toc ul ul ul .toctext { 310 | padding-left: 3em; 311 | } 312 | 313 | nav.toc li.current > .toctext { 314 | border-top: 1px solid #c9c9c9; 315 | border-bottom: 1px solid #c9c9c9; 316 | color: #404040; 317 | font-weight: bold; 318 | background-color: white; 319 | } 320 | 321 | nav.toc ul::-webkit-scrollbar { 322 | width: .4em; 323 | background: none; 324 | } 325 | 326 | nav.toc ul::-webkit-scrollbar-thumb { 327 | border-radius: 5px; 328 | background: #c9c9c9; 329 | } 330 | 331 | nav.toc ul::-webkit-scrollbar-thumb:hover { 332 | border-radius: 5px; 333 | background: #aaaaaa; 334 | } 335 | 336 | article { 337 | margin-left: 20em; 338 | min-width: 20em; 339 | max-width: 48em; 340 | padding: 2em; 341 | } 342 | 343 | article > header {} 344 | 345 | article > header div#topbar { 346 | display: none; 347 | } 348 | 349 | article > header nav ul { 350 | display: inline-block; 351 | list-style: none; 352 | margin: 0; 353 | padding: 0; 354 | } 355 | 356 | article > header nav li { 357 | display: inline-block; 358 | padding-right: 0.2em; 359 | } 360 | 361 | article > header nav li:before { 362 | content: "»"; 363 | padding-right: 0.2em; 364 | } 365 | 366 | article > header .edit-page { 367 | float: right; 368 | } 369 | 370 | article > footer {} 371 | 372 | article > footer a.prev { 373 | float: left; 374 | } 375 | article > footer a.next { 376 | float: right; 377 | } 378 | 379 | article > footer a .direction:after { 380 | content: ": "; 381 | } 382 | 383 | article hr { 384 | margin: 1em 0; 385 | } 386 | 387 | article section.docstring { 388 | border: 1px solid #ddd; 389 | margin: 0.5em 0; 390 | padding: 0.5em; 391 | border-radius: 3px; 392 | } 393 | 394 | article section.docstring .docstring-header { 395 | margin-bottom: 1em; 396 | } 397 | 398 | article section.docstring .docstring-binding { 399 | color: #333; 400 | font-weight: bold; 401 | } 402 | 403 | article section.docstring .docstring-category { 404 | font-style: italic; 405 | } 406 | 407 | article section.docstring a.source-link { 408 | display: block; 409 | font-weight: bold; 410 | } 411 | 412 | .nav-anchor, 413 | .nav-anchor:hover, 414 | .nav-anchor:visited { 415 | color: #333; 416 | } 417 | 418 | /* 419 | * Admonitions 420 | * 421 | * Colors (title, body) 422 | * warning: #f0b37e #ffedcc (orange) 423 | * note: #6ab0de #e7f2fa (blue) 424 | * tip: #1abc9c #dbfaf4 (green) 425 | */ 426 | .admonition { 427 | border-radius: 3px; 428 | background-color: #eeeeee; 429 | margin: 1em 0; 430 | } 431 | 432 | .admonition-title { 433 | border-radius: 3px 3px 0 0; 434 | background-color: #9b9b9b; 435 | padding: 0.15em 0.5em; 436 | } 437 | 438 | .admonition-text { 439 | padding: 0.5em; 440 | } 441 | 442 | .admonition-text > :first-child { 443 | margin-top: 0; 444 | } 445 | 446 | .admonition-text > :last-child { 447 | margin-bottom: 0; 448 | } 449 | 450 | .admonition > .admonition-title:before { 451 | font-family: "FontAwesome"; 452 | margin-right: 5px; 453 | content: "\f06a"; 454 | } 455 | 456 | .admonition.warning > .admonition-title { 457 | background-color: #f0b37e; 458 | } 459 | 460 | .admonition.warning { 461 | background-color: #ffedcc; 462 | } 463 | 464 | .admonition.note > .admonition-title { 465 | background-color: #6ab0de; 466 | } 467 | 468 | .admonition.note { 469 | background-color: #e7f2fa; 470 | } 471 | 472 | .admonition.tip > .admonition-title { 473 | background-color: #1abc9c; 474 | } 475 | 476 | .admonition.tip { 477 | background-color: #dbfaf4; 478 | } 479 | 480 | 481 | /* footnotes */ 482 | .footnote { 483 | padding-left: 0.8em; 484 | border-left: 2px solid #ccc; 485 | } 486 | 487 | /* Search page */ 488 | #search-results .category { 489 | font-size: smaller; 490 | } 491 | 492 | /* Overriding the block style of highligh.js. 493 | * We have to override the padding and the background-color, since we style this 494 | * part ourselves. Specifically, we style the
 surrounding the , while
495 |  * highlight.js applies the .hljs style directly to the  tag.
496 |  */
497 | .hljs {
498 |     background-color: transparent;
499 |     padding: 0;
500 | }
501 | 
502 | @media only screen and (max-width: 768px) {
503 |     nav.toc {
504 |         position: fixed;
505 |         width: 16em;
506 |         left: -16em;
507 |         -webkit-overflow-scrolling: touch;
508 |         -webkit-transition-property: left; /* Safari */
509 |         -webkit-transition-duration: 0.3s; /* Safari */
510 |         transition-property: left;
511 |         transition-duration: 0.3s;
512 |         -webkit-transition-timing-function: ease-out; /* Safari */
513 |         transition-timing-function: ease-out;
514 |         z-index: 2;
515 |         box-shadow: 5px 0px 5px 0px rgb(210,210,210);
516 |     }
517 | 
518 |     nav.toc.show {
519 |         left: 0;
520 |     }
521 | 
522 |     article {
523 |         margin-left: 0;
524 |         padding: 3em 0.9em 0 0.9em; /* top right bottom left */
525 |         overflow-wrap: break-word;
526 |     }
527 | 
528 |     article > header {
529 |         position: fixed;
530 |         left: 0;
531 |         z-index: 1;
532 |     }
533 | 
534 |     article > header nav, hr {
535 |         display: none;
536 |     }
537 | 
538 |     article > header div#topbar {
539 |         display: block; /* is mobile */
540 |         position: fixed;
541 |         width: 100%;
542 |         height: 1.5em;
543 |         padding-top: 1em;
544 |         padding-bottom: 1em;
545 |         background-color: #fcfcfc;
546 |         box-shadow: 0 1px 3px rgba(0,0,0,.26);
547 |         top: 0;
548 |         -webkit-transition-property: top; /* Safari */
549 |         -webkit-transition-duration: 0.3s; /* Safari */
550 |         transition-property: top;
551 |         transition-duration: 0.3s;
552 |     }
553 | 
554 |     article > header div#topbar.headroom--unpinned.headroom--not-top.headroom--not-bottom {
555 |         top: -4em;
556 |         -webkit-transition-property: top; /* Safari */
557 |         -webkit-transition-duration: 0.7s; /* Safari */
558 |         transition-property: top;
559 |         transition-duration: 0.7s;
560 |     }
561 | 
562 |     article > header div#topbar span {
563 |         width: 80%;
564 |         height: 1.5em;
565 |         margin-top: -0.1em;
566 |         margin-left: 0.9em;
567 |         font-size: 1.2em;
568 |         overflow: hidden;
569 |     }
570 | 
571 |     article > header div#topbar a.fa-bars {
572 |         float: right;
573 |         padding: 0.6em;
574 |         margin-top: -0.6em;
575 |         margin-right: 0.3em;
576 |         font-size: 1.5em;
577 |     }
578 | 
579 |     article > header div#topbar a.fa-bars:visited {
580 |         color: #3091d1;
581 |     }
582 | 
583 |     article table {
584 |         overflow-x: auto;
585 |         display: block;
586 |     }
587 | 
588 |     article div.MathJax_Display {
589 |         overflow: scroll;
590 |     }
591 | 
592 |     article span.MathJax {
593 |         overflow: hidden;
594 |     }
595 | }
596 | 
597 | @media only screen and (max-width: 320px) {
598 |     body {
599 |         font-size: 15px;
600 |     }
601 | }
602 | 


--------------------------------------------------------------------------------
/Chapter11/IssueReporter/docs/build/assets/documenter.js:
--------------------------------------------------------------------------------
  1 | /*
  2 |  * Part of Documenter.jl
  3 |  *     https://github.com/JuliaDocs/Documenter.jl
  4 |  *
  5 |  * License: MIT
  6 |  */
  7 | 
  8 | requirejs.config({
  9 |     paths: {
 10 |         'jquery': 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min',
 11 |         'jqueryui': 'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min',
 12 |         'headroom': 'https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.3/headroom.min',
 13 |         'mathjax': 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML',
 14 |         'highlight': 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min',
 15 |         'highlight-julia': 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/julia.min',
 16 |         'highlight-julia-repl': 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/julia-repl.min',
 17 |     },
 18 |     shim: {
 19 |         'mathjax' : {
 20 |             exports: "MathJax"
 21 |         },
 22 |         'highlight-julia': ['highlight'],
 23 |         'highlight-julia-repl': ['highlight'],
 24 |     }
 25 | });
 26 | 
 27 | // Load MathJax
 28 | require(['mathjax'], function(MathJax) {
 29 |     MathJax.Hub.Config({
 30 |       "tex2jax": {
 31 |         inlineMath: [['$','$'], ['\\(','\\)']],
 32 |         processEscapes: true
 33 |       }
 34 |     });
 35 |     MathJax.Hub.Config({
 36 |       config: ["MMLorHTML.js"],
 37 |       jax: [
 38 |         "input/TeX",
 39 |         "output/HTML-CSS",
 40 |         "output/NativeMML"
 41 |       ],
 42 |       extensions: [
 43 |         "MathMenu.js",
 44 |         "MathZoom.js",
 45 |         "TeX/AMSmath.js",
 46 |         "TeX/AMSsymbols.js",
 47 |         "TeX/autobold.js",
 48 |         "TeX/autoload-all.js"
 49 |       ]
 50 |     });
 51 |     MathJax.Hub.Config({
 52 |       TeX: { equationNumbers: { autoNumber: "AMS" } }
 53 |     });
 54 | })
 55 | 
 56 | require(['jquery', 'highlight', 'highlight-julia', 'highlight-julia-repl'], function($, hljs) {
 57 |     $(document).ready(function() {
 58 |         hljs.initHighlighting();
 59 |     })
 60 | 
 61 | })
 62 | 
 63 | // update the version selector with info from the siteinfo.js and ../versions.js files
 64 | require(['jquery'], function($) {
 65 |     $(document).ready(function() {
 66 |         var version_selector = $("#version-selector");
 67 | 
 68 |         // add the current version to the selector based on siteinfo.js, but only if the selector is empty
 69 |         if (typeof DOCUMENTER_CURRENT_VERSION !== 'undefined' && $('#version-selector > option').length == 0) {
 70 |             var option = $("");
 71 |             version_selector.append(option);
 72 |         }
 73 | 
 74 |         if (typeof DOC_VERSIONS !== 'undefined') {
 75 |             var existing_versions = $('#version-selector > option');
 76 |             var existing_versions_texts = existing_versions.map(function(i,x){return x.text});
 77 |             DOC_VERSIONS.forEach(function(each) {
 78 |                 var version_url = documenterBaseURL + "/../" + each;
 79 |                 var existing_id = $.inArray(each, existing_versions_texts);
 80 |                 // if not already in the version selector, add it as a new option,
 81 |                 // otherwise update the old option with the URL and enable it
 82 |                 if (existing_id == -1) {
 83 |                     var option = $("");
 84 |                     version_selector.append(option);
 85 |                 } else {
 86 |                     var option = existing_versions[existing_id];
 87 |                     option.value = version_url;
 88 |                     option.disabled = false;
 89 |                 }
 90 |             });
 91 |         }
 92 | 
 93 |         // only show the version selector if the selector has been populated
 94 |         if ($('#version-selector > option').length > 0) {
 95 |             version_selector.css("visibility", "visible");
 96 |         }
 97 | 
 98 |         // Scroll the navigation bar to the currently selected menu item
 99 |         $("nav.toc > ul").get(0).scrollTop = $(".current").get(0).offsetTop - $("nav.toc > ul").get(0).offsetTop;
100 |     })
101 | 
102 | })
103 | 
104 | // mobile
105 | require(['jquery', 'headroom'], function($, Headroom) {
106 |     $(document).ready(function() {
107 |         var navtoc = $("nav.toc");
108 |         $("nav.toc li.current a.toctext").click(function() {
109 |             navtoc.toggleClass('show');
110 |         });
111 |         $("article > header div#topbar a.fa-bars").click(function(ev) {
112 |             ev.preventDefault();
113 |             navtoc.toggleClass('show');
114 |             if (navtoc.hasClass('show')) {
115 |                 var title = $("article > header div#topbar span").text();
116 |                 $("nav.toc ul li a:contains('" + title + "')").focus();
117 |             }
118 |         });
119 |         $("article#docs").bind('click', function(ev) {
120 |             if ($(ev.target).is('div#topbar a.fa-bars')) {
121 |                 return;
122 |             }
123 |             if (navtoc.hasClass('show')) {
124 |                 navtoc.removeClass('show');
125 |             }
126 |         });
127 |         if ($("article > header div#topbar").css('display') == 'block') {
128 |             var headroom = new Headroom(document.querySelector("article > header div#topbar"), {"tolerance": {"up": 10, "down": 10}});
129 |             headroom.init();
130 |         }
131 |     })
132 | })
133 | 


--------------------------------------------------------------------------------
/Chapter11/IssueReporter/docs/build/assets/search.js:
--------------------------------------------------------------------------------
  1 | /*
  2 |  * Part of Documenter.jl
  3 |  *     https://github.com/JuliaDocs/Documenter.jl
  4 |  *
  5 |  * License: MIT
  6 |  */
  7 | 
  8 | // parseUri 1.2.2
  9 | // (c) Steven Levithan 
 10 | // MIT License
 11 | function parseUri (str) {
 12 | 	var	o   = parseUri.options,
 13 | 		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
 14 | 		uri = {},
 15 | 		i   = 14;
 16 | 
 17 | 	while (i--) uri[o.key[i]] = m[i] || "";
 18 | 
 19 | 	uri[o.q.name] = {};
 20 | 	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
 21 | 		if ($1) uri[o.q.name][$1] = $2;
 22 | 	});
 23 | 
 24 | 	return uri;
 25 | };
 26 | parseUri.options = {
 27 | 	strictMode: false,
 28 | 	key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
 29 | 	q:   {
 30 | 		name:   "queryKey",
 31 | 		parser: /(?:^|&)([^&=]*)=?([^&]*)/g
 32 | 	},
 33 | 	parser: {
 34 | 		strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
 35 | 		loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
 36 | 	}
 37 | };
 38 | 
 39 | requirejs.config({
 40 |     paths: {
 41 |         'jquery': 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min',
 42 |         'lunr': 'https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.1/lunr.min',
 43 |         'lodash': 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min',
 44 |     }
 45 | });
 46 | 
 47 | var currentScript = document.currentScript;
 48 | 
 49 | require(["jquery", "lunr", "lodash"], function($, lunr, _) {
 50 |     $("#search-form").submit(function(e) {
 51 |         e.preventDefault()
 52 |     })
 53 | 
 54 |     // list below is the lunr 2.1.3 list minus the intersect with names(Base)
 55 |     // (all, any, get, in, is, which) and (do, else, for, let, where, while, with)
 56 |     // ideally we'd just filter the original list but it's not available as a variable
 57 |     lunr.stopWordFilter = lunr.generateStopWordFilter([
 58 |         'a',
 59 |         'able',
 60 |         'about',
 61 |         'across',
 62 |         'after',
 63 |         'almost',
 64 |         'also',
 65 |         'am',
 66 |         'among',
 67 |         'an',
 68 |         'and',
 69 |         'are',
 70 |         'as',
 71 |         'at',
 72 |         'be',
 73 |         'because',
 74 |         'been',
 75 |         'but',
 76 |         'by',
 77 |         'can',
 78 |         'cannot',
 79 |         'could',
 80 |         'dear',
 81 |         'did',
 82 |         'does',
 83 |         'either',
 84 |         'ever',
 85 |         'every',
 86 |         'from',
 87 |         'got',
 88 |         'had',
 89 |         'has',
 90 |         'have',
 91 |         'he',
 92 |         'her',
 93 |         'hers',
 94 |         'him',
 95 |         'his',
 96 |         'how',
 97 |         'however',
 98 |         'i',
 99 |         'if',
100 |         'into',
101 |         'it',
102 |         'its',
103 |         'just',
104 |         'least',
105 |         'like',
106 |         'likely',
107 |         'may',
108 |         'me',
109 |         'might',
110 |         'most',
111 |         'must',
112 |         'my',
113 |         'neither',
114 |         'no',
115 |         'nor',
116 |         'not',
117 |         'of',
118 |         'off',
119 |         'often',
120 |         'on',
121 |         'only',
122 |         'or',
123 |         'other',
124 |         'our',
125 |         'own',
126 |         'rather',
127 |         'said',
128 |         'say',
129 |         'says',
130 |         'she',
131 |         'should',
132 |         'since',
133 |         'so',
134 |         'some',
135 |         'than',
136 |         'that',
137 |         'the',
138 |         'their',
139 |         'them',
140 |         'then',
141 |         'there',
142 |         'these',
143 |         'they',
144 |         'this',
145 |         'tis',
146 |         'to',
147 |         'too',
148 |         'twas',
149 |         'us',
150 |         'wants',
151 |         'was',
152 |         'we',
153 |         'were',
154 |         'what',
155 |         'when',
156 |         'who',
157 |         'whom',
158 |         'why',
159 |         'will',
160 |         'would',
161 |         'yet',
162 |         'you',
163 |         'your'
164 |         ])
165 | 
166 |     // add . as a separator, because otherwise "title": "Documenter.Anchors.add!"
167 |     // would not find anything if searching for "add!", only for the entire qualification
168 |     lunr.tokenizer.separator = /[\s\-\.]+/
169 | 
170 |     // custom trimmer that doesn't strip @ and !, which are used in julia macro and function names
171 |     lunr.trimmer = function (token) {
172 |         return token.update(function (s) {
173 |             return s.replace(/^[^a-zA-Z0-9@!]+/, '').replace(/[^a-zA-Z0-9@!]+$/, '')
174 |         })
175 |     }
176 | 
177 |     lunr.Pipeline.registerFunction(lunr.stopWordFilter, 'juliaStopWordFilter')
178 |     lunr.Pipeline.registerFunction(lunr.trimmer, 'juliaTrimmer')
179 | 
180 |     var index = lunr(function () {
181 |         this.ref('location')
182 |         this.field('title')
183 |         this.field('text')
184 |         documenterSearchIndex['docs'].forEach(function(e) {
185 |             this.add(e)
186 |         }, this)
187 |     })
188 |     var store = {}
189 | 
190 |     documenterSearchIndex['docs'].forEach(function(e) {
191 |         store[e.location] = {title: e.title, category: e.category}
192 |     })
193 | 
194 |     $(function(){
195 |         function update_search(querystring) {
196 |             tokens = lunr.tokenizer(querystring)
197 |             results = index.query(function (q) {
198 |                 tokens.forEach(function (t) {
199 |                     q.term(t.toString(), {
200 |                         fields: ["title"],
201 |                         boost: 100,
202 |                         usePipeline: false,
203 |                         editDistance: 0,
204 |                         wildcard: lunr.Query.wildcard.NONE
205 |                     })
206 |                     q.term(t.toString(), {
207 |                         fields: ["title"],
208 |                         boost: 10,
209 |                         usePipeline: false,
210 |                         editDistance: 2,
211 |                         wildcard: lunr.Query.wildcard.NONE
212 |                     })
213 |                     q.term(t.toString(), {
214 |                         fields: ["text"],
215 |                         boost: 1,
216 |                         usePipeline: true,
217 |                         editDistance: 0,
218 |                         wildcard: lunr.Query.wildcard.NONE
219 |                     })
220 |                 })
221 |             })
222 |             $('#search-info').text("Number of results: " + results.length)
223 |             $('#search-results').empty()
224 |             results.forEach(function(result) {
225 |                 data = store[result.ref]
226 |                 link = $('')
227 |                 link.text(data.title)
228 |                 link.attr('href', documenterBaseURL+'/'+result.ref)
229 |                 cat = $('('+data.category+')')
230 |                 li = $('
  • ').append(link).append(" ").append(cat) 231 | $('#search-results').append(li) 232 | }) 233 | } 234 | 235 | function update_search_box() { 236 | querystring = $('#search-query').val() 237 | update_search(querystring) 238 | } 239 | 240 | $('#search-query').keyup(_.debounce(update_search_box, 250)) 241 | $('#search-query').change(update_search_box) 242 | 243 | search_query_uri = parseUri(window.location).queryKey["q"] 244 | if(search_query_uri !== undefined) { 245 | search_query = decodeURIComponent(search_query_uri.replace(/\+/g, '%20')) 246 | $("#search-query").val(search_query) 247 | } 248 | update_search_box(); 249 | }) 250 | }) 251 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/docs/build/index.html: -------------------------------------------------------------------------------- 1 | 2 | IssueReporter.jl Documentation · IssueReporter Documentation

    IssueReporter.jl Documentation

    IssueReporter.jl Documentation

    Functions

    packageuri(pkgname)
     3 | 

    Takes the name of a registered Julia package and returns the associated repo git URL.

    Examples

    julia> IssueReporter.packageuri("IssueReporter")
     4 | "git://github.com/essenciary/IssueReporter.jl.git"
    tokenisdefined()
     5 | 

    Checks if the required GitHub authentication token is defined.

    token()
     6 | 

    Returns the configured GitHub authentication token, if defined – or throws an error otherwise.

    githubauth()
     7 | 

    Performs GitHub authentication and returns the OAuth2 object, required by further GitHub API calls.

    repoid(package_name)
     8 | 

    Converts a registered Julia package name to the corresponding GitHub "username/repo_name" string.

    Examples

    julia> IssueReporter.repoid("IssueReporter")
     9 | "essenciary/IssueReporter.jl"
    report(package_name, title, body)
    10 | 

    Creates a new GitHub issue with the title title and the content body onto the repo corresponding to the registered package called pack-age_name.

    Index


    11 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/docs/build/search/index.html: -------------------------------------------------------------------------------- 1 | 2 | Search · IssueReporter Documentation

    Search

    Search

    Number of results: loading...

      3 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/docs/build/search_index.js: -------------------------------------------------------------------------------- 1 | var documenterSearchIndex = {"docs": [ 2 | 3 | { 4 | "location": "#", 5 | "page": "IssueReporter.jl Documentation", 6 | "title": "IssueReporter.jl Documentation", 7 | "category": "page", 8 | "text": "" 9 | }, 10 | 11 | { 12 | "location": "#IssueReporter.jl-Documentation-1", 13 | "page": "IssueReporter.jl Documentation", 14 | "title": "IssueReporter.jl Documentation", 15 | "category": "section", 16 | "text": "CurrentModule = IssueReporter" 17 | }, 18 | 19 | { 20 | "location": "#IssueReporter.packageuri-Tuple{String}", 21 | "page": "IssueReporter.jl Documentation", 22 | "title": "IssueReporter.packageuri", 23 | "category": "method", 24 | "text": "packageuri(pkgname)\n\n\nTakes the name of a registered Julia package and returns the associated repo git URL.\n\nExamples\n\njulia> IssueReporter.packageuri(\"IssueReporter\")\n\"git://github.com/essenciary/IssueReporter.jl.git\"\n\n\n\n\n\n" 25 | }, 26 | 27 | { 28 | "location": "#IssueReporter.tokenisdefined-Tuple{}", 29 | "page": "IssueReporter.jl Documentation", 30 | "title": "IssueReporter.tokenisdefined", 31 | "category": "method", 32 | "text": "tokenisdefined()\n\n\nChecks if the required GitHub authentication token is defined.\n\n\n\n\n\n" 33 | }, 34 | 35 | { 36 | "location": "#IssueReporter.token-Tuple{}", 37 | "page": "IssueReporter.jl Documentation", 38 | "title": "IssueReporter.token", 39 | "category": "method", 40 | "text": "token()\n\n\nReturns the configured GitHub authentication token, if defined – or throws an error otherwise.\n\n\n\n\n\n" 41 | }, 42 | 43 | { 44 | "location": "#IssueReporter.githubauth-Tuple{}", 45 | "page": "IssueReporter.jl Documentation", 46 | "title": "IssueReporter.githubauth", 47 | "category": "method", 48 | "text": "githubauth()\n\n\nPerforms GitHub authentication and returns the OAuth2 object, required by further GitHub API calls.\n\n\n\n\n\n" 49 | }, 50 | 51 | { 52 | "location": "#IssueReporter.repoid-Tuple{String}", 53 | "page": "IssueReporter.jl Documentation", 54 | "title": "IssueReporter.repoid", 55 | "category": "method", 56 | "text": "repoid(package_name)\n\n\nConverts a registered Julia package name to the corresponding GitHub \"username/repo_name\" string.\n\nExamples\n\njulia> IssueReporter.repoid(\"IssueReporter\")\n\"essenciary/IssueReporter.jl\"\n\n\n\n\n\n" 57 | }, 58 | 59 | { 60 | "location": "#IssueReporter.report-Tuple{String,String,String}", 61 | "page": "IssueReporter.jl Documentation", 62 | "title": "IssueReporter.report", 63 | "category": "method", 64 | "text": "report(package_name, title, body)\n\n\nCreates a new GitHub issue with the title title and the content body onto the repo corresponding to the registered package called pack-age_name.\n\n\n\n\n\n" 65 | }, 66 | 67 | { 68 | "location": "#Functions-1", 69 | "page": "IssueReporter.jl Documentation", 70 | "title": "Functions", 71 | "category": "section", 72 | "text": "packageuri(pkgname::String)\ntokenisdefined()\ntoken()\ngithubauth()\nrepoid(package_name::String)\nreport(package_name::String, title::String, body::String)" 73 | }, 74 | 75 | { 76 | "location": "#Index-1", 77 | "page": "IssueReporter.jl Documentation", 78 | "title": "Index", 79 | "category": "section", 80 | "text": "" 81 | }, 82 | 83 | ]} 84 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/docs/make.jl: -------------------------------------------------------------------------------- 1 | using Pkg 2 | pkg"activate .." 3 | push!(LOAD_PATH,"../src/") 4 | using Documenter, IssueReporter 5 | 6 | makedocs(sitename = "IssueReporter Documentation") 7 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/docs/src/index.md: -------------------------------------------------------------------------------- 1 | # IssueReporter.jl Documentation 2 | 3 | ```@meta 4 | CurrentModule = IssueReporter 5 | ``` 6 | 7 | ```@contents 8 | ``` 9 | 10 | ## Functions 11 | 12 | ```@docs 13 | packageuri(pkgname::String) 14 | tokenisdefined() 15 | token() 16 | githubauth() 17 | repoid(package_name::String) 18 | report(package_name::String, title::String, body::String) 19 | ``` 20 | 21 | ## Index 22 | 23 | ```@index 24 | ``` 25 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/src/IssueReporter.jl: -------------------------------------------------------------------------------- 1 | module IssueReporter 2 | 3 | using Pkg, Pkg.TOML, GitHub, URIParser, Documenter, DocStringExtensions 4 | 5 | function generalregistrypath() :: String 6 | for i in DEPOT_PATH 7 | if isdir(joinpath(i, "registries", "General")) 8 | return joinpath(i, "registries", "General") 9 | end 10 | end 11 | 12 | "" 13 | end 14 | 15 | function generalregistry() :: Vector{Dict{String,Any}} 16 | if ! isempty(generalregistrypath()) 17 | TOML.parsefile(joinpath(generalregistrypath(), "Registry.toml"))["packages"] |> values |> collect 18 | else 19 | Dict{String,Any}[] 20 | end 21 | end 22 | 23 | function searchregistry(pkgname::String) :: Dict{String,Any} 24 | for item in generalregistry() 25 | item["name"] == pkgname && return item 26 | end 27 | 28 | Dict{String,Any}() 29 | end 30 | 31 | """ 32 | $(SIGNATURES) 33 | 34 | Takes the name of a registered Julia package and returns the associated repo git URL. 35 | 36 | Examples 37 | ```jldoctest 38 | julia> IssueReporter.packageuri("IssueReporter") 39 | "git://github.com/essenciary/IssueReporter.jl.git" 40 | ``` 41 | """ 42 | function packageuri(pkgname::String) :: String 43 | pkg = searchregistry(pkgname) 44 | isempty(pkg) && return "" 45 | get!(TOML.parsefile(joinpath(generalregistrypath(), pkg["path"], "Package.toml")), "repo", "") 46 | end 47 | 48 | 49 | """ 50 | $(SIGNATURES) 51 | 52 | Checks if the required GitHub authentication token is defined. 53 | """ 54 | function tokenisdefined() :: Bool 55 | if ! haskey(ENV, "GITHUB_ACCESS_TOKEN") 56 | secrets_path = joinpath(@__DIR__, "secrets.jl") 57 | isfile(secrets_path) && include(secrets_path) 58 | haskey(ENV, "GITHUB_ACCESS_TOKEN") || return false 59 | end 60 | 61 | true 62 | end 63 | 64 | 65 | """ 66 | $(SIGNATURES) 67 | 68 | Returns the configured GitHub authentication token, if defined -- or throws an error otherwise. 69 | """ 70 | function token() :: String 71 | tokenisdefined() && return ENV["GITHUB_ACCESS_TOKEN"] 72 | error("""ENV["GITHUB_ACCESS_TOKEN"] is not set -- please make sure it's passed as a command line argument or defined in the `secrets.jl` file.""") 73 | end 74 | 75 | 76 | """ 77 | $(SIGNATURES) 78 | 79 | Performs GitHub authentication and returns the OAuth2 object, required by further GitHub API calls. 80 | """ 81 | function githubauth() 82 | token() |> GitHub.authenticate 83 | end 84 | 85 | 86 | """ 87 | $(SIGNATURES) 88 | 89 | Converts a registered Julia package name to the corresponding GitHub "username/repo_name" string. 90 | 91 | Examples 92 | ```jldoctest 93 | julia> IssueReporter.repoid("IssueReporter") 94 | "essenciary/IssueReporter.jl" 95 | ``` 96 | """ 97 | function repoid(package_name::String) 98 | pkg_url = packageuri(package_name) |> URIParser.parse_url 99 | repo_info = endswith(pkg_url.path, ".git") ? replace(pkg_url.path, r".git$"=>"") : pkg_url.path 100 | 101 | repo_info[2:end] 102 | end 103 | 104 | 105 | """ 106 | $(SIGNATURES) 107 | 108 | Creates a new GitHub issue with the title `title` and the content `body` onto the repo corresponding to the registered package called `pack-age_name`. 109 | """ 110 | function report(package_name::String, title::String, body::String) 111 | # GitHub.create_issue(repoid(package_name), auth = githubauth(), params = Dict(:title => title, :body => body)) 112 | GitHub.create_issue("essenciary/julia-by-example-test-repo", auth = github_auth(), params = Dict(:title => title, :body => body)) 113 | end 114 | 115 | end # module 116 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/src/secrets.jl--sample.jl: -------------------------------------------------------------------------------- 1 | ENV["GITHUB_ACCESS_TOKEN"] = "YOUR GITHUB TOKEN HERE" 2 | -------------------------------------------------------------------------------- /Chapter11/IssueReporter/test/runtests.jl: -------------------------------------------------------------------------------- 1 | using IssueReporter 2 | using Test, URIParser, GitHub 3 | 4 | @testset "Interacting with the registry" begin 5 | @testset "The General registry is accessible" begin 6 | @test IssueReporter.generalregistrypath() |> Base.Filesystem.isdir 7 | end 8 | end 9 | 10 | @testset "Basic features" begin 11 | @testset "Looking up an existing package returns a proper repo URI" begin 12 | @test IssueReporter.packageuri("DataFrames") |> URIParser.isvalid 13 | end 14 | end 15 | 16 | @testset "GitHub integration" begin 17 | # @testset "An undefined token should return false" begin 18 | # @test ! IssueReporter.tokenisdefined() 19 | # end 20 | # 21 | # @testset "Attempting to access a token that is not set will error" begin 22 | # @test_throws ErrorException IssueReporter.token() 23 | # end 24 | 25 | # setup a mock token 26 | ENV["GITHUB_ACCESS_TOKEN"] = "1234" 27 | 28 | @testset "Token is defined" begin 29 | @test IssueReporter.tokenisdefined() 30 | end 31 | 32 | @testset "A valid token is a non empty string and has the set value" begin 33 | token = IssueReporter.token() 34 | @test isa(token, String) && ! isempty(token) 35 | @test token == "1234" 36 | end 37 | end 38 | 39 | @testset "Adding GitHub issues" begin 40 | delete!(ENV, "GITHUB_ACCESS_TOKEN") 41 | 42 | @testset "Successful authentication should return a GitHub.OAuth2 in-stance" begin 43 | @test isa(IssueReporter.githubauth(), GitHub.OAuth2) 44 | end 45 | @testset "Converting package name to GitHub id" begin 46 | @test IssueReporter.repoid("IssueReporter") == "essenciary/IssueReporter.jl" 47 | end 48 | @testset "Submitting an issue should result in a GitHub.Issue object" begin 49 | @test isa(IssueReporter.report("IssueReporter", "I found a bug", "Here is how you can reproduce the problem: ..."), GitHub.Issue) 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /Chapter11/Manifest.toml: -------------------------------------------------------------------------------- 1 | [[Base64]] 2 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 3 | 4 | [[BenchmarkTools]] 5 | deps = ["JSON", "Printf", "Statistics", "Test"] 6 | git-tree-sha1 = "e686f1754227e4748259f400839b83a1e8773e02" 7 | uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" 8 | version = "0.4.1" 9 | 10 | [[BinaryProvider]] 11 | deps = ["Libdl", "Pkg", "SHA", "Test"] 12 | git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" 13 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 14 | version = "0.5.3" 15 | 16 | [[Cassette]] 17 | deps = ["InteractiveUtils", "LinearAlgebra", "Test"] 18 | git-tree-sha1 = "dac71009ded2090e014098c566cfae447cfd686b" 19 | uuid = "7057c7e9-c182-5462-911a-8362d720325c" 20 | version = "0.1.4" 21 | 22 | [[Compat]] 23 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 24 | git-tree-sha1 = "ec61a16eed883ad0cfa002d7489b3ce6d039bb9a" 25 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 26 | version = "1.4.0" 27 | 28 | [[Conda]] 29 | deps = ["Compat", "JSON", "VersionParsing"] 30 | git-tree-sha1 = "fb86fe40cb5b35990e368709bfdc1b46dbb99dac" 31 | uuid = "8f4d0f93-b110-5947-807f-2305c1781a2d" 32 | version = "1.1.1" 33 | 34 | [[Dates]] 35 | deps = ["Printf"] 36 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 37 | 38 | [[DelimitedFiles]] 39 | deps = ["Mmap"] 40 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 41 | 42 | [[Distributed]] 43 | deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] 44 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 45 | 46 | [[DocStringExtensions]] 47 | deps = ["LibGit2", "Markdown", "Pkg", "Test"] 48 | git-tree-sha1 = "1df01539a1c952cef21f2d2d1c092c2bcf0177d7" 49 | uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" 50 | version = "0.6.0" 51 | 52 | [[Documenter]] 53 | deps = ["Base64", "DocStringExtensions", "InteractiveUtils", "LibGit2", "Logging", "Markdown", "Pkg", "REPL", "Random", "Test", "Unicode"] 54 | git-tree-sha1 = "a6db1c69925cdc53aafb38caec4446be26e0c617" 55 | uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4" 56 | version = "0.21.0" 57 | 58 | [[FileWatching]] 59 | uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" 60 | 61 | [[GitHub]] 62 | deps = ["Base64", "Compat", "Dates", "HTTP", "JSON", "MbedTLS", "Test"] 63 | git-tree-sha1 = "b988ce46c9b682acfeed4801cbaafa1ef954ad31" 64 | uuid = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26" 65 | version = "5.0.2" 66 | 67 | [[HTTP]] 68 | deps = ["Base64", "Dates", "Distributed", "IniFile", "MbedTLS", "Sockets", "Test"] 69 | git-tree-sha1 = "b881f69331e85642be315c63d05ed65d6fc8a05b" 70 | uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" 71 | version = "0.7.1" 72 | 73 | [[IJulia]] 74 | deps = ["Base64", "Compat", "Conda", "Dates", "InteractiveUtils", "JSON", "Markdown", "MbedTLS", "Pkg", "Printf", "REPL", "Random", "SoftGlobalScope", "Test", "UUIDs", "ZMQ"] 75 | git-tree-sha1 = "38d1ce0fbbefcb67f5ab46f1093cbce0335092e0" 76 | uuid = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 77 | version = "1.14.1" 78 | 79 | [[IniFile]] 80 | deps = ["Test"] 81 | git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" 82 | uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" 83 | version = "0.5.0" 84 | 85 | [[InteractiveUtils]] 86 | deps = ["LinearAlgebra", "Markdown"] 87 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 88 | 89 | [[JSON]] 90 | deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] 91 | git-tree-sha1 = "1f7a25b53ec67f5e9422f1f551ee216503f4a0fa" 92 | uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" 93 | version = "0.20.0" 94 | 95 | [[LibGit2]] 96 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 97 | 98 | [[Libdl]] 99 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 100 | 101 | [[LinearAlgebra]] 102 | deps = ["Libdl"] 103 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 104 | 105 | [[Logging]] 106 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 107 | 108 | [[MacroTools]] 109 | deps = ["Compat"] 110 | git-tree-sha1 = "c443e1c8d58a4e9f61b708ad0a88286c7042145b" 111 | uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" 112 | version = "0.4.4" 113 | 114 | [[Markdown]] 115 | deps = ["Base64"] 116 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 117 | 118 | [[MbedTLS]] 119 | deps = ["BinaryProvider", "Dates", "Libdl", "Random", "Sockets", "Test"] 120 | git-tree-sha1 = "c93a87da4081a3de781f34e0540175795a2ce83d" 121 | uuid = "739be429-bea8-5141-9913-cc70e7f3736d" 122 | version = "0.6.6" 123 | 124 | [[Mmap]] 125 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 126 | 127 | [[Pkg]] 128 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 129 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 130 | 131 | [[Printf]] 132 | deps = ["Unicode"] 133 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 134 | 135 | [[REPL]] 136 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 137 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 138 | 139 | [[Random]] 140 | deps = ["Serialization"] 141 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 142 | 143 | [[SHA]] 144 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 145 | 146 | [[Serialization]] 147 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 148 | 149 | [[SharedArrays]] 150 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 151 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 152 | 153 | [[Sockets]] 154 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 155 | 156 | [[SoftGlobalScope]] 157 | deps = ["Test"] 158 | git-tree-sha1 = "97f6dfcf612b9a7260fde44170725d9ea34b1431" 159 | uuid = "b85f4697-e234-5449-a836-ec8e2f98b302" 160 | version = "1.0.7" 161 | 162 | [[SparseArrays]] 163 | deps = ["LinearAlgebra", "Random"] 164 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 165 | 166 | [[Statistics]] 167 | deps = ["LinearAlgebra", "SparseArrays"] 168 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 169 | 170 | [[Test]] 171 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 172 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 173 | 174 | [[Traceur]] 175 | deps = ["Cassette", "InteractiveUtils", "Logging", "MacroTools", "Test"] 176 | git-tree-sha1 = "d46ea4a2575f896e90c8a4b52ce2841e6db7d059" 177 | uuid = "37b6cedf-1f77-55f8-9503-c64b63398394" 178 | version = "0.2.0" 179 | 180 | [[URIParser]] 181 | deps = ["Test", "Unicode"] 182 | git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" 183 | uuid = "30578b45-9adc-5946-b283-645ec420af67" 184 | version = "0.4.0" 185 | 186 | [[UUIDs]] 187 | deps = ["Random"] 188 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 189 | 190 | [[Unicode]] 191 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 192 | 193 | [[VersionParsing]] 194 | deps = ["Compat"] 195 | git-tree-sha1 = "c9d5aa108588b978bd859554660c8a5c4f2f7669" 196 | uuid = "81def892-9a0e-5fdd-b105-ffc91e053289" 197 | version = "1.1.3" 198 | 199 | [[ZMQ]] 200 | deps = ["BinaryProvider", "FileWatching", "Libdl", "Sockets", "Test"] 201 | git-tree-sha1 = "34e7ac2d1d59d19d0e86bde99f1f02262bfa1613" 202 | uuid = "c2297ded-f4af-51ae-bb23-16f91089e4e1" 203 | version = "1.0.0" 204 | -------------------------------------------------------------------------------- /Chapter11/Project.toml: -------------------------------------------------------------------------------- 1 | [deps] 2 | BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" 3 | DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" 4 | Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" 5 | GitHub = "bc5e4493-9b4d-5f90-b8aa-2b2bcaad7a26" 6 | IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a" 7 | Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 8 | Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 9 | Traceur = "37b6cedf-1f77-55f8-9503-c64b63398394" 10 | URIParser = "30578b45-9adc-5946-b283-645ec420af67" 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Packt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # Julia Programming Projects 5 | 6 | Julia Programming Projects 7 | 8 | This is the code repository for [Julia Programming Projects](https://www.packtpub.com/big-data-and-business-intelligence/julia-programming-projects?utm_source=github&utm_medium=repository&utm_campaign=9781788292740 ), published by Packt. 9 | 10 | **Learn Julia 1.x by building apps for data analysis, visualization, machine learning, and the web ** 11 | 12 | ## What is this book about? 13 | Julia is a new programming language that offers a unique combination of performance and productivity. Its powerful features, friendly syntax, and speed are attracting a growing number of adopters from Python, R, and Matlab, effectively raising the bar for modern general and scientific computing. 14 | 15 | This book covers the following exciting features: 16 | * Leverage Julia's strengths, its top packages, and main IDE options 17 | * Analyze and manipulate datasets using Julia and DataFrames 18 | * Write complex code while building real-life Julia applications 19 | * Develop and run a web app using Julia and the HTTP package 20 | * Build a recommender system using supervised machine learning 21 | * Perform exploratory data analysis 22 | * Apply unsupervised machine learning algorithms 23 | * Perform time series data analysis, visualization, and forecasting 24 | 25 | If you feel this book is for you, get your [copy](https://www.amazon.com/dp/178829274X) today! 26 | 27 | https://www.packtpub.com/ 29 | 30 | ## Instructions and Navigations 31 | All of the code is organized into folders. For example, Chapter02. 32 | 33 | The code will look like the following: 34 | ``` 35 | function articleinfo(content) 36 | dom = articledom(content) 37 | (extractcontent(dom.root), extractlinks(dom.root), extracttitle(dom.root), extractimage(dom.root)) 38 | end 39 | ``` 40 | 41 | **Following is what you need for this book:** 42 | Data scientists, statisticians, business analysts, and developers who are interested in learning how to use Julia to crunch numbers, analyze data and build apps will find this book useful. A basic knowledge of programming is assumed. 43 | 44 | With the following software and hardware list you can run all code files present in the book (Chapter 1-11). 45 | ### Software and Hardware List 46 | | Chapter | Software required | OS required | 47 | | -------- | ------------------------------------ | -----------------------------------| 48 | | 1-11 | Julia | Windows, Mac OS X, and Linux (Any) | 49 | 50 | 51 | We also provide a PDF file that has color images of the screenshots/diagrams used in this book. [Click here to download it](https://www.packtpub.com/sites/default/files/downloads/9781788292740_ColorImages.pdf?). 52 | 53 | ### Related products 54 | * Julia 1.0 Programming Cookbook [[Packt]](https://www.packtpub.com/application-development/julia-10-programming-cookbook?utm_source=github&utm_medium=repository&utm_campaign=9781788998369 ) [[Amazon]](https://www.amazon.com/dp/1788998367) 55 | 56 | * Julia 1.0 Programming - Second Edition [[Packt]](https://www.packtpub.com/application-development/julia-10-programming-second-edition?utm_source=github&utm_medium=repository&utm_campaign=9781788999090 ) [[Amazon]](https://www.amazon.com/dp/1788999096) 57 | 58 | ## Get to Know the Author 59 | **Adrian Salceanu** 60 | has been a professional software developer for over 15 years. For the last 10, he's been leading agile teams in developing real-time, data-intensive web and mobile products. Adrian is a public speaker and an enthusiastic contributor to the open source community, focusing on high-performance web development. He's the organizer of the Barcelona Julia Users group and the creator of Genie, a high-performance, highly productive Julia web framework. Adrian has a Master's degree in computing and a postgraduate degree in advanced computer science. 61 | 62 | ### Suggestions and Feedback 63 | [Click here](https://docs.google.com/forms/d/e/1FAIpQLSdy7dATC6QmEL81FIUuymZ0Wy9vH1jHkvpY57OiMeKGqib_Ow/viewform) if you have any feedback or suggestions. 64 | 65 | 66 | ### Download a free PDF 67 | 68 | If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
      Simply click on the link to claim your free PDF.
      69 |

      https://packt.link/free-ebook/9781788292740

      --------------------------------------------------------------------------------