Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

郭宇翔 yourtion

🎯
Focusing
View GitHub Profile
View my-mocha-reporter.js
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");
@yourtion
yourtion / backup_mysql.sh
Created Jun 20, 2019
备份MySQL并删除旧数据
View backup_mysql.sh
#!/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 "备份数据完成";
@yourtion
yourtion / fmp-timing.js
Created Nov 26, 2018
前端监控实践——FMP的智能获取算法 https://segmentfault.com/a/1190000017092752
View fmp-timing.js
// 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,
@yourtion
yourtion / Let'sEncrypt.sh
Last active Oct 4, 2018
Docker+Nginx+Let'sEncrypt
View Let'sEncrypt.sh
#!/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
View mount_ntfs.sh
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、解挂载然后重新挂载
# 解挂载
@yourtion
yourtion / master.js
Created Feb 2, 2018
Node.js Simple IPC Timmer Demo
View master.js
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');
@yourtion
yourtion / proxy.conf
Created Jan 8, 2018
NginxProxyConfig
View proxy.conf
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;
View template-render.js
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));
View vscode.js
// 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,
@yourtion
yourtion / unpack_plist.py
Last active Oct 19, 2017
unpack plist image
View unpack_plist.py
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os,sys
from xml.etree import ElementTree
from PIL import Image
import logging
DEBUG = False
# 设置默认的level为DEBUG