Skip to content

Instantly share code, notes, and snippets.

@fhefh2015
fhefh2015 / check_mobile.js
Last active Oct 10, 2020
2020最新移动 联通 电信号码正则
View check_mobile.js
//https://juejin.im/post/6844904109800161294
//2020最新移动,联通,电信号码正则
//由于新增了197、199、190等新号段,最新移动,电信,联通号段如下: 移动号段: 134、135、136、137、138、139、147、150、151、152、157、158、159、172、178、182、183、184、187、188、195 、198、197
//联通号段: 130、131、132、145、146、155、156、166、170、171、175、176、185、186、196
//电信号段: 133、141、149、153、173、174、177、179、180、181、189、191、193、199、190
//手机号码验证(号码验证没有特别严谨):
function isMobile(s) {
let reg = /^1[3|4|5|6|7|8|9][0-9]{9}$/; //验证规则
let flag = reg.test(s); //true
@fhefh2015
fhefh2015 / screen.js
Created Oct 10, 2020
获取屏幕宽度高度
View screen.js
function get_screen_size() {
return {
width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
height: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
};
}
@fhefh2015
fhefh2015 / launch.json
Last active Sep 27, 2020
Nest.js VSCode Chrome Debug
View launch.json
//.vscode/launch.json
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
@fhefh2015
fhefh2015 / getYearWeek.js
Created Sep 26, 2020
JS将日期转换成当年的周数(work week)
View getYearWeek.js
// 时间格式 yyyy-MM-dd
function getYearWeek(date) {
var date = new Date(date);
var date2 = new Date(date.getFullYear(), 0, 1);
var day1 = date.getDay();
if (day1 == 0) day1 = 7;
var day2 = date2.getDay();
if (day2 == 0) day2 = 7;
d = Math.round((date.getTime() - date2.getTime() + (day2 - day1) * (24 * 60 * 60 * 1000)) / 86400000);
return Math.ceil(d / 7) + 1;
@fhefh2015
fhefh2015 / iterm2-solarized.md
Created Jul 19, 2020 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)
View iterm2-solarized.md

Default

Default

Powerlevel10k

Powerlevel10k

@fhefh2015
fhefh2015 / utils.js
Created May 22, 2020
vue2 broadcast和dispatch
View utils.js
/*
broadcast 事件广播
@param {componentName} 组件名称
@param {eventName} 事件名
@param {params} 参数
遍历寻找所有子孙组件,假如子孙组件和componentName组件名称相同的话,则触发$emit的事件方法,数据为 params.
如果没有找到 则使用递归的方式 继续查找孙组件,直到找到为止,否则继续递归查找,直到找到最后一个都没有找到为止。
*/
function broadcast(componentName, eventName, params) {
this.$children.forEach(child => {
@fhefh2015
fhefh2015 / oss.sh
Created May 16, 2020
刷流量脚本
View oss.sh
echo "while [ 1 ]" > _ins.sh
echo "do" >> _ins.sh
echo "wget -q -t0 -O /dev/null https://alios.dd5688.com/signapp/5dc2b45f6407b/38d8ef0bf89bdc80b5ce19bca22db44498752716.ipa" >> _ins.sh
echo "done" >> _ins.sh
for i in `seq 1 20`
do
nohup bash _ins.sh > /dev/null 2>&1 &
echo "thread $i start!"
done
@fhefh2015
fhefh2015 / tinc-install.sh
Created Apr 25, 2020 — forked from jpillora/tinc-install.sh
Install and run tinc-1.1pre11 on Raspberry Pi 2 (Raspberrian)
View tinc-install.sh
# install tinc
apt-get update && echo "===> update deps" &&
apt-get install -y make libssl-dev zlib1g-dev liblzo2-dev libreadline-dev libncurses5-dev && echo "===> got deps" &&
curl http://www.tinc-vpn.org/packages/tinc-1.1pre11.tar.gz | tar xzvf - && echo "===> got tinc src" &&
cd tinc-1.1pre11 &&
./configure && echo "===> configured tinc" &&
make &&
make install && echo "===> installed tinc" &&
tinc --version # tinc version 1.1pre11 (built Nov 12 2015 16:25:28, protocol 17.4)
View ecdh.go
// ecdh implements a simple way to perform Diffie-Hellman Key Exchange using
// Curve25519 on the command line.
//
// NOTE: this is a toy for fun. Don't use it.
//
// See https://godoc.org/golang.org/x/crypto/curve25519 and
// https://cr.yp.to/ecdh.html for more info.
//
// The final shared secret given is the raw shared secret bytes from DH and is
// not typically suitable for direct use as an encryption key as it can leak
You can’t perform that action at this time.