Skip to content

Instantly share code, notes, and snippets.

View GitaiQAQ's full-sized avatar
🏠
Working for home

Gitai GitaiQAQ

🏠
Working for home
View GitHub Profile
import React, { Component, useCallback, useRef, useState } from 'react'
import { View, Text, Button } from '@tarojs/components'
import VirtualList from '@tarojs/components/virtual-list'

function buildData(offset = 0) {
  return Array(100)
    .fill(0)
    .map((_, i) => i + offset)
}
import byteSize from 'byte-size';
const manifest = [];
process.on('beforeExit', () => {
console.table(manifest);
});
export default () => ({
name: 'Size',
{
name: 'InlineScriptHTMLRender',
async generateBundle(_, bundles, isWrite) {
if (isWrite) {
return new Promise((resolve) => {
Object.values(bundles).map((bundle) => {
Object.keys(bundles).map(key => delete bundles[key]);
if (bundle.name === 'bootloader') {
renderFile('src/index.ejs', {
inlineScript: bundle.code,
import replace from '@rollup/plugin-replace';
let manifest = {};
export const replaceManifest = () => {
return replace({
__MANIFEST__: () => JSON.stringify(manifest),
});
};
export const doThis = count => Array.prototype.map.bind(Array.from({ length: count }));
export const Timeout = (timeout, promise?: Promise<any>) =>
new Promise((resolve, reject) => {
const timer = setTimeout(() => {
reject(new Error(`Timeout(${timeout})`));
}, timeout);
// 如果完成了得清理
const clear = () => clearTimeout(timer);
promise.then(clear, clear);
interface Test<T> {
g?: Test<T>;
}
function mixinPerson<T extends Constructor<{}>>(Base: T) {
return class Base {
constructor(public name: string) { }
}
#!/bin/ts-node
const SymbolCache = Symbol.for("cache");
let miss = 0;
function computed(...args) {
const _cache = {};
return function (
target,
propertyKey: string,
@GitaiQAQ
GitaiQAQ / .u.js
Last active February 28, 2022 15:52
A tiny unit test module or function powered by ES6/Promise.
#!/usr/bin/env node
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
// Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
@GitaiQAQ
GitaiQAQ / main.rs
Last active February 8, 2019 09:01
假装写了个 v-dom,实际上只有最简单的 diff
#![allow(dead_code)]
use std::collections::HashMap;
use std::collections::HashSet;
trait Renderable {
fn render(&mut self) {
unimplemented!()
}
}
@GitaiQAQ
GitaiQAQ / AutoACE.js
Created January 9, 2019 15:13
自动挂载 ACE 替换普通文本域。
(function() {
'use strict';
jQuery(document).ready(function() {
let Language = {
"C": "c_cpp",
"C++": "c_cpp",
"Java": "java",
"JavaScript": "javascript",
"Python": "python"
};