Skip to content

Instantly share code, notes, and snippets.

View learn-redux-toolkit.ts
import {
configureStore,
createSlice,
createAsyncThunk,
PayloadAction,
getDefaultMiddleware,
} from "@reduxjs/toolkit";
import { useDispatch, useSelector } from "react-redux";
import logger from "redux-logger";
View pages_api_[b64].ts
/* How to use
import { getTypes } from "../api/types"
const result = await getTypes("https://esm.sh/react");
if (result.hasTypes) {
console.log(result.typesCode);
}
*/
import { NextApiHandler } from "next";
import fetch from "isomorphic-unfetch";
View react-vue-interop.ts
import React, { useEffect, useRef } from 'react';
import ReactDOM from 'react-dom';
import { defineComponent, onMounted, onUnmounted } from '@vue/composition-api';
import Vue from 'vue';
export function vuenize(component: React.ComponentType, parentData: Vue.VNodeData = {}) {
const randomKey = 'key_' + Math.random();
let mountedNode: any = null;
return defineComponent({
name: component.name || component.displayName,
@mizchi
mizchi / benchmark.js
Last active Sep 30, 2020
JSON, fast-json-stringify, superjson benchmark
View benchmark.js
// original: https://github.com/blitz-js/superjson/blob/main/benchmark.js
const Benchmark = require('benchmark');
const SuperJSON = require('./dist/').default;
const fastJson = require('fast-json-stringify');
const stringify = fastJson({
type: 'object',
required: ['a'],
additionalProperties: false,
properties: {
View dig-ifttt-before-after-on-cloudfront-error.log
$ dig ifttt.com
; <<>> DiG 9.10.6 <<>> ifttt.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32324
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 4, ADDITIONAL: 9
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
View games0.json
{"title":"Mayo","playerName":"Mizchi","townName":"Littlewood","mapString":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
View simple-single-spa-how-to-use.js
import { registerApplication, start, navigateToUrl } from 'single-spa';
import { h, render, Fragment } from 'preact';
// navigateToUrl を発行するだけの x-link 要素
customElements.define("x-link", class extends HTMLElement {
connectedCallback() {
this.style.textDecoration = "underline";
this.style.color = "blue";
this.addEventListener("click", (ev) => {
ev.preventDefault();
View tf.es.js
This file has been truncated, but you can view the full file.
/* prebuilt es */
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
View tf-core.es.js
This file has been truncated, but you can view the full file.
/* build tfjs-core for esm */
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
View index.vue
<template>
<div>
<Sub message="hello" />
</div>
</template>
<script lang="ts">
import {
defineComponent,
reactive,