Skip to content

Instantly share code, notes, and snippets.

View ycjcl868's full-sized avatar
:dependabot:
I may be slow to respond.

Charles ycjcl868

:dependabot:
I may be slow to respond.
View GitHub Profile
@vezaynk
vezaynk / HOC.ts
Created February 1, 2023 23:35
HOC helpers. reduceHOCs and applyHOCs.
interface HOC<T> {
(Component: React.ComponentType<T>): (props: T) => JSX.Element
}
const reduceHOCs = <T>(...hocs: HOC<T>[]): HOC<T> => hocs
.reduce((reduced, next) => (c) => next(reduced(c)));
const applyHOCs = <T>(...hocs: HOC<T>[]) {
const reducedHoc = reduceHOCs(...hocs);
@sxzz
sxzz / QQ-NT-package.json
Last active February 28, 2024 02:43
package.json for QQ-NT
{
"name": "QQ-NT",
"version": "6.8.3-4068",
"private": true,
"description": "QQ-NT",
"productName": "QQ-NT",
"author": {
"name": "Tencent",
"email": "QQ-Team@tencent.com"
},
@gaearon
gaearon / minesweeper.html
Last active October 9, 2023 12:15
minesweeper (incomplete/simplfied). stream: https://www.youtube.com/watch?v=CL01_m50TYY
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div id="canvas"></div>
<button id="restart">Restart</button>
<script src="minesweeper.js"></script>
<style>
* {
@kentcdodds
kentcdodds / session.server.ts
Created November 18, 2021 21:04
Authentication in Remix applications
import * as bcrypt from "bcrypt";
import { createCookieSessionStorage, redirect } from "remix";
import { db } from "./db.server";
export type LoginForm = {
username: string;
password: string;
};
@sindresorhus
sindresorhus / esm-package.md
Last active June 6, 2024 20:54
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@jacob-ebey
jacob-ebey / webpack-access-federated-containers-plugin.js
Created December 8, 2020 05:12
webpack-access-federated-containers-plugin.js
/*
Makes your remote containers low level API accessible via:
import accessFederatedContainer from "access-federated-containers";
accessFederatedContainer("app2")
*/
/** @typedef {import("webpack").Compiler} Compiler */
/** @typedef {import("webpack").Compilation} Compilation */
npm set registry https://r.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # node-gyp 编译依赖的 node 源码镜像
## 以下选择添加
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass # node-sass 二进制包镜像
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
npm set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer 二进制包镜像
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver # operadriver 二进制包镜像
npm set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs # phantomjs 二进制包镜像
@gaearon
gaearon / uselayouteffect-ssr.md
Last active May 16, 2024 14:13
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@luckyadam
luckyadam / Taro IDE 设计.md
Last active June 17, 2022 07:45
Taro IDE 设计

Taro IDE 设计

项目背景

为了提升 Taro 的产品形象,让 Taro 能够为更多层次的人群接受,我们需要将 Taro 包装成一个完整的、专业的平台产品,来降低人们的认知、接入成本,同时,Taro 一直以来都是作为一个免费、开源的框架,但除了框架之外我们还有很多不适合开源的能力沉淀,我们需要一个商业化的版本,来将我们沉淀的服务能力开放出去,在带来收益的同时,为公司打造一个企业级的多端建站工具。

目标

  • 将 Taro 包装成平台化产品,降低认知与接入成本
  • 探索 Taro 商业化模式
@cecilemuller
cecilemuller / 2019-https-localhost.md
Last active June 8, 2024 20:31
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).