Skip to content

Instantly share code, notes, and snippets.

View run.ts
import { PrismaClient } from "@prisma/client";
import { minifyCode, expandCode, calcHash } from "../src/lib/minifier";
import { v4 as uuid } from "uuid";
async function createSnippet(authorId: string, files: { [k: string]: string }) {
const snippetId = uuid();
return await prisma.snippet.create({
data: {
id: snippetId,
title: "test-snippet",
View log
prisma:info Starting a sqlite pool with 17 connections.
prisma:info Started http server on http+unix:///private/tmp/prisma-789c342c854e2e3b622ab519.sock
prisma:query BEGIN
prisma:query SELECT `dev`.`User`.`id` FROM `dev`.`User` WHERE `dev`.`User`.`name` = ? LIMIT ? OFFSET ?
prisma:query SELECT `dev`.`User`.`id` FROM `dev`.`User` WHERE `dev`.`User`.`name` = ?
prisma:query UPDATE `dev`.`User` SET `name` = ? WHERE `dev`.`User`.`id` IN (?)
prisma:query SELECT `dev`.`User`.`id`, `dev`.`User`.`name` FROM `dev`.`User` WHERE `dev`.`User`.`id` = ? LIMIT ? OFFSET ?
prisma:query COMMIT
prisma:query BEGIN
prisma:query SELECT `dev`.`User`.`id` FROM `dev`.`User` WHERE `dev`.`User`.`id` = ? LIMIT ? OFFSET ?
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