Skip to content

Instantly share code, notes, and snippets.

View chinoto's full-sized avatar

Damian Pound chinoto

View GitHub Profile
wasm-pack does a bit more than just build (npm stuff), but that's really all most people care about (myself included). The relevant pieces can be traced from the build command:
https://github.com/rustwasm/wasm-pack/blob/master/src/command/build.rs#L264
Important points are the calls to step_build_wasm, step_install_wasm_bindgen, step_run_wasm_bindgen, and step_run_wasm_opt, the other 4 steps are just fluff for making a node module/npm package (the package.json allows `import {my_func} from './pkg';` instead of './pkg/${crate_name}.js'...).
step_build_wasm is simply `cargo build --lib --release --target wasm32-unknown-unknown`
https://github.com/rustwasm/wasm-pack/blob/master/src/build/mod.rs#L76
step_install_wasm_bindgen is what justifies wasm-pack's existence because whatever version of wasm-bindgen your crate depends on requires that you use a corresponding version of wasm-bindgen-cli to generate the bindings correctly. It will either use an existing install, download a precompiled version, or run `cargo
@chinoto
chinoto / DamiansDaily.MyD
Last active September 19, 2020 00:30
MyDefrag script based on SystemDiskDaily. Uses rough sorting for NtfsSystemFiles and directories, puts files less than 128KB near the start, places files less than 50MB after that, and any larger files only have fragments smaller than 50MB combined. Hopefully this is all relatively quick to run and offers a practical benefit on rotational media.
# MyDefrag v4.0 default script: System Disk Daily
#
# This script is part of the standard MyDefrag distribution.
Title("Damian's Daily")
Description("System Disk Daily description") // See the "Settings.MyD" file.
WindowSize(minimized)
#WhenFinished(exit)
const fs = require('fs-extra');
const {gzip,ungzip:gunzip} = require('node-gzip');
//const decoder = new require('string_decoder').StringDecoder('utf8');
//const {toByteArray:b64dec,fromByteArray:b64enc} = require('base64-js');
//const {encode:yEnc,decode:yDec} = require('yenc-stream');
const qrI = require('qr-image');
//const qrC = require('qrcode');
async function encoder(jsonStr) {
//let jsonStr=await fs.readFile('/home/damian/Downloads/F8KKsSyF.txt','utf-8');
@chinoto
chinoto / promise_variations.js
Created July 18, 2018 16:05
Demonstrating different ways of using promises with(out) async/await that are dependent on multiple promises
const sleep=(fn,ms)=>new Promise(r=>setTimeout(()=>r(fn()),ms));
const init=Date.now();
const log=(y)=>console.log((Date.now()-init)+' '+y);
//7: Awaiting on required values immediately. Very slow.
(async () => {
const x=await sleep(()=>1,100);
const a=await sleep(()=>3,200);
const b=await sleep(()=>4,300);
@chinoto
chinoto / myapp.js
Last active September 30, 2016 16:27 — forked from mikeymop/landing.js
var
tabris=require('tabris')
,page=new tabris.Page({
topLevel:true,
title:"myapp"
})
,pain=0
,grumpy;
new tabris.Button({