Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zampino/7b6a2f9ebabac2c3e4359c51bcbb416d to your computer and use it in GitHub Desktop.
Save zampino/7b6a2f9ebabac2c3e4359c51bcbb416d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{"nbformat":4,"nbformat_minor":4,"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"nextjournal":{"nodes-edn":"{\"59b63e29-4d22-4bda-ad15-9dd2bc53e03a\" {:ref-id \"7df2e665-6d1e-4080-8681-acc472ab2a61\", :ref-kind \"output\", :id \"59b63e29-4d22-4bda-ad15-9dd2bc53e03a\", :kind \"reference\"}, \"d5a87d45-6166-4df7-8eaf-dae2534b53df\" {:id \"d5a87d45-6166-4df7-8eaf-dae2534b53df\", :kind \"embed\", :url \"https:\/\/vimeo.com\/31039323\"}, \"09cb1da9-827e-40bc-b801-e4dfd985aa7d\" {:id \"09cb1da9-827e-40bc-b801-e4dfd985aa7d\", :kind \"reference\", :ref-id \"7c318886-4c75-4b29-81ee-eb6e805b4653\"}, \"7d341a00-0d77-4f04-926b-21c770b7c276\" {:content \"echo \\\"some results\\\" >> \/results\/results-file.txt\\nls \/results\", :execution-hash 90796726, :name nil, :output-log-lines {:stdout 2}, :imports [], :language \"bash\", :id \"7d341a00-0d77-4f04-926b-21c770b7c276\", :compute-ref #uuid \"2045b8cb-2270-4ca1-ad6c-2379eb4037b3\", :runtime [:runtime \"7c318886-4c75-4b29-81ee-eb6e805b4653\"], :kind \"code\", :error nil, :exec-duration 1095, :bucket nil}, \"30868604-b483-48d1-925a-56a5fd4c93ed\" {:id \"30868604-b483-48d1-925a-56a5fd4c93ed\", :kind \"embed\", :url \"https:\/\/twitter.com\/usenextjournal\/status\/1019235170157723648\"}, \"d8dcf2b9-d2ca-4eae-8105-efc8f37ce309\" {:runtime\/inherited-environment-variables ({:name \"NEXTJOURNAL_RUNTIME_SERVICE_URL\", :value \"https:\/\/nextjournal.com\/runner\/CGhvbtLix6eRbqxSM4Nstz\/runtime\/4e307b44-52c3-4f79-9f3d-23047859e2fa\"} {:name \"PATH\", :value \"\/opt\/conda\/bin:\/usr\/local\/nvidia\/bin:\/usr\/local\/cuda\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin\"} {:name \"NVIDIA_VISIBLE_DEVICES\", :value \"void\"} {:name \"NVIDIA_DRIVER_CAPABILITIES\", :value \"all\"} {:name \"NEXTJOURNAL_MOUNT_CUDA\", :value \"10.2-cudnn7-devel-ubuntu18.04\"} {:name \"BASH_ENV\", :value \"\/.bash_profile\"} {:name \"LC_ALL\", :value \"en_US.UTF-8\"} {:name \"LANGUAGE\", :value \"en_US.en\"} {:name \"LANG\", :value \"en_US.UTF-8\"}), :output-log-lines nil, :type :nextjournal, :language \"r\", :id \"d8dcf2b9-d2ca-4eae-8105-efc8f37ce309\", :compute-ref #uuid \"1b0148bb-77f0-4012-832a-002b3883ddab\", :kind \"runtime\", :error nil, :environment [:environment {:article\/nextjournal.id #uuid \"5b45e6f7-fe51-488a-b89b-1c8f74dfb387\", :change\/nextjournal.id #uuid \"5df6989b-58ac-4d6b-9ea8-00332febe807\", :node\/id \"4e307b44-52c3-4f79-9f3d-23047859e2fa\"}]}, \"5da51686-4164-44b6-b447-b668a97ae2e0\" {:content \"cat $$ref{{[\\\"~:output\\\",\\\"7d341a00-0d77-4f04-926b-21c770b7c276\\\",\\\"results-file.txt\\\"]}}\", :name \"snowy-king\", :output-log-lines {:stdout 2}, :imports [], :language \"bash\", :id \"5da51686-4164-44b6-b447-b668a97ae2e0\", :compute-ref #uuid \"6bf20536-f285-49e1-9c01-99d1ad7096c9\", :runtime [:runtime \"7c318886-4c75-4b29-81ee-eb6e805b4653\"], :kind \"code\", :error nil, :exec-duration 1089, :bucket nil}, \"99b6f202-eebf-4e6a-8d00-771020586620\" {:id \"99b6f202-eebf-4e6a-8d00-771020586620\", :kind \"embed\", :url \"https:\/\/www.youtube.com\/watch?v=yJDv-zdhzMY\"}, \"6e28804f-84c2-4a14-a294-3a4c7d1d88e3\" {:id \"6e28804f-84c2-4a14-a294-3a4c7d1d88e3\", :kind \"runtime\", :language \"javascript\", :environment [:environment nil], :type :nextjournal}, \"878e9fc4-9993-4e85-82ef-0cb40ec768be\" {:content \"ls \/results\", :output-log-lines {}, :language \"bash\", :id \"878e9fc4-9993-4e85-82ef-0cb40ec768be\", :compute-ref #uuid \"ec6d8662-a149-4471-a88d-2feed10805ec\", :runtime [:runtime \"7c318886-4c75-4b29-81ee-eb6e805b4653\"], :kind \"code\", :error nil, :exec-duration 707, :bucket nil}, \"c8770050-6dd3-4828-8398-76c32e696929\" {:runtime\/inherited-environment-variables ({:name \"CLOJURE_VERSION\", :value \"1.9.0.341\"} {:name \"DEBIAN_FRONTEND\", :value \"noninteractive\"} {:name \"BASH_ENV\", :value \"\/.bash_profile\"} {:name \"LANG\", :value \"en_US.UTF-8\"} {:name \"LANGUAGE\", :value \"en_US.en\"} {:name \"LC_ALL\", :value \"en_US.UTF-8\"} {:name \"PATH\", :value \"\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin\"} {:name \"JAVA_HOME\", :value \"\/docker-java-home\"} {:name \"JAVA_VERSION\", :value \"8u171\"} {:name \"JAVA_DEBIAN_VERSION\", :value \"8u171-b11-1~deb9u1\"} {:name \"CA_CERTIFICATES_JAVA_VERSION\", :value \"20170531+nmu1\"}), :output-log-lines {:stdout 9}, :type :nextjournal, :language \"clojure\", :id \"c8770050-6dd3-4828-8398-76c32e696929\", :compute-ref #uuid \"c312aac5-c058-4e1d-9813-8368f8ac1b4d\", :kind \"runtime\", :error nil, :environment [:environment {:node\/id \"19e3027e-20bc-47c9-8f60-edcdbf613a23\", :article\/nextjournal.id #uuid \"5b45eb52-bad4-413d-9d7f-b2b573a25322\", :change\/nextjournal.id #uuid \"5b45f778-3e8c-4dc6-807a-f83956c63dca\"}]}, \"d0c6ba0e-a7c9-4830-8411-cfce86e5abf3\" {:stdout-collapsed? true, :content \"svg('\/results\/my-plot.png')\\nhist(rnorm(200, 1), breaks=100)\\ndev.off()\", :output-log-lines {:stdout 3}, :language \"r\", :id \"d0c6ba0e-a7c9-4830-8411-cfce86e5abf3\", :compute-ref #uuid \"6d592f3d-67c8-45fb-a304-2a792e425840\", :runtime [:runtime \"d8dcf2b9-d2ca-4eae-8105-efc8f37ce309\"], :kind \"code\", :error nil, :exec-duration 763, :bucket nil}, \"7c318886-4c75-4b29-81ee-eb6e805b4653\" {:runtime\/inherited-environment-variables ({:name \"MPLBACKEND\", :value \"svg\"} {:name \"NVIDIA_VISIBLE_DEVICES\", :value \"void\"} {:name \"NVIDIA_DRIVER_CAPABILITIES\", :value \"all\"} {:name \"PATH\", :value \"\/opt\/conda\/bin:\/usr\/local\/nvidia\/bin:\/usr\/local\/cuda\/bin:\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin\"} {:name \"NEXTJOURNAL_MOUNT_CUDA\", :value \"10.2-cudnn7-devel-ubuntu18.04\"} {:name \"BASH_ENV\", :value \"\/.bash_profile\"} {:name \"LC_ALL\", :value \"en_US.UTF-8\"} {:name \"LANGUAGE\", :value \"en_US.en\"} {:name \"LANG\", :value \"en_US.UTF-8\"}), :name \"\", :output-log-lines {:stdout 9}, :type :nextjournal, :language \"python\", :id \"7c318886-4c75-4b29-81ee-eb6e805b4653\", :compute-ref #uuid \"00691dd5-2a22-424f-a1b6-72b8918b56e7\", :kind \"runtime\", :error nil, :environment [:environment {:article\/nextjournal.id #uuid \"5b45e08b-5b96-413e-84ed-f03b5b65bd66\", :change\/nextjournal.id #uuid \"5df5e18c-0be4-4d8d-b099-6ce55ca12cf4\", :node\/id \"0149f12a-08de-4f3d-9fd3-4b7a665e8624\"}]}, \"f8daae3a-f5f2-4e5c-928e-aedfe49b8b70\" {:stdout-collapsed? nil, :content \"pip freeze\", :execution-hash 30066679, :name nil, :output-log-lines {:stdout 109}, :imports [], :language \"bash\", :id \"f8daae3a-f5f2-4e5c-928e-aedfe49b8b70\", :compute-ref #uuid \"1b0571af-8a1e-415f-8d53-9592945bba41\", :runtime [:runtime \"7c318886-4c75-4b29-81ee-eb6e805b4653\"], :kind \"code\", :error nil, :exec-duration 2493, :bucket nil}, \"f97700e4-e9b0-400a-a0ee-e2552f464414\" {:language \"clojure\", :kind \"code-listing\", :id \"f97700e4-e9b0-400a-a0ee-e2552f464414\", :content \"(->> (read)\\n eval\\n prn\\n (while true))\"}, \"a0271398-c86a-4144-ab4d-21ff7168bb6e\" {:id \"a0271398-c86a-4144-ab4d-21ff7168bb6e\", :kind \"code\", :content \"var size = 1500, x = [], y = [], z = [], i, j;\\n\\nfor (var i = 0; i < size; i++) {\\n\\tx[i] = y[i] = -2 * Math.PI + 4 * Math.PI * i \/ size;\\n z[i] = new Array(size);\\n}\\nfor (var i = 0; i < size; i++) {\\n\\tfor (j = 0; j < size; j++) {\\n\\t\\tvar r2 = x[i] * x[i] + y[j] * y[j];\\n z[i][j] = Math.sin(x[i]) * Math.cos(y[j]) * Math.sin(r2) \/ Math.log(r2+1);\\n \\t}\\n}\\n\\nNextjournal.plot([{ z: z, x: x, y: y, type: 'contour' }]);\", :language \"javascript\", :runtime [:runtime \"6e28804f-84c2-4a14-a294-3a4c7d1d88e3\"], :error nil}, \"c7bf6199-58e9-4068-b297-692cfdcdcd4a\" {:id \"c7bf6199-58e9-4068-b297-692cfdcdcd4a\", :kind \"reference\", :link [:output \"7d341a00-0d77-4f04-926b-21c770b7c276\" \"results-file.txt\"]}, \"23726b74-8e72-42eb-9e23-585bcc097be4\" {:id \"23726b74-8e72-42eb-9e23-585bcc097be4\", :kind \"reference\", :link [:output \"52345bb6-ad59-49f3-835f-cc7b513128d5\" \"global-temperature.csv\"]}, \"6e0e6115-8b5e-4317-b656-5694d00bd538\" {:content \"(require '[clojure.java.io :as io])\\n(with-open [reader (io\/reader $$ref{{[\\\"~:output\\\",\\\"52345bb6-ad59-49f3-835f-cc7b513128d5\\\",\\\"global-temperature.csv\\\"]}})]\\n (char (.read reader)))\", :name nil, :output-log-lines {}, :language \"clojure\", :id \"6e0e6115-8b5e-4317-b656-5694d00bd538\", :compute-ref #uuid \"00bc535c-14d3-433d-8216-424a1de633ef\", :runtime [:runtime \"c8770050-6dd3-4828-8398-76c32e696929\"], :kind \"code\", :error nil, :exec-duration 380, :bucket nil}, \"c4c3a13c-3b14-4351-8fd3-c1a1fca58db0\" {:language \"custom\", :kind \"code-listing\", :id \"c4c3a13c-3b14-4351-8fd3-c1a1fca58db0\", :content \"AddExp = AddExp \\\"+\\\" MulExp -- plus\\n | AddExp \\\"-\\\" MulExp -- minus\\n | MulExp\", :custom-language \"Ohm\"}, \"11fa9e08-9740-464a-baba-a75616a1e5fc\" {:value 32, :name \"temperature\", :kind \"number\", :id \"11fa9e08-9740-464a-baba-a75616a1e5fc\"}, \"bf447f1f-3ec7-4257-b394-86172f9c7b15\" {:ref-id \"7d341a00-0d77-4f04-926b-21c770b7c276\", :ref-kind \"output\", :ref-var \"results-file.txt\", :id \"bf447f1f-3ec7-4257-b394-86172f9c7b15\", :kind \"reference\"}, \"131147ed-aef3-4308-9808-aa2446469316\" {:content \"mtcars\", :output-log-lines {}, :language \"r\", :id \"131147ed-aef3-4308-9808-aa2446469316\", :compute-ref #uuid \"11e4bfbc-cc15-40e0-b7c2-edd37e1ff7e0\", :runtime [:runtime \"d8dcf2b9-d2ca-4eae-8105-efc8f37ce309\"], :kind \"code\", :error nil, :exec-duration 213, :bucket nil}, \"7d4312f8-fdb2-4b0c-8312-47ae3853f095\" {:content \"{:number 1\\n :string \\\"A string\\\"\\n :nested-map {:key-1 1 :key-2 2}\\n :nested-vector [1 2 3 [4 5 6]]}\", :output-log-lines {}, :language \"clojure\", :id \"7d4312f8-fdb2-4b0c-8312-47ae3853f095\", :compute-ref #uuid \"7df9c144-a45b-4eb7-8f43-baf252312206\", :runtime [:runtime \"c8770050-6dd3-4828-8398-76c32e696929\"], :kind \"code\", :error nil, :exec-duration 66, :bucket nil}}","runtime-id":"7c318886-4c75-4b29-81ee-eb6e805b4653","url":"https:\/\/staging.nextjournal.com\/nextjournal\/elements"}},"cells":[{"cell_type":"markdown","metadata":{},"source":["# Elements of a Nextjournal Article\n\n<h2 class=\"pm-node nj-subtitle\">A Comprehensive List of All Available Content Types<\/h2>\n\n<p class=\"pm-node nj-authors\">Philipp Markovics<\/p>\n\n# Paragraphs and Lists\n\nThe paragraph is the simplest Nextjournal node type. Internally, paragraphs use a rich-text editing component for text styles: *italic*, **bold**, `monospaced` text and [links](http:\/\/nextjournal.com).\n\nYou can embed *inline nodes* in paragraphs: mathematical formulas, like $\\omega = 2 \\pi f$, references to a code cell\u2019s result, like [reference](#nextjournal#reference#59b63e29-4d22-4bda-ad15-9dd2bc53e03a)**,** and numbers that can be referenced in code cells, like `temperature = `[32](#nextjournal#number#11fa9e08-9740-464a-baba-a75616a1e5fc)*\u00baC.*\n\n## Lists\n\nLists are restricted to a single level at the moment. Typing `*` followed by a space into an empty paragraph quickly transforms the paragraph into a list:\n\n* A list items\n* followed by another list item\n\n# Sections\n\nSections give structure to an article in a tree-like format. Sections can be nested. The section's nesting level defines its heading size and numbering.\n\n## Nesting Sections\n\nA section\u2019s nesting level can be changed by *promoting* or *demoting* the section via its *action menu.* Hover over a section to expose the \u2022\u2022\u2022 menu button in the gutter. Opening the *action menu* will show a *Promote Heading* or *Demote Heading* action depending on the section\u2019s current nesting level.\n\n### Disabling Section Numbering\n\nTo disable the numerals appearing before section headings, open A*rticle Settings* and deactivate \"Numbered Section Headings\".\n\n# Files and Images\n\nFiles can be uploaded straight to an article. Here is an example of an uploaded CSV file with global temperature data:\n\n## Files\n\n[global-temperature.csv](https:\/\/staging.nextjournal.com\/data\/QmdP19LtDkw97N4Cs6LddgcP4VqmS3WGzcAYCYpMFkf8TR?content-type=text\/csv&node-id=52345bb6-ad59-49f3-835f-cc7b513128d5&filename=global-temperature.csv&node-kind=file)\n\n## Images\n\nIf the uploaded file is an image, including SVGs, it will be rendered inline. If the image size exceeds the article\u2019s default content width, layout controls allow expanding the image width beyond the article boundaries.\n\nImages may be captioned.\n\n### Wide Images\n\n![Anomaly2014.jpg](https:\/\/staging.nextjournal.com\/data\/QmbkR24jTpUVK5onvZ3J78WK13MAniRBmsawvGWEqWzDyL?content-type=image\/jpeg&node-id=7df2e665-6d1e-4080-8681-acc472ab2a61&filename=Anomaly2014.jpg&node-kind=file)\n\n### Standard Width Image\n\n![protools9.png](https:\/\/staging.nextjournal.com\/data\/QmcoVYoNUMLGpkNvPh5ytKRrPMeM2JZm5WGo13oeUvFm8i?content-type=image\/png&node-id=bab00757-2b83-46bb-9309-ef016b773551&filename=protools9.png&node-kind=file)\n\n### Framed Images\n\n![Water.jpg](https:\/\/staging.nextjournal.com\/data\/Qmd79hwKR9xSxQQYsvJj2Zm3SrvjAafw453euv7gqEfDE1?content-type=image\/jpeg&node-id=b2eeb80f-f547-419d-87d4-5389a7542577&filename=Water.jpg&node-kind=file)\n\n# Code Cells\n\nExecutable code cells form the core of the editor. Some cells execute remotely, on the Nextjournal cluster (Bash, Clojure, Python, R and Julia) while others execute in the browser (Javascript and ClojureScript).\n\n## Runtimes and Environments"]},{"cell_type":"raw","source":["nextjournal reference component"],"metadata":{"nextjournal":{"id":"09cb1da9-827e-40bc-b801-e4dfd985aa7d"}}},{"cell_type":"markdown","metadata":{},"source":["When adding the first cell for a particular language, a *runtime* is created along with it and added to the *code panel*. New cells using the same language are appended to the previously existing runtime.\n\nRuntimes provide an isolated computational resource for code cells to run in. For remote execution, code cells that share a runtime share process state and an ephemeral filesystem in the form of a *Docker container*. Browser-based runtimes execute in a *web worker*.\n\nRemote runtimes are templated from an *environment:* a *Docker image* providing initial filesystem state, a language runtime, and preinstalled software packages.\n\nBy default, each new runtime is based on the *[Nextjournal Default]()*[ environment]().\n\n### Bash Cells and Runtimes\n\n*Bash cells* exhibit special behavior. If another language runtime exists, bash cells will be appended to that runtime. This way, you can perform command line work *underneath* the language process, such as installing Python packages or downloading data.\n\n## Referencing Files\n\nAs noted above, files can be uploaded directly to an article. They can be referenced in a code cell or paragraph by typing `Ctrl\/Cmd+E` and selecting *the file you want to reference*.\n\nThis example takes the `global-temperature.csv` file uploaded above, reads it, and returns the first character from the file."]},{"cell_type":"raw","metadata":{"nextjournal":{"id":"6e0e6115-8b5e-4317-b656-5694d00bd538","kind":"code","language":"clojure"}},"source":["(require '[clojure.java.io :as io])\n(with-open [reader (io\/reader ","\"\/.nextjournal\/data-named\/QmdP19LtDkw97N4Cs6LddgcP4VqmS3WGzcAYCYpMFkf8TR\/global-temperature.csv\"",")]\n (char (.read reader)))"]},{"cell_type":"markdown","metadata":{},"source":["## Results\n\nCode cells, by default, display the result of the last expression and *standard output* it generates.\n\nCertain result types, like simple data structures, plots and images, are given special treatment or enhanced by the editor.\n\nCurrently, Nextjournal provides the following *result viewers*:\n\n### Data (the default)\n\nIf the last expression is a data structure, it's rendered as an expandable tree."]},{"cell_type":"raw","metadata":{"nextjournal":{"id":"7d4312f8-fdb2-4b0c-8312-47ae3853f095","kind":"code","language":"clojure"}},"source":["{:number 1\n :string \"A string\"\n :nested-map {:key-1 1 :key-2 2}\n :nested-vector [1 2 3 [4 5 6]]}"]},{"cell_type":"markdown","metadata":{},"source":["### Plotly Results\n\nRemote language runtimes, except Bash, automatically render Plotly graphs generated by the language-specific Plotly package. ClojureScript and Javascript cells can use the [Nextjournal.plot]() function."]},{"cell_type":"raw","metadata":{"nextjournal":{"id":"a0271398-c86a-4144-ab4d-21ff7168bb6e","kind":"code","language":"javascript"}},"source":["var size = 1500, x = [], y = [], z = [], i, j;\n\nfor (var i = 0; i < size; i++) {\n\tx[i] = y[i] = -2 * Math.PI + 4 * Math.PI * i \/ size;\n z[i] = new Array(size);\n}\nfor (var i = 0; i < size; i++) {\n\tfor (j = 0; j < size; j++) {\n\t\tvar r2 = x[i] * x[i] + y[j] * y[j];\n z[i][j] = Math.sin(x[i]) * Math.cos(y[j]) * Math.sin(r2) \/ Math.log(r2+1);\n \t}\n}\n\nNextjournal.plot([{ z: z, x: x, y: y, type: 'contour' }]);"]},{"cell_type":"markdown","metadata":{},"source":["### Image Results\n\nImages generated by cells are displayed automatically, under certain conditions. Here is an example of a R cell that\u2019s generating an image of a plot."]},{"cell_type":"raw","metadata":{"nextjournal":{"id":"d0c6ba0e-a7c9-4830-8411-cfce86e5abf3","kind":"code","language":"r"}},"source":["svg('\/results\/my-plot.png')\nhist(rnorm(200, 1), breaks=100)\ndev.off()"]},{"cell_type":"markdown","metadata":{},"source":["### Table Results\n\nIf the results is a data frame or CSV file, it will render as table that shows the first 10 entries of the result. Here\u2019s a R cell that renders the `mtcars` demo data:"]},{"cell_type":"raw","metadata":{"nextjournal":{"id":"131147ed-aef3-4308-9808-aa2446469316","kind":"code","language":"r"}},"source":["mtcars"]},{"cell_type":"markdown","metadata":{},"source":["### Console Output\n\nProcess *standard output* and *standard error* are streamed to the browser, between the source code and the final result. Cell output can be toggled. This Bash cell lists the installed PyPi Python packages."]},{"cell_type":"code","metadata":{"nextjournal":{"id":"f8daae3a-f5f2-4e5c-928e-aedfe49b8b70","kind":"code","language":"bash"}},"source":["%%sh\n","pip freeze"],"outputs":[],"execution_count":1},{"cell_type":"markdown","metadata":{},"source":["## Working With Results\n\n### Writing Results to the Filesystem\n\nFiles written to a runtime are only accessible from within that runtime.\n\nThe special `\/results` path exists for making a result file referenceable, permanent and downloadable. The cell below writes a file to `\/results` and Nextjournal automatically does the rest:"]},{"cell_type":"code","metadata":{"nextjournal":{"id":"7d341a00-0d77-4f04-926b-21c770b7c276","kind":"code","language":"bash"}},"source":["%%sh\n","echo \"some results\" >> \/results\/results-file.txt\nls \/results"],"outputs":[{"output_type":"display_data","data":{"text\/plain":"some results\n"},"metadata":{}}],"execution_count":1},{"cell_type":"markdown","metadata":{},"source":["### Referencing Results\n\nThe file is now downloadable in the browser and can be referenced from other code cells, or even from another article. All results on the filesystem can be referenced using `Cmd\/Ctrl+E` in a code cell:"]},{"cell_type":"code","metadata":{"nextjournal":{"id":"5da51686-4164-44b6-b447-b668a97ae2e0","kind":"code","language":"bash"}},"source":["%%sh\n","cat ","\"\/.nextjournal\/data-named\/QmbB9B95WE5pKbZENgqYMzGM23xdqQg6CgGGmQ2CnMMidt\/results-file.txt\""],"outputs":[],"execution_count":1},{"cell_type":"markdown","metadata":{},"source":["### Content Addressed Storage\n\nA note on storage. It may surprise you that `results-file.txt` no longer exists in `\/results`:"]},{"cell_type":"code","metadata":{"nextjournal":{"id":"878e9fc4-9993-4e85-82ef-0cb40ec768be","kind":"code","language":"bash"}},"source":["%%sh\n","ls \/results"],"outputs":[],"execution_count":1},{"cell_type":"markdown","metadata":{},"source":["All results are content-addressed. If `results-file.txt` is updated with new results, Nextjournal does not write over the original file. The reference, [reference](#nextjournal#reference#bf447f1f-3ec7-4257-b394-86172f9c7b15), will simply point to the new results. This provides a form of version control for everything written to the filesystem.\n\nThis process is invisible to the end-user while providing immense flexibility and complete reproducibility.\n\n# Code Listings\n\nCode listings are not executable \u2014 they're for showing syntax-highlighted code in a larger variety of languages.\n\n```clojure no-exec id=f97700e4-e9b0-400a-a0ee-e2552f464414\n(->> (read)\n eval\n prn\n (while true))\n```\n\n## Custom Languages\n\nCode Listings also have a special option for custom languages. Selection \"Custom\" from the languages menu removes syntax highlighting from the code listing and allows for a custom language label.\n\n```custom no-exec id=c4c3a13c-3b14-4351-8fd3-c1a1fca58db0\nAddExp = AddExp \"+\" MulExp -- plus\n | AddExp \"-\" MulExp -- minus\n | MulExp\n```\n\n# Formula\n\nFormula can appear as block, where take up the whole width of the article, or inline, where they appear in the flow of a paragraph. Formula are written in [LaTeX](https:\/\/www.latex-project.org\/) and rendered in-browser using [katex](https:\/\/github.com\/Khan\/KaTeX).\n\n## Block Formulas\n\n$$\nA(t) = A \\sin\\left(2\\pi f t + \\phi\\right) = A \\sin\\left(\\omega t+\\phi\\right),\n$$\n## Inline Formulas\n\nHere is some text showing inlined LaTeX for an amplitude$A$, a frequency$f$, and a phase $\\phi$.\n\n# Embedding Tweets and Videos\n\nInsert an embed node and simply paste in a link to a tweet or YouTube or Vimeo video. If the link is recognizable, the media will show.\n\n## Tweets"]},{"cell_type":"raw","source":["nextjournal embed component"],"metadata":{"nextjournal":{"id":"30868604-b483-48d1-925a-56a5fd4c93ed"}}},{"cell_type":"markdown","metadata":{},"source":["## YouTube Videos"]},{"cell_type":"raw","source":["nextjournal embed component"],"metadata":{"nextjournal":{"id":"99b6f202-eebf-4e6a-8d00-771020586620"}}},{"cell_type":"markdown","metadata":{},"source":["## Vimeo Videos"]},{"cell_type":"raw","source":["nextjournal embed component"],"metadata":{"nextjournal":{"id":"d5a87d45-6166-4df7-8eaf-dae2534b53df"}}},{"cell_type":"markdown","metadata":{},"source":["# Appendix\n\nHere is some content that\u2019s initially invisible because it lives in the collapsed appendix section of this article."]}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment