-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
{ | ||
"nbformat": 4, | ||
"nbformat_minor": 0, | ||
"metadata": { | ||
"colab": { | ||
"name": "Terminal_CryptoDeepTech.ipynb", | ||
"provenance": [], | ||
"collapsed_sections": [] | ||
}, | ||
"kernelspec": { | ||
"name": "python3", | ||
"display_name": "Python 3" | ||
} | ||
}, | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"from google.colab import drive\n", | ||
"drive.mount('/content/drive/')\n" | ||
], | ||
"metadata": { | ||
"id": "uJsx5Qdzetn0" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"cd drive/MyDrive/" | ||
], | ||
"metadata": { | ||
"id": "J3zgAAFdevhI" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "JkHBZhTNN9K_" | ||
}, | ||
"source": [ | ||
"#@title JS Shell\n", | ||
"%%html\n", | ||
"<div id=term_demo></div>\n", | ||
"<script src=\"https://code.jquery.com/jquery-latest.js\"></script>\n", | ||
"<script src=\"https://cdn.jsdelivr.net/npm/jquery.terminal/js/jquery.terminal.min.js\"></script>\n", | ||
"<link href=\"https://cdn.jsdelivr.net/npm/jquery.terminal/css/jquery.terminal.min.css\" rel=\"stylesheet\"/>\n", | ||
"<script>\n", | ||
" $('#term_demo').terminal(function(command) {\n", | ||
" if (command !== '') {\n", | ||
" try {\n", | ||
" var result = window.eval(command);\n", | ||
" if (result !== undefined) {\n", | ||
" this.echo(new String(result));\n", | ||
" }\n", | ||
" } catch(e) {\n", | ||
" this.error(new String(e));\n", | ||
" }\n", | ||
" } else {\n", | ||
" this.echo('');\n", | ||
" }\n", | ||
" }, {\n", | ||
" greetings: 'Welcome to JavaScript Shell',\n", | ||
" name: 'js_demo',\n", | ||
" height: 200,\n", | ||
" prompt: 'js> '\n", | ||
" });" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "ePOgDV3PR7P5" | ||
}, | ||
"source": [ | ||
"#@title IPython.display\n", | ||
"from IPython.display import JSON\n", | ||
"from google.colab import output\n", | ||
"from subprocess import getoutput\n", | ||
"import os\n", | ||
"\n", | ||
"def shell(command):\n", | ||
" if command.startswith('cd'):\n", | ||
" path = command.strip().split(maxsplit=1)[1]\n", | ||
" os.chdir(path)\n", | ||
" return JSON([''])\n", | ||
" return JSON([getoutput(command)])\n", | ||
"output.register_callback('shell', shell)" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"metadata": { | ||
"id": "Kn9S2H8HODQD" | ||
}, | ||
"source": [ | ||
"#@title Terminal CryptoDeepTech\n", | ||
"%%html\n", | ||
"<div id=term_demo></div>\n", | ||
"<script src=\"https://code.jquery.com/jquery-latest.js\"></script>\n", | ||
"<script src=\"https://cdn.jsdelivr.net/npm/jquery.terminal/js/jquery.terminal.min.js\"></script>\n", | ||
"<link href=\"https://cdn.jsdelivr.net/npm/jquery.terminal/css/jquery.terminal.min.css\" rel=\"stylesheet\"/>\n", | ||
"<script>\n", | ||
" $('#term_demo').terminal(async function(command) {\n", | ||
" if (command !== '') {\n", | ||
" try {\n", | ||
" let res = await google.colab.kernel.invokeFunction('shell', [command])\n", | ||
" let out = res.data['application/json'][0]\n", | ||
" this.echo(new String(out))\n", | ||
" } catch(e) {\n", | ||
" this.error(new String(e));\n", | ||
" }\n", | ||
" } else {\n", | ||
" this.echo('');\n", | ||
" }\n", | ||
" }, {\n", | ||
" greetings: 'Terminal CryptoDeepTech',\n", | ||
" name: 'colab_demo',\n", | ||
" height: 320,\n", | ||
" prompt: 'crypto > '\n", | ||
" });" | ||
], | ||
"execution_count": null, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"" | ||
], | ||
"metadata": { | ||
"id": "HGohEqF7tcep" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
} | ||
] | ||
} |