Skip to content

Instantly share code, notes, and snippets.

View guest271314's full-sized avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@yashraj1120
yashraj1120 / server.c
Created March 26, 2023 19:07
simple response server
// 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>
@mamannn
mamannn / http2.js
Created March 15, 2023 14:45
http2
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,
},
@kfox
kfox / README.md
Last active September 23, 2025 07:02
TCP echo server for Node.js

TCP echo server for Node.js

Usage

  1. Make sure you have a modern-ish version of Node.js installed.
  2. Type npx https://gist.github.com/kfox/1280c2f0ee8324067dba15300e0f2fd3
  3. Connect to it from a client, e.g. netcat or similar: nc localhost 9000
@Ustice
Ustice / Boolean Algebra for Programmers in a Nutshell.md
Last active October 13, 2025 16:02
Boolean Algebra in a nutshell for JS/TS programmers

Boolean Algebra in a nutshell for JS/TS programmers

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

De Morgan's Theorem is great distributing nots (!), and for when you want to convert an && to an ||, or back. This is it:

 !(A &amp;&amp; B) = !A || !B
@lukaslihotzki
lukaslihotzki / polyfill_worklet_import.js
Last active October 1, 2022 14:02
Polyfill to support "import" in worklet scripts in Firefox
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
@hack0x90
hack0x90 / sc_index.js
Created May 15, 2022 20:53
SoundCloud mp3 Download Index.js File
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
@tangoabcdelta
tangoabcdelta / spdy.http2.js
Created April 16, 2022 14:44
determine if spdy or http2 was used to fetch website
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'
@dfkaye
dfkaye / Hash.js
Created March 6, 2022 02:54
Use crypto subtle digest to create hash hex string
// 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/

Javascript Cryptography Considered Harmful

WHAT DO YOU MEAN, "JAVASCRIPT CRYPTOGRAPHY"?

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.

@gildas-lormeau
gildas-lormeau / unzip
Created September 12, 2021 20:24
Basic unzip implementation based on zip.js and Deno
#!/bin/sh
~/.deno/bin/deno run --allow-net --allow-write --allow-read --unstable unzip.js "$@"