This file contains hidden or 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 today = new Date().toJSON().slice(0, 10).replace(/-/g, '') | |
| // 对象数组除重 | |
| arr.filter((item, index) => arr.findIndex((i) => item.id === i.id) === index) | |
| const combine = (arr) => { | |
| let result = [] | |
| let go = (currentArr) => { | |
| if (currentArr.length === arr.length) { | |
| result.push(currentArr) |
This file contains hidden or 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
| # This hosts file is brought to you by Dan Pollock and can be found at | |
| # http://someonewhocares.org/hosts/ | |
| # You are free to copy and distribute this file for non-commercial uses, | |
| # as long the original URL and attribution is included. | |
| #<localhost> | |
| 127.0.0.1 localhost | |
| 127.0.0.1 localhost.localdomain | |
| 255.255.255.255 broadcasthost | |
| ::1 localhost |
This file contains hidden or 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
| /** | |
| * 返回数组数组的标准偏差。 | |
| * | |
| * 使用 Array.reduce() 来计算均值,方差已经值的方差之和,方差的值,然后确定标准偏差。 | |
| * 您可以省略第二个参数来获取样本标准偏差,或将其设置为 true 以获得总体标准偏差。 | |
| */ | |
| const standardDeviation = (arr, usePopulation = false) => { | |
| const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length; | |
| return Math.sqrt( | |
| arr.reduce((acc, val) => acc.concat((val - mean) ** 2), []).reduce((acc, val) => acc + val, 0) / |
This file contains hidden or 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
| #!/usr/bin/python | |
| # coding=utf-8 | |
| # TF-IDF提取文本关键词 | |
| # http://scikit-learn.org/stable/modules/feature_extraction.html#tfidf-term-weighting | |
| import sys | |
| import os | |
| from config_ch import * | |
| import chardet | |
| import numpy as np |
This file contains hidden or 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 | |
| # curl "https://gist.github.com/weberliu/c3e12e4c09f27c9ef3363314f2401859/centos-ss" | /bin/sh | |
| #################################### | |
| install_home="/etc/shadowsocks/" # 安装目录 | |
| port=30443; # 端口 | |
| password="ladders" # 密码 | |
| encrypt="chacha20-ietf-poly1305" # 加密方式 | |
| #################################### |
This file contains hidden or 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
| /* | |
| USAGE: | |
| import njk from './nunjucks'; | |
| // Templating - Must be used before any router | |
| app.use(njk(path.join(__dirname, 'views'), { | |
| extname: '.njk', | |
| noCache: process.env.NODE_ENV !== 'production', | |
| throwOnUndefined: true, | |
| filters: { | |
| json: function (str) { |
This file contains hidden or 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
| import Component from '../component' | |
| export default { | |
| /** | |
| * 默认参数 | |
| */ | |
| setDefaults () { | |
| return { | |
| title: undefined, | |
| content: undefined, |
This file contains hidden or 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 arrDiff (a1, a2) { | |
| var a = [] | |
| var diff = [] | |
| for (var i = 0; i < a1.length; i++) { | |
| a[a1[i]] = true | |
| } | |
| for (var i = 0; i < a2.length; i++) { | |
| if (a[a2[i]]) { |
This file contains hidden or 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://stackoverflow.com/questions/21961839/simulation-background-size-cover-in-canvas/21961894#21961894 | |
| * | |
| * By Ken Fyrstenberg Nilsen | |
| * | |
| * drawImageProp(context, image [, x, y, width, height [,offsetX, offsetY]]) | |
| * | |
| * If image and context are only arguments rectangle will equal canvas | |
| */ | |
| function drawImageProp (ctx, img, x, y, w, h, offsetX, offsetY) { |
This file contains hidden or 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
| <!DOCTYPE HTML> | |
| <html> | |
| <head> | |
| <style> | |
| body { | |
| margin: 0px; | |
| padding: 0px; | |
| } | |
| </style> | |
| </head> |
NewerOlder