Skip to content

Instantly share code, notes, and snippets.

View munrocket's full-sized avatar

munrocket

View GitHub Profile
@munrocket
munrocket / ccxt.mini.js
Created September 25, 2018 16:28
Minimal version of CCXT library with only 11 stock exchanges
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/* A entry point for the browser bundle version. This gets compiled by:
browserify --debug ./ccxt.browser.js > ./build/ccxt.browser.js
*/
window.ccxt = require ('./ccxt')
},{"./ccxt":2}],2:[function(require,module,exports){
"use strict";
// This simple snippet is a good start for FMA emulation in javascript.
// It pass a LOT of accuracy tests but can't handle cases with overflows and odd rounding
// IEEE compliant version is developed here: https://github.com/munsocket/proposal-fma/
export function fma(a, b, c) {
let LO;
function twoSum(a, b) {
let s = a + b;
let a1 = s - b;
@munrocket
munrocket / ios-web-testing.md
Last active October 23, 2022 19:30
Linux/Windows iOS testing

Console On Screen Universal Solution

const scrConsole = document.createElement('div');
scrConsole.id = 'screenConsole';
scrConsole.style.position = 'absolute';
scrConsole.style.zIndex = 9e9;
scrConsole.style.bottom = '5px';
scrConsole.style.left = '5px';
scrConsole.style.color = 'white'; 
scrConsole.style.fontSize = '.8em'; 
@munrocket
munrocket / shadertoy_exporter.js
Last active November 14, 2023 18:51
How to record cycled video from shadertoy
// copy paste this in console
function shader_exporter(duration, width, heigth, paused) {
document.getElementById('demogl').style.width = width + 'px';
document.getElementById('demogl').style.height = heigth + 'px';
document.getElementById('myResetButton').click();
document.getElementById('myRecord').click();
if (paused) document.getElementById('myPauseButton').click();
let t0 = performance.now();
function loop(){
if (performance.now() - t0 > duration * 1000) {
@munrocket
munrocket / chrome.md
Last active February 14, 2024 04:30
Chrome Canary with WebGPU (for macos or linux)
@munrocket
munrocket / webm_conversion.md
Last active March 4, 2024 01:37
webm2gif converter for shadertoy

N png -> mp4

ffmpeg -r 30 -i "img%02d.png" -pix_fmt yuv420p -movflags +faststart perfectloop.mp4

trim first 5 second

ffmpeg -ss 00:00:05 -t 00:00:10 -i 1.mov 2.mov
@munrocket
munrocket / wgsl_3d_sdf.md
Last active April 24, 2024 00:45
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_2d_sdf.md
Last active May 3, 2024 13:49
WGSL 2D SDF Primitives

WGSL 2D SDF Primitives

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

Circle - exact

fn sdCircle(p: vec2f, r: f32) -> f32 {
  return length(p) - r;
}
@munrocket
munrocket / wgsl_noise.md
Last active May 5, 2024 21:19
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;