- Make sure you have a modern-ish version of Node.js installed.
- Type
npx https://gist.github.com/kfox/1280c2f0ee8324067dba15300e0f2fd3 - Connect to it from a client, e.g.
netcator similar:nc localhost 9000
| // webserver.c | |
| // https://bruinsslot.jp/post/simple-http-webserver-in-c/ | |
| #include <arpa/inet.h> | |
| #include <errno.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <stdint.h> | |
| #include <stdlib.h> | |
| #include <sys/socket.h> |
| import got from "got"; | |
| import http2 from "http2-wrapper"; | |
| const httpsProxy = new http2.proxies.Http2OverHttp({ | |
| proxyOptions: { | |
| url: "http://localhost:3128", | |
| // For demo purposes only! | |
| rejectUnauthorized: false, | |
| }, |
There are a lot of strategies that you will hear about in the Javascript community for keeping your conditionals from becoming a tangled mess. This isn't like them. This is someting different. MATH! Boolean Algebra to be exact. I use it all the time to simplify complex conditionals. There are two things that you need to know: de Morgan's Theorem, and Karnaugh (pronounced CAR-no) Maps. (Don't worry, there is no test)
De Morgan's Theorem is great distributing nots (!), and for when you want to convert an && to an ||, or back. This is it:
!(A && B) = !A || !B
| const wrappedFunc = Worklet.prototype.addModule; | |
| Worklet.prototype.addModule = async function(url) { | |
| try { | |
| return await wrappedFunc.call(this, url); | |
| } catch (e) { | |
| if (e.name != 'AbortError') { | |
| throw e; | |
| } | |
| // assume error is caused by https://bugzilla.mozilla.org/show_bug.cgi?id=1572644 |
| import { spawn } from 'child_process'; | |
| import { parse } from 'node-html-parser'; | |
| const client_id = process.env.SOUNDCLOUD_CLIENT_ID; | |
| const link = process.argv[2] || 'https://soundcloud.com/rashidaliofficial/kabhi-kabhi-aditi'; | |
| /* | |
| * Download SoundCloud track page HTML code |
| window.performance.getEntriesByType("resource").filter(p => 'nextHopProtocol' in p)[0].nextHopProtocol // 'h2' | |
| // deprecated | |
| // https://chromestatus.com/feature/5637885046816768 | |
| window.chrome.loadTimes().wasFetchedViaSpdy; // true | |
| window.chrome.loadTimes().npnNegotiatedProtocol; // 'h2' | |
| window.chrome.loadTimes().connectionInfo; // 'h2' | |
| // 5 March 2022 | |
| // Using window.crypto.subtle.digest() | |
| // @param "sha-256" or other algorithm | |
| // @param DataView with ArrayBuffer or just ArrayBuffer | |
| // Not my own. | |
| // Copy+paste+modified from | |
| // https://stackoverflow.com/a/68545495 |
Originally posted at https://www.nccgroup.trust/us/about-us/newsroom-and-events/blog/2011/august/javascript-cryptography-considered-harmful/
We mean attempts to implement security features in browsers using cryptographic algoritms implemented in whole or in part in Javascript.
You may now be asking yourself, "What about Node.js? What about non-browser Javascript?". Non-browser Javascript cryptography is perilous, but not doomed. For the rest of this document, we're referring to browser Javascript when we discuss Javascript cryptography.
| #!/bin/sh | |
| ~/.deno/bin/deno run --allow-net --allow-write --allow-read --unstable unzip.js "$@" |