Skip to content

Instantly share code, notes, and snippets.

View shhider's full-sized avatar

Shi Haohong shhider

  • DingTalk Docs / 钉钉文档
  • Hangzhou / 杭州
View GitHub Profile
@shhider
shhider / esm-package.md
Created June 22, 2022 08:32 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from 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.
// Copyright (c) 2012 Sutoiku, Inc.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE O
@shhider
shhider / IRR.js
Created October 20, 2020 12:06 — forked from ghalimi/IRR.js
IRR Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
// Some algorithms have been ported from Apache OpenOffice:
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
@shhider
shhider / what-forces-layout.md
Created December 25, 2019 02:19 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@shhider
shhider / basic.md
Last active December 31, 2020 03:15 — forked from tzutalin/ffmpeg.md
[ffmpeg Lite Doc] #ffmpeg #litedoc

video <=> gif

# Video => GIF
ffmpeg -i xxx.mov -pix_fmt rgb24 xxx.gif

# Gif => Video
ffmpeg -i input.gif -b:v 0 -crf 40 -vf scale=600:-1 output.mp4
@shhider
shhider / toUnicode.js
Last active July 29, 2021 08:52 — forked from littlee/toUnicode.js
[JavaScript convert string to unicode format] #tounicode
const toUnicode = (str) => str.split('').map((char) => {
const temp = char.charCodeAt(0).toString(16).toUpperCase();
if (temp.length > 2) {
return '\\u' + temp;
}
return char;
}).join('');
console.log(toUnicode('转换成 Unicode'));
@shhider
shhider / po2json.js
Created August 16, 2017 07:25 — forked from zaach/po2json.js
PO parser from http://jsgettext.berlios.de/lib/Gettext.js adapted for Node.js and modified to be more like po2json.pl
#!/usr/bin/env node
/*
PO parser from http://jsgettext.berlios.de/lib/Gettext.js
adapted for Node.js and modified to be more like po2json.pl
- Zach Carter <zcarter@cse.usf.edu>
*/
/*
Pure Javascript implementation of Uniforum message translation.
library(tidyverse)
library(gganimate)
NUMPLAYERS = 45
ROUNDS = 5000
INITWEALTH = 45
#initialize the bank
#columns wealths of the NUMPLAYERS players
#rows show wealths of each of the ROUNDS ticks of the clocks