Skip to content

Instantly share code, notes, and snippets.

const childProcess = require('child_process');
childProcess.exec(`start http://localhost:${env.port}`);
### macOS Catalina: “App is damaged and can't be opened. You should move it to the trash.”
```
sudo xattr -rd com.apple.quarantine '/Applications/Navicat Premium.app'
```
const requestAnimFrame = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
return window.setTimeout(callback, 1000 / 60, (new Date).getTime())
};
})();
const cancelAnimFrame = function() {
return window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || function(id) {
clearTimeout(id);
};
}();
document.body.addEventListener('lazyImg', function(e) {
loadImgs(e.detail.container);
}, false);
document.body.dispatchEvent(new CustomEvent('lazyImg', {
detail: {
container: document.querySelector('.dropdown'),
force: true
}
}));
// 方案一: cookie-parser 中间件
// server.js
const cookieParser = require('cookie-parser');
const server = express();
server.use(cookieParser());
// 方案二:next-cookies
// pages/_app.js
import nextCookies from 'next-cookies';
MyApp.getInitialProps = async (appContext) => {
function getClearUrl(url) {
if (url.includes('?') || url.includes('#')) {
return (url.match(/^.*?(?=[?|#])/))[0];
} else {
return url;
}
}
function getSearch(url: string): string {
let search: string = '';
function downloadFileAsync(url, dest) {
return new Promise((resolve, reject) => {
const file = fs.createWriteStream(dest);
http.get(url, (res) => {
if (res.statusCode !== 200) {
reject(response.statusCode);
return;
}
@avaforvr
avaforvr / nrm
Created August 31, 2020 09:58
[nrm] #node
nrm 是一个 npm 源管理器,允许你快速地在 npm源间切换。
## 安装:
```shell
npm install -g nrm
```
## 使用
### 查看可选源(带*号即为当前使用源)
```shell
@avaforvr
avaforvr / Stylish
Last active November 4, 2020 09:17
/*fixed元素*/
.is-fixed {
position: static !important;
display:none;
}
/*专栏页头*/
.ColumnPageHeader-Wrapper {
display:none;
}
/*头部logo*/
const a = document.createElement('a');
a.setAttribute('href', 'https://www.baidu.com');
a.setAttribute('target', '_blank');
document.body.appendChild(a);
a.click();
a.parentNode && a.parentNode.removeChild(a);