Skip to content

Instantly share code, notes, and snippets.

@uupaa
uupaa / TS2488.md
Last active May 3, 2023 21:20
How to fix and fine tune TypeScript compilation errors: TS2488, TS7053

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),
@uupaa
uupaa / ngconf at 2020
Created January 11, 2020 12:42
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 June 26, 2024 07:55
Mac VSCode: How to plantUML preview within markdown

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 October 12, 2018 10:59
PlantUML demo
@uupaa
uupaa / WebWorker.make.by.a.string.html
Last active August 27, 2018 00:41
WebWorker make by a string.
<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 August 5, 2022 03:58
OffscreenCanvas, image.decode(), createImageBitmap(), WebWorker, transferToImageBitmap(), transferFromImageBitmap(), zero copy, Shape Detection API

個人的に 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 July 4, 2018 22:59
convert Array#forEach(async/await) to await Promise.all(Arraymap(async/await))
/*
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);
@uupaa
uupaa / a.js
Created June 5, 2018 05:47
test
export class Alert {
constructor(msg) {
alert(msg);
}
}
@uupaa
uupaa / code.md
Last active January 17, 2018 04:59
Custom Components + Google Maps API does not work well.
<!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 December 6, 2017 21:06
rust memo

Rust

Install

stable build:

curl https://sh.rustup.rs -sSf | sh
source ~/.zprofile    # in zsh
rustc --version