Skip to content

Instantly share code, notes, and snippets.

View tiye's full-sized avatar
💭
Make Cirru great again!

题叶 tiye

💭
Make Cirru great again!
View GitHub Profile
@guest271314
guest271314 / javascript_engines_and_runtimes.md
Last active May 25, 2024 13:02
A list of JavaScript engines, runtimes, interpreters

V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Chrome and in Node.js, among others. It implements ECMAScript and WebAssembly, and runs on Windows 7 or later, macOS 10.12+, and Linux systems that use x64, IA-32, ARM, or MIPS processors. V8 can run standalone, or can be embedded into any C++ application.

SpiderMonkey is Mozilla’s JavaScript and WebAssembly Engine, used in Firefox, Servo and various other projects. It is written in C++, Rust and JavaScript. You can embed it into C++ and Rust projects, and it can be run as a stand-alone shell. It can also be [compiled](https://bytecodealliance.org/articles/making-javascript-run-fast-on

<script>
var module = WebAssembly.instantiateStreaming(fetch("linked_list.wasm"), {});
</script>

WebGPU in Deno and the browser (with canvas-sketch)

This is a canvas-sketch demo that can render an image with WebGPU in both the browser and deno.

requirements

This requires deno 1.8 or higher (tested on 1.31.3) and a recent version of node/npm to install canvas-sketch-cli. If you want to run the browser version, you'll need a browser with WebGPU support, which is most likely going to be Chrome Canary with WebGPU enabled.

@hjlld
hjlld / explainer.md
Created October 8, 2021 09:22
WebGPU 标准释义 - 中文版

1. 概述

WebGPU 是一个让网页可以使用系统 GPU 来实现计算和绘制复杂图形并呈现在网页内部的 Web API 提案。目标和 WebGL 家族的 API 类似,但 WebGPU 可以访问更多更高级的 GPU 特性。在 WebGL 中,其主要用途是用于绘制图形,但是经过(相当大的努力的)改造才能用于计算,而 WebGPU 则是把 GPU 通用计算作为首要支持。

1.1 使用场景

如下示例场景,未能被 WebGL 2 覆盖,需要使用 WebGPU:

  • 绘制物体数量庞大、高度细节化的场景图形(例如 CAD 模型)。WebGPU 的绘制命令的性能消耗比 WebGL 低很多。
  • 执行高级算法用于绘制逼真的场景。由于缺乏对通用计算的支持,许多现代渲染技术和优化不能在 WebGL 2 上实现。
@munrocket
munrocket / wgsl_3d_sdf.md
Last active May 22, 2024 17:13
WGSL 3D SDF Primitives

WGSL 3D SDF Primitives

Revision: 06.08.2023, https://compute.toys/view/407

Sphere - exact

fn sdSphere(p: vec3f, r: f32) -> f32 {
  return length(p) - r;
}
@munrocket
munrocket / wgsl_noise.md
Last active May 22, 2024 16:46
WGSL Noise Algorithms

WGSL Noise Algorithms

Operator % has changed, probably current code with it need a fix

Good and fast integer hash

// https://www.pcg-random.org/
fn pcg(n: u32) -> u32 {
    var h = n * 747796405u + 2891336453u;
    h = ((h >> ((h >> 28u) + 4u)) ^ h) * 277803737u;
@technikhil314
technikhil314 / generateDigest.js
Last active November 30, 2023 09:55
Generate sha-256 hash using crypto in browsers
const text = 'An obscure body in the S-K System, your majesty. The inhabitants refer to it as the planet Earth.';
async function digestMessage(message) {
const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); // hash the message
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
return hashHex;
}
@sindresorhus
sindresorhus / esm-package.md
Last active June 1, 2024 19:35
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@ursi
ursi / publishing-packages.md
Last active April 2, 2021 01:03
The current process for Publishing PureScript packages

PureScript is currently in a transitional period with regards to how new packages are published. As such, the process of publishing a package is rather arduous. You will need: spago, pulp, and bower.

  1. Make sure your package name is unique by searching for it in bower-packages.json and new-packages.json. Alternatively you can search Pursuit as well, but those two files are the sources of truth.
  2. Make sure the module names in your package are globally unique by searching for them on Pursuit. Unfortunately this is a requirement with the current technology. However, finding a module with the same name on Pursuit doesn't mean all hope is lost. Module names only have to be unique in the package set. So you can use the information in step 6 to see if your module name is actually taken. There is a good number of package
@Kestrer
Kestrer / how-to-write-hygienic-macros.md
Created October 17, 2020 05:35
A guide on how to write hygienic Rust macros

How to Write Hygienic Rust Macros

Macro hygiene is the concept of macros that work in all contexts; they don't affect and aren't affected by anything around them. Ideally all macros would be fully hygienic, but there are lots of pitfalls and traps that make it all too easy to accidentally write unhygienic macros. This guide attempts to provide a comprehensive resource for writing the most hygienic macros.

Understanding the Module System

First, a little aside on the details of Rust's module system, and specifically paths; it is