This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed 's/\x1b\[[0-9;]*m//g' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Mocha = require("mocha"); | |
var constants = Mocha.Runner.constants; | |
var EVENT_RUN_END = constants.EVENT_RUN_END; | |
var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN; | |
var EVENT_SUITE_END = constants.EVENT_SUITE_END; | |
var EVENT_TEST_PASS = constants.EVENT_TEST_PASS; | |
const t = new Mocha(); | |
t.addFile("./all.spec.js"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
baseDir="/data/backup/mysql"; | |
userName="root" | |
password="123456" | |
host="127.0.0.1" | |
backup() { | |
echo "开始备份数据库: $1" | |
mysqldump -h$host -u$userName -p$password --default-character-set=utf8 $1 | gzip > $baseDir/$1_dump_$(date +%Y%m%d_%H%M%S).sql.tar.gz | |
echo "备份数据完成"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/qbright/fmp-timing/blob/master/src/fmp-timing.js | |
const START_TIME = performance && performance.timing.responseEnd; | |
const IGNORE_TAG_SET = ["SCRIPT", "STYLE", "META", "HEAD", "LINK"]; | |
const TAG_WEIGHT_MAP = { | |
SVG: 2, | |
IMG: 2, | |
CANVAS: 4, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# https://ruby-china.org/topics/31942 | |
# Install | |
yum install -y epel-release | |
yum install -y certbot | |
# 使用方法:certbot certonly --webroot -w [Web站点目录] -d [站点域名] -m [联系人email地址] --agree-tos | |
certbot certonly --webroot -w /opt/www/demo.mydomain.com -d demo.mydomain.com -m myname@gmail.com --agree-tos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1、列出所有的外接存储设备 | |
$ diskutil list external | |
/dev/disk2 (external, physical): | |
#: TYPE NAME SIZE IDENTIFIER | |
0: FDisk_partition_scheme *15.9 GB disk2 | |
1: Windows_NTFS DBand 15.9 GB disk2s1 | |
2、解挂载然后重新挂载 | |
# 解挂载 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { fork } = require('child_process'); | |
const crypto = require('crypto'); | |
const timmer = fork('./timmer.js'); | |
let lastTime = Date.now(); | |
let localTime = Date.now(); | |
timmer.on('message', (m) => { | |
console.log('remote: ', m.time - lastTime - 1000 + 'ms'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy_redirect off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
client_max_body_size 10m; | |
client_body_buffer_size 128k; | |
proxy_connect_timeout 90; | |
proxy_send_timeout 90; | |
proxy_read_timeout 90; | |
proxy_buffer_size 4k; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function render(template, context) { | |
return template.replace(/\{\{(.*?)\}\}/g, (match, key) => context[key]); | |
} | |
const template = "{{name}}很厉name害,才{{age}}岁"; | |
const context = { name: "yourtion", age: "15" }; | |
console.log(render(template, context)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place your settings in this file to overwrite the default settings | |
{ | |
"editor.fontFamily": "Hack", | |
"templates.Author": "Yourtion Guo <yourtion@gmail.com>", | |
// Editor | |
"editor.tabSize": 2, | |
"editor.insertSpaces":true, | |
// "editor.formatOnPaste": true, | |
"editor.quickSuggestions": { | |
"other": true, |
NewerOlder