Skip to content

Instantly share code, notes, and snippets.

@uupaa
uupaa / TS2488.md
Last active May 9, 2020
How to fix and fine tune TypeScript compilation errors: TS2488, TS7053
View TS2488.md

Before

  static split_semver(s:string) {
    // @arg String - "version-99.88.77"
    // @ret NumberArray - [ 99. 88, 77 ]
    try {
      const [, major, minor, patch] = Array.from(s.match(/(\d{1,2})\.(\d{1,2})\.(\d{1,2})/)); // [, "99", "88", 77" ]
      return [
        parseInt(major, 10),
View ngconf at 2020
#user nobody;
#user nginx;
worker_processes 2;
# error_log logs/error.log;
# error_log logs/error.log notice;
# error_log logs/error.log info;
#pid logs/nginx.pid;
@uupaa
uupaa / Mac VSCode: How to plantUML preview within markdown.md
Last active Dec 6, 2019
Mac VSCode: How to plantUML preview within markdown
View Mac VSCode: How to plantUML preview within markdown.md

Mac VSCode: How to plantUML preview within markdown.

Prepare

$ mkdir -p ~/java
$ cd ~/java
$ brew install maven
$ git clone https://github.com/plantuml/plantuml-server.git
$ cd plantuml-server 
@uupaa
uupaa / PlantUML demo.md
Last active Oct 12, 2018
PlantUML demo
View PlantUML demo.md
@uupaa
uupaa / WebWorker.make.by.a.string.html
Last active Aug 27, 2018
WebWorker make by a string.
View WebWorker.make.by.a.string.html
<script>
const WORKER_RESOURCE = `
self.onmessage = (event) => {
debugger;
postMessage(event.data + " worker"); // hello worker
}`;
const blob = new Blob( [ WORKER_RESOURCE ], { type: "application/javascript" } );
const blobURL = URL.createObjectURL(blob); // -> URL.revokeObjectURL(blobURL);
const worker = new Worker(blobURL);
@uupaa
uupaa / offscreen_canvas_image_decode_and_shapre_detection.md
Last active Feb 18, 2020
OffscreenCanvas, image.decode(), createImageBitmap(), WebWorker, transferToImageBitmap(), transferFromImageBitmap(), zero copy, Shape Detection API
View offscreen_canvas_image_decode_and_shapre_detection.md

個人的に 2012年頃(?)から渇望していた OffscreenCanvas と一連のAPIがついに Chrome に実装されました。

このエントリでは、UIの応答性を改善する OffscreenCanvas の仕組みと、 OffscreenCanvas を有効活用するための周辺APIについて、概要とサンプルコードを紹介していきます。

ネタ元はこちらです https://www.youtube.com/watch?time_continue=159&v=wkDd-x0EkFU

既存の <canvas> は DOM と強く結びついている事から UI Thread(= ブラウザにおける Main Thread) の影響をうけますし、反対に影響を与えてしまいます。

影響: UI Thread で重い処理を走らせてしまうと、アニメーションのフレームスキップが発生し、なめらかにスクロールしなくなり、UIの応答性が悪くなるなどの弊害が発生してしまいます。

@uupaa
uupaa / a.js
Created Jul 4, 2018
convert Array#forEach(async/await) to await Promise.all(Arraymap(async/await))
View a.js
/*
json.forEach(async (raw) => {
const segment = new Segment(this._net);
await segment.init(raw);
this._hash[raw.id] = segment;
this._list.push(segment);
});
*/
await Promise.all( json.map(async (raw, index) => {
const segment = new Segment(this._net);
View a.js
export class Alert {
constructor(msg) {
alert(msg);
}
}
@uupaa
uupaa / code.md
Last active Jan 17, 2018
Custom Components + Google Maps API does not work well.
View code.md
<!DOCTYPE html><head><meta charset="utf-8"><title>MapView</title>
<style>html,body,map-view{height:100%;margin:10px}</style>
</head><body>
  <map-view type="google" key="..."></map-view>
  <script type="module" src="./app.js" charset="uft-8"></script>
</body>
</html>
@uupaa
uupaa / rust.md
Last active Dec 6, 2017
rust memo
View rust.md

Rust

Install

stable build:

curl https://sh.rustup.rs -sSf | sh
source ~/.zprofile    # in zsh
rustc --version
You can’t perform that action at this time.