Skip to content

Instantly share code, notes, and snippets.

View guest271314's full-sized avatar
💭
Fix WontFix

guest271314

💭
Fix WontFix
View GitHub Profile
@littledan
littledan / anonymous-inline-modules.md
Last active June 29, 2022 01:07
Anonymous inline modules
View anonymous-inline-modules.md

Note: this document is subsumed by the module blocks proposal

Anonymous inline modules

Anonymous inline modules are syntax for the contents of a module, which can then be imported.

let inlineModule = module {
  export let y = 1;
};
@spvkgn
spvkgn / opus-tools_static_build.sh
Last active September 10, 2022 23:06
Script to build a statically linked opus-tools
View opus-tools_static_build.sh
#!/bin/sh
# ==============================================================
# Script to build a statically linked version of opus-tools
#
# Release tarballs:
# http://downloads.xiph.org/releases/opus/
# http://downloads.xiph.org/releases/ogg/
# http://downloads.xiph.org/releases/flac/
#
@lukaslihotzki
lukaslihotzki / polyfill_worklet_import.js
Last active October 1, 2022 14:02
Polyfill to support "import" in worklet scripts in Firefox
View polyfill_worklet_import.js
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
@domenic
domenic / 1-service-worker.js
Last active October 20, 2022 11:10
Service worker stream transferring
View 1-service-worker.js
"use strict";
const worker = new Worker("worker.js");
self.onfetch = e => {
const transform = new TransformStream(); // creates an identity transform
e.respondWith(new Response(transform.readable));
// Give the worker the writable end. An identity transform stream will just shuffle
// bytes written there into transform.readable.
@Dobby233Liu
Dobby233Liu / a.js
Last active October 23, 2022 08:58
my messing w/ msedge dev read aloud. ONLY RUN IN edge dev. i give up, so it wont work properly
View a.js
var ARRAY_LENGTH = 16;
var MIN_HEX_LENGTH = 2;
class UUID {
static createUUID() {
const array = new Uint8Array(ARRAY_LENGTH);
window.crypto.getRandomValues(array);
let uuid = '';
@TotallyNotChase
TotallyNotChase / host.json
Last active October 24, 2022 02:01
Native Messaging - C
View host.json
{
"name": "pingpong",
"description": "Native messaging host example",
"path": "path/to/release_executable",
"type": "stdio",
"allowed_origins": [
"chrome-extension://extension_id/"
]
}
@zed
zed / ping_pong.c
Last active January 30, 2023 07:05
Native messaging "ping_pong" example in C
View ping_pong.c
/*** Native messaging "ping_pong" example in C.
*
* It is reimplementation of the corresponding Python example from
* https://github.com/mdn/webextensions-examples/tree/master/native-messaging
*
* # Python 3.x version
* # Read a message from stdin and decode it.
* def getMessage():
* rawLength = sys.stdin.buffer.read(4)
* if len(rawLength) == 0:
View nweb23.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@mathisonian
mathisonian / index.md
Last active March 22, 2023 05:31
requiring npm modules in the browser console
View index.md

demo gif

The final result: require() any module on npm in your browser console with browserify

This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.

Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5

inspiration

@yashraj1120
yashraj1120 / server.c
Created March 26, 2023 19:07
simple response server
View server.c
// 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>