Skip to content

Instantly share code, notes, and snippets.

@fhefh2015
fhefh2015 / getYearWeek.js
Created September 26, 2020 08:16
JS将日期转换成当年的周数(work week)
// 时间格式 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 July 19, 2020 13:16 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@fhefh2015
fhefh2015 / utils.js
Created May 22, 2020 03:29
vue2 broadcast和dispatch
/*
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 04:22
刷流量脚本
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 April 25, 2020 08:56 — forked from jpillora/tinc-install.sh
Install and run tinc-1.1pre11 on Raspberry Pi 2 (Raspberrian)
# 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)
@fhefh2015
fhefh2015 / ecdh.go
Created April 23, 2020 02:12 — forked from banks/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
package main

import (
	"crypto/md5"
	//"errors"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
@fhefh2015
fhefh2015 / base64-form-data.js
Created December 26, 2019 03:42 — forked from AshikNesin/base64-form-data.js
Base64 image to multipart/form-data
const base64 = 'data:image/png;base65,....' // Place your base64 url here.
fetch(base64)
.then(res => res.blob())
.then(blob => {
const fd = new FormData();
const file = new File([blob], "filename.jpeg");
fd.append('image', file)
// Let's upload the file
// Don't set contentType manually → https://github.com/github/fetch/issues/505#issuecomment-293064470
@fhefh2015
fhefh2015 / check_baidupan.py
Created December 25, 2019 02:44
百度网盘链接有效性批量测试
import requests
import re
from bs4 import BeautifulSoup
import time
import json
from requests import exceptions
class Baiduyun:
'''
@fhefh2015
fhefh2015 / code.php
Created October 23, 2019 07:03
Discuz!加解密函数
//https://www.debuginn.cn/4084.html
class Demo extends Controller
{
//函数authcode($string, $operation, $key, $expiry)中的$string:字符串,明文或密文;$operation:DECODE表示解密,其它表示加密;$key:密匙;$expiry:密文有效期。
public function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
// 动态密匙长度,相同的明文会生成不同密文就是依靠动态密匙
$ckey_length = 4;
// 密匙
$key = md5($key ? $key : $GLOBALS['discuz_auth_key']);