Skip to content

Instantly share code, notes, and snippets.

View shuiRong's full-sized avatar
👻
Working

shuirong shuiRong

👻
Working
View GitHub Profile
@shuiRong
shuiRong / JS
Created June 27, 2023 09:54
Crawl the page, decode
import {
JSDOM
} from 'jsdom';
import got from 'got';
import iconv from 'iconv-lite'
const response = got({
url: '........',
headers: {
'Content-Type': 'text/html; charset=utf-8'
@shuiRong
shuiRong / JS
Created June 22, 2023 09:32
Extract all meaningful text conten from page/html/document
/**
* 从页面中提取文本,为什么不用 innerText/textContent ?
* 因为有些内容在 script/noscript/style 中,这些字符用户看不到,不能当成有意义字符。
*/
export const extractTextFromHTML = (window?: any) => {
if (!window) return ''
try {
const treeWalker = window.document.createTreeWalker(
window.document.body,
@shuiRong
shuiRong / shell
Created June 11, 2021 02:12
shell 脚本 批量 遍历 视频 mp4 ffmpeg 转换 mp3
#!/bin/bash
i=1
for name in *.mp4; do
ffmpeg -i "$name" -vn "mp3/神探狄仁杰OST ${i%.*}.mp3"
let "i++"
done
@shuiRong
shuiRong / JS
Created May 25, 2021 06:06
parseParam 解析url参数,hash模式,考虑到前后两种参数可能
export default {
getUrlAllParam(...args) {
// 获取url参数的值,在hash路由的情况下,同时。适配参数在#前,和在#后的情况。
if (args.length === 0) return undefined
const url = decodeURIComponent(window.location.href)
const reg =
args.length === 1
? new RegExp(`[&?]${args[0]}=([^&%#]+)`)
: new RegExp(`[&?](?:${args.join('|')})=([^&%#]+)`)
@shuiRong
shuiRong / go
Created April 12, 2021 08:31
telegram escape string | markdownv2
package main
import (
"fmt"
"strings"
)
func main() {
var htmlEscaper = strings.NewReplacer(
"#", "\\#",
@shuiRong
shuiRong / js
Created March 23, 2021 06:04
Prettier 和 vscode settings.json 配置的关联
配置 Prettier 规则的地方有好几个,比如可以在 `.vscode/settings.json` 里,也可在项目根目录下的 `.prettierrc`文件里,但如果后者存在(就算空白没东西),
那么 Prettier 将不会尝试从 settings.json 里读取任何配置。
P.S. 这不是前者覆盖后者的关系。是如果有这个配置文件,另一个就没用的关系。
@shuiRong
shuiRong / JS
Created March 8, 2021 07:59
GSAP(GreenSock) 使用自定义 贝塞尔曲线 cubic-bezier 函数
用到这个库:https://github.com/gre/bezier-easing
`bezier-easing` 和 CSS 的 `transition-timing-function` 函数效果完全一样
```
import BezierEasing from "bezier-easing";
TweenLite.to(mc, 5, {x:600, ease:new Ease(BezierEasing(0.25, 0.1, 0.0, 1.0))});
```
@shuiRong
shuiRong / go
Last active November 21, 2020 13:33
go socks5 client 代理
// 配置翻墙用的Client
// socks5://127.0.0.1:1085
func createProxyClient(socks5 string) *http.Client {
client := &http.Client{}
tgProxyURL, err := url.Parse(socks5)
if err != nil {
fmt.Printf("解析socks5失败: %s", err.Error())
os.Exit(1)
}
@shuiRong
shuiRong / shell
Created September 21, 2020 04:56
Github Action 设置 中国时间
- name: 更新为中国时间
run: |
sudo rm -rf /etc/localtime
sudo ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
date
@shuiRong
shuiRong / go
Created August 27, 2020 03:19
Golang GO
项目A引用了模块B,
模块B引用了模块C,
如果想replace C到本地的文件,那么不能在模块B的`go.mod`中写,而是要写在项目A的`go.mod`中。