Skip to content

Instantly share code, notes, and snippets.

View MaxGraey's full-sized avatar

Max Graey MaxGraey

View GitHub Profile
const isOrdered = arr => !arr.some((v, i) => v == arr[i + 1]);
function swap(alphabets, idx1, idx2) {
var t = alphabets[idx1];
alphabets[idx1] = alphabets[idx2];
alphabets[idx2] = t;
return alphabets;
}
function permute(alphabets, startIndex = 0, endIndex = alphabets.length - 1) {
if (startIndex !== endIndex) {
@MaxGraey
MaxGraey / Wasm-FAQ-2019.md
Last active January 19, 2024 22:26
WebAssembly FAQ для телеграм сообщества WebAssembly_ru

Введение

Данный FAQ был специально создан для телеграм сообщества https://t.me/WebAssembly_ru.

Он базируется на статье от Andre Weissflog, но так же содержит множество моих дополнений и мыслей, которые могут быть уже не слишком актуальны на момент прочтения. Прошу это учитывать.

0. Какие цели у WebAssembly?

@MaxGraey
MaxGraey / rotate-v2.ts
Created January 26, 2019 19:10
squoosh rotate v2
export function rotate(inputWidth: i32, inputHeight: i32, rotate: i32): void {
const bpp = 4;
let offset = inputWidth * inputHeight * bpp;
// In the straight-copy case, d1 is x, d2 is y.
// x starts at 0 and increases.
// y starts at 0 and increases.
let d1Start: i32;
let d1Limit: i32;
let d1Multiplier: i32;
@MaxGraey
MaxGraey / rotate.ts
Last active January 26, 2019 18:05
rotate image for squoosh
export function rotate(inputWidth: i32, inputHeight: i32, rotate: i32): void {
const bpp = 4;
let offset = inputWidth * inputHeight * bpp;
let i = 0;
// In the straight-copy case, d1 is x, d2 is y.
// x starts at 0 and increases.
// y starts at 0 and increases.
let d1Start: i32;
let d1Limit: i32;
@MaxGraey
MaxGraey / reverse-string.js
Last active November 29, 2018 10:35
Unicode aware reverse string Benchmarks
'use strict';
// run:
// node --expose-gc reverse-string.js
/*
node v11.3.0, MacBook Late 2013
Bench results:
[Naive reverse string]
@MaxGraey
MaxGraey / as-status.md
Last active November 9, 2018 20:13
AssemblyScript Std Status

Globals/Numbers 🚧

  • EPSILON
  • MIN_VALUE
  • MAX_VALUE
  • MIN_POSITIVE_VALUE (non standard)
  • MIN_SAFE_INTEGER
  • MAX_SAFE_INTEGER
  • NaN
  • NEGATIVE_INFINITY
@MaxGraey
MaxGraey / Funding.md
Created October 30, 2018 00:26
Funding
@MaxGraey
MaxGraey / index.js
Last active December 14, 2020 15:37
Ramda vs RxJS vs JS lambda calculus vs JS functional vs JS loop
/*
Test environment:
- node.js 10.5.0
- macOS 10.13.5
- MacBook Pro Late 2013
- Ramda 0.25.0
- RxJS 6.2.1
Results (Babel transpiled):

Структура кода компонента

Последовательно, согласно нумерации.

\n - перенос строки

  1. import * as React from 'react'
  2. Импорты из сторонних библиотек\n
  3. Локальные импорты по абсолютным путям
@MaxGraey
MaxGraey / lib.rs
Last active April 17, 2018 14:36
Shrink Rust wasm size
#![feature(core_intrinsics, lang_items)]
#![no_main]
#![no_std]
#[lang = "panic_fmt"]
extern "C" fn panic_fmt(_args: ::core::fmt::Arguments, _file: &'static str, _line: u32) -> ! {
use core::intrinsics;
unsafe {
intrinsics::abort();
}