diff --git a/003_test_cicada_sockio_notebook.ipynb b/003_test_cicada_sockio_notebook.ipynb new file mode 100644 index 0000000..383e159 --- /dev/null +++ b/003_test_cicada_sockio_notebook.ipynb @@ -0,0 +1,199 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "001_test_cicada_sockio_notebook.ipynb", + "provenance": [], + "private_outputs": true, + "collapsed_sections": [], + "toc_visible": true, + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "accelerator": "GPU" + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "XlrPVwyqCkGr", + "colab_type": "text" + }, + "source": [ + "\n", + "## .: Intro to the cicada python daemon library :. \n", + " \n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "loE0T33BDhtT", + "colab_type": "text" + }, + "source": [ + "### :: Install cicada and loguru ::\n", + "\n", + "
\n", + "\n", + " \n" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "SJvKkrMxosVS", + "colab_type": "code", + "colab": {} + }, + "source": [ + "!pip install https://github.com/omgimdrunk/cicada/raw/master/dist/cicada-0.5.10-py3-none-any.whl\n", + "!pip install --upgrade loguru" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bXu6Kyd_ySKR", + "colab_type": "text" + }, + "source": [ + " ### :: Creating client socket and threading read out ::\n", + "
\n", + "\n", + " \n" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "ZAIyfxPf1k18", + "colab_type": "code", + "colab": {} + }, + "source": [ + "from cicada.sockio import INET_TCP\n", + "from getpass import getpass\n", + "import sys\n", + "import time\n", + "\n", + "\n", + "\n", + "def intohere(data):\n", + "\n", + " sys.stdout.write(\"{}\".format(data))\n", + " sys.stdout.flush()\n", + "\n", + "def inetguest(typeinet):\n", + " \"\"\"\n", + " read_into :: def read_into(self, on_read)\n", + "\n", + " This will dup the socket but doesn't destroy the parent!\n", + " From this point on it can only read,\n", + " while the parent can only write.\n", + " \n", + " \"\"\"\n", + "\n", + "\n", + " with typeinet('freechess.org', 5000) as muhsock:\n", + " if muhsock.as_guest():\n", + " muhsock.read_into(on_read=intohere)\n", + " while muhsock.is_connected:\n", + "\n", + " x = getpass();\n", + " try:\n", + " d_out = muhsock.write(x)\n", + " except Exception as E:\n", + " sys.stderr.write(\"[{}] : {} {} !err \\n\".format(time.time(), E, d_out))\n", + " sys.exit()\n", + "\n", + " \n", + "inetguest(INET_TCP)\n", + "\n" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "pUfwaxOh1UKR", + "colab_type": "code", + "colab": {} + }, + "source": [ + "" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "qX9xZFvk_Ini", + "colab_type": "text" + }, + "source": [ + "### :: Compile C and link to py quickly\n", + "
\n", + "\n", + " \n" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "aK39BZmd62ZS", + "colab_type": "code", + "colab": {} + }, + "source": [ + "!echo -e ' #include \\n int main(){ printf(\"%s\", \"aaaannnnndddd we have a SUPA C COMPILA!\"); return 0; }' > gcctest.c\n", + "!gcc gcctest.c -o gcctest.o\n", + "!./gcctest.o" + ], + "execution_count": 0, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "IM5OLSuQ_uVN", + "colab_type": "text" + }, + "source": [ + "# New Section" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "iz4HDHat_vYP", + "colab_type": "code", + "colab": {} + }, + "source": [ + "!ls -lth\n", + "!uname -m" + ], + "execution_count": 0, + "outputs": [] + } + ] +} \ No newline at end of file