Skip to content

Instantly share code, notes, and snippets.

Koutaro Chikuba mizchi

Block or report user

Report or block mizchi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pwa-app-install-button.tsx
import React, { useEffect, useState, useCallback } from "react";
let _installPrompt: any;
window.addEventListener("beforeinstallprompt", e => {
e.preventDefault();
_installPrompt = e;
});
function AppInstallButton() {
const [prompt, setInstallPrompt] = useState<any>(_installPrompt);
View native-fs-editor.ts
import "regenerator-runtime/runtime";
const tx = document.createElement("textarea") as HTMLTextAreaElement;
async function writeFile(handler: any, text: string): Promise<void> {
const writer = await handler.createWriter();
await writer.truncate(0);
await writer.write(0, text);
await writer.close();
}
View native-fs-read-example.ts
import "regenerator-runtime/runtime";
const tx = document.createElement("textarea") as HTMLTextAreaElement;
document.body.appendChild(tx);
const btn = document.createElement("button");
btn.textContent = "start";
document.body.appendChild(btn);
btn.addEventListener("click", async (ev: any) => {
// @ts-ignore
const fileHandler = await window.chooseFileSystemEntries();
View Webpack で WebWorker + サードパーティ WebWorker.md
@mizchi
mizchi / webpack.conifg.js
Created Aug 29, 2019
build battel 用の資料
View webpack.conifg.js
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HTMLPlugin = require("html-webpack-plugin");
const WorkerPlugin = require("worker-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const { GenerateSW } = require("workbox-webpack-plugin");
const tsLoader = {
loader: "ts-loader",
options: {
View README.md

slink

Comlink like RPC for socket.io

// server
const handlerMap = {
  async foo(args: { id: string }, socket) {
    return "foo:" + args.id + ":" + socket.id;
  }
View try-tfjs.ts
import "@babel/polyfill";
import * as tf from "@tensorflow/tfjs";
import "@tensorflow/tfjs-node-gpu"; // Intel Cuda の対応OSのみ有効
const fn = (a, b) => {
const n = Math.cos(a * Math.PI * 2) * b + Math.sin(b * Math.PI * 2) * a;
return a > b ? n : -n;
};
function buildModel() {
View e2e_parallel_runner.bash
#!/usr/bin/env bash
# ref. http://fahdshariff.blogspot.com/2014/02/retrying-commands-in-shell-scripts.html
retry() {
local -r -i max_attempts="$1"; shift
local -r cmd="$@"
local -i attempt_num=1
until $cmd
do
if (( attempt_num == max_attempts ))
then
View README.md

Minilink

comlink から proxy やらなんやら抜いたもの。 気が向いたら npm に投げる

使い方

// worker thread
import {expose} from './minilink'
View vue-precompiled-render.ts
import Vue from "vue";
import { createRenderer } from "vue-server-renderer";
import * as vueCompiler from "vue-template-compiler";
const renderer = createRenderer();
const directives = {};
export async function compile(
template: string,
You can’t perform that action at this time.