Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dfinke committed Sep 10, 2020
2 parents 6ac4833 + e89876d commit 90878a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 165 deletions.
2 changes: 1 addition & 1 deletion 08_apples_and_bananas/apples.ipynb
Expand Up @@ -130,7 +130,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The argument may name a file in which case you should read the contents of that file"
"The argument may name a file in which case you should read the contents of that file. In addition the -vowel command line argument can be passed to override the default character (a)"
]
},
{
Expand Down
156 changes: 10 additions & 146 deletions 10_telephone/telephone.ipynb
Expand Up @@ -11,118 +11,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\r\n",
"<div>\r\n",
" <div id='dotnet-interactive-this-cell-57750' style='display: none'>\r\n",
" The below script needs to be able to find the current output cell; this is an easy method to get it.\r\n",
" </div>\r\n",
" <script type='text/javascript'>\r\n",
"// ensure `requirejs` is available globally\r\n",
"if (typeof requirejs !== typeof Function || typeof requirejs.config !== typeof Function) {\r\n",
" let requirejs_script = document.createElement('script');\r\n",
" requirejs_script.setAttribute('src', 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js');\r\n",
" requirejs_script.setAttribute('type', 'text/javascript');\r\n",
" requirejs_script.onload = function () {\r\n",
" loadDotnetInteractiveApi();\r\n",
" };\r\n",
"\r\n",
" document.getElementsByTagName('head')[0].appendChild(requirejs_script);\r\n",
"}\r\n",
"else {\r\n",
" loadDotnetInteractiveApi();\r\n",
"}\r\n",
"\r\n",
"async function probeAddresses(probingAddresses) {\r\n",
" function timeout(ms, promise) {\r\n",
" return new Promise(function (resolve, reject) {\r\n",
" setTimeout(function () {\r\n",
" reject(new Error('timeout'))\r\n",
" }, ms)\r\n",
" promise.then(resolve, reject)\r\n",
" })\r\n",
" }\r\n",
"\r\n",
" if (Array.isArray(probingAddresses)) {\r\n",
" for (let i = 0; i < probingAddresses.length; i++) {\r\n",
"\r\n",
" let rootUrl = probingAddresses[i];\r\n",
"\r\n",
" if (!rootUrl.endsWith('/')) {\r\n",
" rootUrl = `${rootUrl}/`;\r\n",
" }\r\n",
"\r\n",
" try {\r\n",
" let response = await timeout(1000, fetch(`${rootUrl}discovery`, {\r\n",
" method: 'POST',\r\n",
" timeout: 1000,\r\n",
" headers: {\r\n",
" 'Content-Type': 'text/plain'\r\n",
" },\r\n",
" body: probingAddresses[i]\r\n",
" }));\r\n",
"\r\n",
" if (response.status == 200) {\r\n",
" return rootUrl;\r\n",
" }\r\n",
" }\r\n",
" catch (e) { }\r\n",
" }\r\n",
" }\r\n",
"}\r\n",
"\r\n",
"function loadDotnetInteractiveApi() {\r\n",
" probeAddresses([\"http://172.24.208.1:57750/\", \"http://192.168.1.65:57750/\", \"http://172.23.64.1:57750/\", \"http://127.0.0.1:57750/\"])\r\n",
" .then((root) => {\r\n",
" // use probing to find host url and api resources\r\n",
" // load interactive helpers and language services\r\n",
" let dotnet_require = requirejs.config({\r\n",
" context: '12900.57750',\r\n",
" paths: {\r\n",
" 'dotnet-interactive': `${root}resources`\r\n",
" }\r\n",
" });\r\n",
" if (!window.dotnet_require) {\r\n",
" window.dotnet_require = dotnet_require;\r\n",
" }\r\n",
" \r\n",
" dotnet_require([\r\n",
" 'dotnet-interactive/dotnet-interactive',\r\n",
" 'dotnet-interactive/lsp',\r\n",
" 'dotnet-interactive/editor-detection'\r\n",
" ],\r\n",
" function (dotnet, lsp, editor) {\r\n",
" dotnet.init(window);\r\n",
" \r\n",
" },\r\n",
" function (error) {\r\n",
" console.log(error);\r\n",
" }\r\n",
" );\r\n",
" })\r\n",
" .catch(error => {console.log(error);});\r\n",
" }\r\n",
" </script>\r\n",
"</div>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"You said: \"The quick brown fox jumps over the lazy dog.\"\r\n",
"I heard : \"The q+ick b(own fox jumps<over the l&zy dog.\"\r\n"
]
}
],
"outputs": [],
"source": [
".\\telephone.ps1 'The quick brown fox jumps over the lazy dog.'"
]
Expand All @@ -136,18 +27,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"You said: \"The quick brown fox jumps over the lazy dog.\"\r\n",
"I heard : \"-he wuick b#own fox jumps over t$e lazy dog.\"\r\n"
]
}
],
"outputs": [],
"source": [
" .\\telephone.ps1 ../inputFiles/fox.txt"
]
Expand All @@ -161,20 +43,11 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"You said: \"../inputs/fox.txt\"\r\n",
"I heard : \"../i}fHls/fwS^sxt\"\r\n"
]
}
],
"outputs": [],
"source": [
".\\telephone.ps1 -m .5 ../inputs/fox.txt"
".\\telephone.ps1 -m .5 ../inputFiles/fox.txt"
]
},
{
Expand All @@ -186,20 +59,11 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"You said: \"../inputs/fox.txt\"\r\n",
"I heard : \"../inputs/foE.oxt\"\r\n"
]
}
],
"outputs": [],
"source": [
".\\telephone.ps1 -s 2 ../inputs/fox.txt"
".\\telephone.ps1 -s 2 ../inputFiles/fox.txt"
]
}
],
Expand Down
20 changes: 2 additions & 18 deletions 11_bottles_of_beer/bottles.ipynb
Expand Up @@ -27,25 +27,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2 bottles of beer on the wall,\r\n",
"2 bottles of beer,\r\n",
"Take one down, pass it around,\r\n",
"1 bottle of beer on the wall!\r\n",
"1 bottle of beer on the wall,\r\n",
"1 bottle of beer,\r\n",
"Take one down, pass it around,\r\n",
"No more bottles of beer on the wall!\r\n",
"\r\n"
]
}
],
"outputs": [],
"source": [
" ./bottles.ps1 -n 2"
]
Expand Down

0 comments on commit 90878a8

Please sign in to comment.