From f8cde668cdff0f54a632328f924a3cfaed623b1e Mon Sep 17 00:00:00 2001 From: Anton Nesterov Date: Sun, 29 Sep 2024 14:14:44 +0200 Subject: [PATCH] ref: move notebooks to own directory --- .gitignore | 3 +- README.md | 3 + bun.lockb | Bin 0 -> 3144 bytes deno.json | 2 - deno_tinygo_wasm.ipynb | 79 ------------------ main.ts | 8 -- main_test.ts | 6 -- mod.ts | 1 + .../assets}/CarPrice_Assignment.csv | 0 .../assets}/cleaned_car_prices.csv | 0 .../assets}/encoded_car_data.csv | 0 .../data_analytics_js.ipynb | 0 .../deno_jupyter_bug.ipynb | 2 +- notebooks/deno_tinygo_wasm.ipynb | 59 +++++++++++++ package.json | 11 +++ tsconfig.json | 27 ++++++ 16 files changed, 104 insertions(+), 97 deletions(-) create mode 100644 README.md create mode 100755 bun.lockb delete mode 100644 deno_tinygo_wasm.ipynb delete mode 100644 main.ts delete mode 100644 main_test.ts create mode 100644 mod.ts rename {assets => notebooks/assets}/CarPrice_Assignment.csv (100%) rename {assets => notebooks/assets}/cleaned_car_prices.csv (100%) rename {assets => notebooks/assets}/encoded_car_data.csv (100%) rename data_analytics_js.ipynb => notebooks/data_analytics_js.ipynb (100%) rename deno_jupyter_bug.ipynb => notebooks/deno_jupyter_bug.ipynb (98%) create mode 100644 notebooks/deno_tinygo_wasm.ipynb create mode 100644 package.json create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 496ee2c..91dfed8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.DS_Store \ No newline at end of file +.DS_Store +node_modules \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7c4f72f --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# @nesterow/shortcuts + +Various functions for JS, Go and Jupyter Notebooks. diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..388cbd8d860578a2ccffcee489df595d4262740f GIT binary patch literal 3144 zcmd5;eNYr-7~jJK^-NI19CIA+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i-wo{@|owHgA?6?jg7CprzO)saR# zY2e8LoAE46(|F!m;a z=PUx}p|0Rcc5`ts8pzPSpsTw~x5j5S@Ek|8z?OJknLpn;r_%*RM03#^W5j9Miootp z(SsUs0)sOE`PM!z-9)SdQb@B-55=W9S>EF2IX>G(a~76y@v*{^fbEK2CQGG^~8kwq5^0gY0x8l`L96Ftl5}}?wHS7o9 UR|6pE+rY~Wq`)H{y#Jm019*x`oB#j- literal 0 HcmV?d00001 diff --git a/deno.json b/deno.json index 5b320c2..08f662a 100644 --- a/deno.json +++ b/deno.json @@ -1,8 +1,6 @@ { "tasks": { - "dev": "deno run --watch main.ts" }, "imports": { - "@std/assert": "jsr:@std/assert@1" } } diff --git a/deno_tinygo_wasm.ipynb b/deno_tinygo_wasm.ipynb deleted file mode 100644 index e5027a4..0000000 --- a/deno_tinygo_wasm.ipynb +++ /dev/null @@ -1,79 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Estimated offset is: 0.982618\n", - "Estimated slope is: 3.000173\n", - "R^2: 0.999999\n", - "2 \n" - ] - }, - { - "data": { - "text/plain": [ - "\u001b[1mnull\u001b[22m" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "import stats from \"./stat/mod.ts\";\n", - "\n", - "stats.example();" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2 \u0001\u0002\u0003\n" - ] - }, - { - "data": { - "text/plain": [ - "\u001b[1mnull\u001b[22m" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Deno", - "language": "typescript", - "name": "deno" - }, - "language_info": { - "codemirror_mode": "typescript", - "file_extension": ".ts", - "mimetype": "text/x.typescript", - "name": "typescript", - "nbconvert_exporter": "script", - "pygments_lexer": "typescript", - "version": "5.6.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/main.ts b/main.ts deleted file mode 100644 index 292ce5f..0000000 --- a/main.ts +++ /dev/null @@ -1,8 +0,0 @@ -export function add(a: number, b: number): number { - return a + b; -} - -// Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#concepts -if (import.meta.main) { - console.log("Add 2 + 3 =", add(2, 3)); -} diff --git a/main_test.ts b/main_test.ts deleted file mode 100644 index 3d981e9..0000000 --- a/main_test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { assertEquals } from "@std/assert"; -import { add } from "./main.ts"; - -Deno.test(function addTest() { - assertEquals(add(2, 3), 5); -}); diff --git a/mod.ts b/mod.ts new file mode 100644 index 0000000..f67b2c6 --- /dev/null +++ b/mod.ts @@ -0,0 +1 @@ +console.log("Hello via Bun!"); \ No newline at end of file diff --git a/assets/CarPrice_Assignment.csv b/notebooks/assets/CarPrice_Assignment.csv similarity index 100% rename from assets/CarPrice_Assignment.csv rename to notebooks/assets/CarPrice_Assignment.csv diff --git a/assets/cleaned_car_prices.csv b/notebooks/assets/cleaned_car_prices.csv similarity index 100% rename from assets/cleaned_car_prices.csv rename to notebooks/assets/cleaned_car_prices.csv diff --git a/assets/encoded_car_data.csv b/notebooks/assets/encoded_car_data.csv similarity index 100% rename from assets/encoded_car_data.csv rename to notebooks/assets/encoded_car_data.csv diff --git a/data_analytics_js.ipynb b/notebooks/data_analytics_js.ipynb similarity index 100% rename from data_analytics_js.ipynb rename to notebooks/data_analytics_js.ipynb diff --git a/deno_jupyter_bug.ipynb b/notebooks/deno_jupyter_bug.ipynb similarity index 98% rename from deno_jupyter_bug.ipynb rename to notebooks/deno_jupyter_bug.ipynb index 206445f..c24997d 100644 --- a/deno_jupyter_bug.ipynb +++ b/notebooks/deno_jupyter_bug.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [ { diff --git a/notebooks/deno_tinygo_wasm.ipynb b/notebooks/deno_tinygo_wasm.ipynb new file mode 100644 index 0000000..1db6ba5 --- /dev/null +++ b/notebooks/deno_tinygo_wasm.ipynb @@ -0,0 +1,59 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Linear Regression Line:\n", + "\tEstimated offset is: 1.480586\n", + "\tEstimated slope is: 2.999774\n", + "\tR^2 is: 0.999991\n" + ] + } + ], + "source": [ + "import stats from \"https://l12.xyz/x/shortcuts/raw/stat/mod.ts\";\n", + "\n", + "const xs = [];\n", + "const ys = [];\n", + "\n", + "for (let i = 0; i < 100; i++) {\n", + " xs.push(i);\n", + " ys.push((1 + 3 * i) + Math.random());\n", + "}\n", + "\n", + "const linreg = stats.LinearRegression(xs, ys, [], false);\n", + "const r = stats.RSquared(xs, ys, [], linreg.alpha, linreg.beta);\n", + "\n", + "console.log(\"\\nLinear Regression Line:\");\n", + "console.log(\"\\tEstimated offset is: \", linreg.alpha.toFixed(6));\n", + "console.log(\"\\tEstimated slope is: \", linreg.beta.toFixed(6));\n", + "console.log(\"\\tR^2 is: \", r.toFixed(6));\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Deno", + "language": "typescript", + "name": "deno" + }, + "language_info": { + "codemirror_mode": "typescript", + "file_extension": ".ts", + "mimetype": "text/x.typescript", + "name": "typescript", + "nbconvert_exporter": "script", + "pygments_lexer": "typescript", + "version": "5.6.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..b8d727c --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "@nesterow/shortcuts", + "module": "mod.ts", + "type": "module", + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..238655f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext", "DOM"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +}