├── .gitignore ├── hmmm ├── .gitignore ├── Cargo.toml ├── src │ └── main.rs └── Cargo.lock ├── logo-animations ├── .prettierrc ├── .gitignore ├── public │ ├── favicon.png │ ├── index.html │ └── global.css ├── src │ ├── main.js │ ├── transitions.js │ └── App.svelte ├── package.json ├── rollup.config.js ├── README.md ├── scripts │ └── setupTypeScript.js └── package-lock.json ├── bouncydvd ├── .gitignore ├── preview.gif ├── assets │ └── dvd.png ├── Cargo.toml ├── src │ └── main.rs └── Cargo.lock ├── cursed-k8s-x86 ├── .gitignore ├── deploy-to-kube.sh ├── assemble.sh └── cursed.yaml.s ├── ferris ├── pleading@2x.png └── pleading.svg └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /hmmm/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /logo-animations/.prettierrc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bouncydvd/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /cursed-k8s-x86/.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | hello_world 3 | hello_world.o -------------------------------------------------------------------------------- /logo-animations/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /public/build/ 3 | 4 | .DS_Store 5 | .vscode -------------------------------------------------------------------------------- /cursed-k8s-x86/deploy-to-kube.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | kubectl apply -f cursed.yaml.s --validate=false -------------------------------------------------------------------------------- /bouncydvd/preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nikhiljha/experiments/HEAD/bouncydvd/preview.gif -------------------------------------------------------------------------------- /ferris/pleading@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nikhiljha/experiments/HEAD/ferris/pleading@2x.png -------------------------------------------------------------------------------- /bouncydvd/assets/dvd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nikhiljha/experiments/HEAD/bouncydvd/assets/dvd.png -------------------------------------------------------------------------------- /logo-animations/public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nikhiljha/experiments/HEAD/logo-animations/public/favicon.png -------------------------------------------------------------------------------- /logo-animations/src/main.js: -------------------------------------------------------------------------------- 1 | import App from './App.svelte'; 2 | 3 | var app = new App({ 4 | target: document.body 5 | }); 6 | 7 | export default app; -------------------------------------------------------------------------------- /hmmm/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hmmmm" 3 | version = "0.1.0" 4 | authors = ["Nikhil Jha "] 5 | edition = "2018" 6 | 7 | [dependencies] 8 | tempfile = "3.2.0" 9 | -------------------------------------------------------------------------------- /bouncydvd/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bouncydvd" 3 | version = "0.1.0" 4 | authors = ["Nikhil Jha "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | nannou = "0.16.0" 11 | -------------------------------------------------------------------------------- /logo-animations/src/transitions.js: -------------------------------------------------------------------------------- 1 | import { cubicOut } from 'svelte/easing'; 2 | 3 | export function shrink(node, params) { 4 | const { 5 | delay = 0, 6 | duration = 400, 7 | easing = cubicOut 8 | } = params; 9 | 10 | const w = parseFloat(getComputedStyle(node).strokeWidth); 11 | 12 | return { 13 | delay, 14 | duration, 15 | easing, 16 | css: t => `opacity: ${t}; stroke-width: ${t * w}` 17 | }; 18 | } -------------------------------------------------------------------------------- /logo-animations/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Svelte app 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /cursed-k8s-x86/assemble.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # These are the flags I needed to use to compile it on x86_64 MacOS. 4 | # The assembly uses MacOS syscalls to do hello world, so you'll need to substitute that with Linux syscalls if you want it to work there. 5 | # Also modify the below to make sense... 6 | as -target x86_64-apple-macos10.12 cursed.yaml.s -o hello_world.o 7 | ld -macosx_version_min 10.12 hello_world.o -o hello_world -lSystem -L /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib 8 | ./hello_world 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # experiments 2 | 3 | Hi! This repository is where I'm going to put short fun things I made that are probably never going to be touched again. 4 | 5 | ## cursed-k8s-x86 6 | 7 | A file that you can both `kubectl apply` and assemble/link with `as`/`ld`. 8 | 9 | ## bouncydvd 10 | 11 | The DVD logo bouncing around your screen, but in Rust. RESF Approved. 12 | 13 | 14 | 15 | ## hmmm 16 | 17 | A rust program that uses... an interesting trick... in order to print "Hello World". 18 | 19 | ## logo-animations 20 | 21 | my profile picture logo thing, but drawn (by hand) and animated with svelte 22 | 23 | -------------------------------------------------------------------------------- /logo-animations/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svelte-app", 3 | "version": "1.0.0", 4 | "private": true, 5 | "scripts": { 6 | "build": "rollup -c", 7 | "dev": "rollup -c -w", 8 | "start": "sirv public --no-clear" 9 | }, 10 | "devDependencies": { 11 | "@rollup/plugin-commonjs": "^17.0.0", 12 | "@rollup/plugin-node-resolve": "^11.0.0", 13 | "rollup": "^2.3.4", 14 | "rollup-plugin-css-only": "^3.1.0", 15 | "rollup-plugin-livereload": "^2.0.0", 16 | "rollup-plugin-svelte": "^7.0.0", 17 | "rollup-plugin-terser": "^7.0.0", 18 | "svelte": "^3.0.0" 19 | }, 20 | "dependencies": { 21 | "sirv-cli": "^1.0.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cursed-k8s-x86/cursed.yaml.s: -------------------------------------------------------------------------------- 1 | kubeajsd: 2 | .data 3 | msg: 4 | .asciz "Hello, world!\n" 5 | meme: 6 | .text 7 | .global _main 8 | _main: mov $0x02000004, %rax 9 | kubeaa: mov $1, %rdi /* 10 | apiVersion: apps/v1 11 | kind: Deployment 12 | metadata: 13 | kube2: aa */ 14 | name: nop 15 | spec: 16 | kube5: mov msg@GOTPCREL(%rip), %rsi /* 17 | replicas: 1 18 | selector: 19 | matchLabels: 20 | app: Nop 21 | kube6: aa */ 22 | template: 23 | metadata: 24 | labels: 25 | app: Nop 26 | kube3: mov $13, %rdx /* 27 | spec: 28 | containers: 29 | - image: gcr.io/google_containers/echoserver:1.0 30 | imagePullPolicy: Always 31 | name: echoserver 32 | ports: 33 | - containerPort: 8080 34 | kube4: aa */ 35 | kube9: 36 | syscall 37 | mov $0x02000001, %rax 38 | xor %rdi, %rdi 39 | syscall 40 | -------------------------------------------------------------------------------- /hmmm/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | use std::io::Write; 3 | use std::process::Command; 4 | use tempfile::tempdir; 5 | 6 | // dont worry about any of the code below, it's not cursed or anything 7 | // only 100% beautiful RESF-approved code here 👍 8 | 9 | fn main() { 10 | let program = "#include 11 | int main(void) 12 | { printf(\"Hello world\\n\"); }"; 13 | let dir = tempdir().unwrap(); 14 | let source_path = dir.path().join("helloworld.c"); 15 | let output_path = dir.path().join("a.out"); 16 | let mut source = File::create(source_path.clone()).unwrap(); 17 | writeln!(source, "{}", program); 18 | 19 | Command::new("clang") 20 | .arg(source_path.clone()) 21 | .arg("-o") 22 | .arg(output_path.clone()) 23 | .output() 24 | .expect("failed to execute clang"); 25 | 26 | let output = Command::new(output_path) 27 | .output() 28 | .expect("failed to execute helloworld"); 29 | 30 | println!("{}", String::from_utf8(output.stdout).unwrap()); 31 | } 32 | -------------------------------------------------------------------------------- /logo-animations/public/global.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | position: relative; 3 | width: 100%; 4 | height: 100%; 5 | } 6 | 7 | body { 8 | color: #333; 9 | margin: 0; 10 | padding: 8px; 11 | box-sizing: border-box; 12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; 13 | } 14 | 15 | a { 16 | color: rgb(0,100,200); 17 | text-decoration: none; 18 | } 19 | 20 | a:hover { 21 | text-decoration: underline; 22 | } 23 | 24 | a:visited { 25 | color: rgb(0,80,160); 26 | } 27 | 28 | label { 29 | display: block; 30 | } 31 | 32 | input, button, select, textarea { 33 | font-family: inherit; 34 | font-size: inherit; 35 | -webkit-padding: 0.4em 0; 36 | padding: 0.4em; 37 | margin: 0 0 0.5em 0; 38 | box-sizing: border-box; 39 | border: 1px solid #ccc; 40 | border-radius: 2px; 41 | } 42 | 43 | input:disabled { 44 | color: #ccc; 45 | } 46 | 47 | button { 48 | color: #333; 49 | background-color: #f4f4f4; 50 | outline: none; 51 | } 52 | 53 | button:disabled { 54 | color: #999; 55 | } 56 | 57 | button:not(:disabled):active { 58 | background-color: #ddd; 59 | } 60 | 61 | button:focus { 62 | border-color: #666; 63 | } 64 | -------------------------------------------------------------------------------- /bouncydvd/src/main.rs: -------------------------------------------------------------------------------- 1 | use nannou::prelude::*; 2 | use nannou::rand; 3 | 4 | fn main() { 5 | nannou::app(model) 6 | .update(update) 7 | .simple_window(view) 8 | .run(); 9 | } 10 | 11 | struct Model { 12 | x: f32, 13 | y: f32, 14 | angle: f32, 15 | texture: wgpu::Texture, 16 | } 17 | 18 | fn model(app: &App) -> Model { 19 | let assets = app.assets_path().unwrap(); 20 | let img_path = assets.join("dvd.png"); 21 | let texture = wgpu::Texture::from_path(app, img_path).unwrap(); 22 | 23 | Model { 24 | x: 0.0, 25 | y: 0.0, 26 | angle: 90.0.to_radians(), 27 | texture: texture, 28 | } 29 | } 30 | 31 | fn update(_app: &App, model: &mut Model, _update: Update) { 32 | model.x += model.angle.cos() * 0.01; 33 | model.y += model.angle.sin() * 0.01; 34 | if model.x >= 1.0 { 35 | model.angle = rand::random_range(90.0.to_radians(), 270.0.to_radians()); 36 | } else if model.y >= 1.0 { 37 | model.angle = rand::random_range(180.0.to_radians(), 360.0.to_radians()); 38 | } else if model.x <= -1.0 { 39 | model.angle = rand::random_range(-90.0.to_radians(), 90.0.to_radians()); 40 | } else if model.y <= -1.0 { 41 | model.angle = rand::random_range(0.0.to_radians(), 180.0.to_radians()); 42 | } 43 | } 44 | 45 | fn view(app: &App, model: &Model, frame: Frame) { 46 | let draw = app.draw(); 47 | let win = app.window_rect().pad_top(31.0).pad_bottom(31.0).pad_left(50.0).pad_right(50.0); 48 | 49 | frame.clear(WHITE); 50 | // draw.text(&format!("{} {} {}", model.angle, model.x, model.y)) 51 | // .x_y(0.0, 0.0) 52 | // .color(BLACK); 53 | // draw.rect() 54 | // .x_y(model.x * win.w() / 2.0, model.y * win.h() / 2.0) 55 | // .w_h(100.0, 100.0) 56 | // .color(PLUM); 57 | 58 | draw.texture(&model.texture) 59 | .x_y(model.x * win.w() / 2.0, model.y * win.h() / 2.0) 60 | .w_h(100.0, 62.0); 61 | 62 | draw.to_frame(app, &frame).unwrap(); 63 | } -------------------------------------------------------------------------------- /logo-animations/rollup.config.js: -------------------------------------------------------------------------------- 1 | import svelte from 'rollup-plugin-svelte'; 2 | import commonjs from '@rollup/plugin-commonjs'; 3 | import resolve from '@rollup/plugin-node-resolve'; 4 | import livereload from 'rollup-plugin-livereload'; 5 | import { terser } from 'rollup-plugin-terser'; 6 | import css from 'rollup-plugin-css-only'; 7 | 8 | const production = !process.env.ROLLUP_WATCH; 9 | 10 | function serve() { 11 | let server; 12 | 13 | function toExit() { 14 | if (server) server.kill(0); 15 | } 16 | 17 | return { 18 | writeBundle() { 19 | if (server) return; 20 | server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { 21 | stdio: ['ignore', 'inherit', 'inherit'], 22 | shell: true 23 | }); 24 | 25 | process.on('SIGTERM', toExit); 26 | process.on('exit', toExit); 27 | } 28 | }; 29 | } 30 | 31 | export default { 32 | input: 'src/main.js', 33 | output: { 34 | sourcemap: true, 35 | format: 'iife', 36 | name: 'app', 37 | file: 'public/build/bundle.js' 38 | }, 39 | plugins: [ 40 | svelte({ 41 | compilerOptions: { 42 | // enable run-time checks when not in production 43 | dev: !production 44 | } 45 | }), 46 | // we'll extract any component CSS out into 47 | // a separate file - better for performance 48 | css({ output: 'bundle.css' }), 49 | 50 | // If you have external dependencies installed from 51 | // npm, you'll most likely need these plugins. In 52 | // some cases you'll need additional configuration - 53 | // consult the documentation for details: 54 | // https://github.com/rollup/plugins/tree/master/packages/commonjs 55 | resolve({ 56 | browser: true, 57 | dedupe: ['svelte'] 58 | }), 59 | commonjs(), 60 | 61 | // In dev mode, call `npm run start` once 62 | // the bundle has been generated 63 | !production && serve(), 64 | 65 | // Watch the `public` directory and refresh the 66 | // browser on changes when not in production 67 | !production && livereload('public'), 68 | 69 | // If we're building for production (npm run build 70 | // instead of npm run dev), minify 71 | production && terser() 72 | ], 73 | watch: { 74 | clearScreen: false 75 | } 76 | }; 77 | -------------------------------------------------------------------------------- /logo-animations/README.md: -------------------------------------------------------------------------------- 1 | *Looking for a shareable component template? Go here --> [sveltejs/component-template](https://github.com/sveltejs/component-template)* 2 | 3 | --- 4 | 5 | # svelte app 6 | 7 | This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template. 8 | 9 | To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit): 10 | 11 | ```bash 12 | npx degit sveltejs/template svelte-app 13 | cd svelte-app 14 | ``` 15 | 16 | *Note that you will need to have [Node.js](https://nodejs.org) installed.* 17 | 18 | 19 | ## Get started 20 | 21 | Install the dependencies... 22 | 23 | ```bash 24 | cd svelte-app 25 | npm install 26 | ``` 27 | 28 | ...then start [Rollup](https://rollupjs.org): 29 | 30 | ```bash 31 | npm run dev 32 | ``` 33 | 34 | Navigate to [localhost:5000](http://localhost:5000). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes. 35 | 36 | By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`. 37 | 38 | If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense. 39 | 40 | ## Building and running in production mode 41 | 42 | To create an optimised version of the app: 43 | 44 | ```bash 45 | npm run build 46 | ``` 47 | 48 | You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com). 49 | 50 | 51 | ## Single-page app mode 52 | 53 | By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere. 54 | 55 | If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json: 56 | 57 | ```js 58 | "start": "sirv public --single" 59 | ``` 60 | 61 | ## Using TypeScript 62 | 63 | This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with: 64 | 65 | ```bash 66 | node scripts/setupTypeScript.js 67 | ``` 68 | 69 | Or remove the script via: 70 | 71 | ```bash 72 | rm scripts/setupTypeScript.js 73 | ``` 74 | 75 | ## Deploying to the web 76 | 77 | ### With [Vercel](https://vercel.com) 78 | 79 | Install `vercel` if you haven't already: 80 | 81 | ```bash 82 | npm install -g vercel 83 | ``` 84 | 85 | Then, from within your project folder: 86 | 87 | ```bash 88 | cd public 89 | vercel deploy --name my-project 90 | ``` 91 | 92 | ### With [surge](https://surge.sh/) 93 | 94 | Install `surge` if you haven't already: 95 | 96 | ```bash 97 | npm install -g surge 98 | ``` 99 | 100 | Then, from within your project folder: 101 | 102 | ```bash 103 | npm run build 104 | surge public my-project.surge.sh 105 | ``` 106 | -------------------------------------------------------------------------------- /logo-animations/src/App.svelte: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | cool website 12 | 17 | 18 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | {#if !visible} 65 | 66 | 71 | setTimeout(() => { 72 | visible = !visible; 73 | }, 600)} 74 | d="M125.74,360.65l41.57,24.41,40.9-24.41-23,77.5L147.73,438Zm22.73,80.27L167,499.59l17.47-58.67Zm13.35-277.65h9.44l-4.72-33.75Zm51.24-82-45-78.47V124.07Zm-43.32,45.3,68.65.09-23.77-43.1Zm-.86,2.93,5.21,34,34,20.14,31-54.12Zm72.21,1.7-30.28,53.66,43.77,25.28,11-34.64Zm22.43,84.94,1,38.6h47.42l-44.54-76.52-10.51,33.39ZM290.68,341l41.49-52.71-18.44-30.74H264.4l.28,68.6ZM172.84,489.73l32.54-48.81H187.72Zm15.58-17.35,25.78-31.46h-5.43ZM268.16,332l-5.2-3.47L218.37,356l-10.8,18.27-19.2,63.9H207ZM210.1,438.15h6.06l72.75-94.73-18.11-9.95ZM165,124.07V2.82L120,81.29ZM118.45,83.58l-23.77,43.1,68.65-.09ZM94,129.52l31,54.12,34-20.14,5.2-34Zm-26.52,46,11,34.64,43.77-25.28L92,131.22Zm8.71,36.11L65.72,178.24,21.18,254.76H68.61l1-38.6ZM68.4,326.18l.27-68.6H19.35L.91,288.32,42.39,341Zm77,114.74H127.7l32.53,48.81Zm-21.06,0h-5.42l25.78,31.46Zm1.75-2.77H144.7l-19.19-63.9L114.71,356,70.12,328.49,64.91,332ZM62.27,333.47l-18.11,9.95,72.76,94.73H123Z" /> 75 | 76 | {/if} 77 | 78 | {#if visible} 79 | 80 | 84 | 85 | {/if} 86 | 87 | 88 | -------------------------------------------------------------------------------- /logo-animations/scripts/setupTypeScript.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | 3 | /** This script modifies the project to support TS code in .svelte files like: 4 | 5 | 8 | 9 | As well as validating the code for CI. 10 | */ 11 | 12 | /** To work on this script: 13 | rm -rf test-template template && git clone sveltejs/template test-template && node scripts/setupTypeScript.js test-template 14 | */ 15 | 16 | const fs = require("fs") 17 | const path = require("path") 18 | const { argv } = require("process") 19 | 20 | const projectRoot = argv[2] || path.join(__dirname, "..") 21 | 22 | // Add deps to pkg.json 23 | const packageJSON = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.json"), "utf8")) 24 | packageJSON.devDependencies = Object.assign(packageJSON.devDependencies, { 25 | "svelte-check": "^1.0.0", 26 | "svelte-preprocess": "^4.0.0", 27 | "@rollup/plugin-typescript": "^8.0.0", 28 | "typescript": "^4.0.0", 29 | "tslib": "^2.0.0", 30 | "@tsconfig/svelte": "^1.0.0" 31 | }) 32 | 33 | // Add script for checking 34 | packageJSON.scripts = Object.assign(packageJSON.scripts, { 35 | "validate": "svelte-check" 36 | }) 37 | 38 | // Write the package JSON 39 | fs.writeFileSync(path.join(projectRoot, "package.json"), JSON.stringify(packageJSON, null, " ")) 40 | 41 | // mv src/main.js to main.ts - note, we need to edit rollup.config.js for this too 42 | const beforeMainJSPath = path.join(projectRoot, "src", "main.js") 43 | const afterMainTSPath = path.join(projectRoot, "src", "main.ts") 44 | fs.renameSync(beforeMainJSPath, afterMainTSPath) 45 | 46 | // Switch the app.svelte file to use TS 47 | const appSveltePath = path.join(projectRoot, "src", "App.svelte") 48 | let appFile = fs.readFileSync(appSveltePath, "utf8") 49 | appFile = appFile.replace("