Skip to content

Instantly share code, notes, and snippets.

View iflamed's full-sized avatar

New Bing iflamed

View GitHub Profile
@iflamed
iflamed / deploy.sh
Created April 5, 2024 07:37
deploy website with ssh in another user
#!/bin/zsh
ssh server "sudo su -c \"cd /var/www/sites/folder && git pull && npm install && npm run build\" serveruser"
ssh server "sudo supervisorctl restart servercmd"
@iflamed
iflamed / awk.sh
Created January 31, 2024 06:43
使用awk 分析nginx日志
awk -F\" '{print $2}' access.log | awk '{print $2}' | awk -F\? '{print $1}' | sort -n | uniq -c | sort -rn | head -n 100
@iflamed
iflamed / text-decode.js
Created August 14, 2023 10:48
微信小程序 Uint8Array to String 支持utf8
TextEncoder:
var encoder = new TextEncoder()
encoder.encode("中文abc🍎");
//result : Uint8Array(9) [228, 184, 173, 230, 150, 135, 97, 98, 99, 240, 159, 141, 142]
//兼容写法1:
unescape(encodeURIComponent("中文abc🍎")).split("").map(val => val.charCodeAt());
//result : (9) [228, 184, 173, 230, 150, 135, 97, 98, 99, 240, 159, 141, 142]
//兼容写法2:
encodeURIComponent("中文abc🍎").split("").map(val => val.charCodeAt());
//result : (33) [37, 69, 52, 37, 66, 56, 37, 65, 68, 37, 69, 54, 37, 57, 54, 37, 56, 55, 97, 98, 99, 37, 70, 48, 37, 57, 70, 37, 56, 68, 37, 56, 69]
@iflamed
iflamed / debian11-paddleocr.sh
Created June 29, 2023 03:02
PaddleOCR on debian
#install nvidia-driver
apt install linux-headers-$(uname -r)
wget https://cn.download.nvidia.com/tesla/470.199.02/NVIDIA-Linux-x86_64-470.199.02.run
sh NVIDIA-Linux-x86_64-470.199.02.run
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
@iflamed
iflamed / ffmpeg-pipe.sh
Last active July 10, 2023 06:24
ffmpeg视频采样截图审核
ffmpeg -hwaccel auto -i ../test02.MOV -vf "scale=iw/2:ih/2,fps=1" -c:v mjpeg -f image2pipe | processProgram
# 或者
ffmpeg -hwaccel auto -i ../test02.MOV -vf "scale=iw/2:ih/2,fps=1" -c:v mjpeg -f image2pipe - | processProgram
# rtmp or rtsp server
ffmpeg -hwaccel auto -i rtsp://localhost:8554/mytv/test02 -vf "scale=iw/2:ih/2,fps=1" -f image2 out%03d.jpg
ffmpeg -i rtsp://localhost:8554/mytv/test02 -vf fps=1 -f image2 out%03d.jpg
ffmpeg -i rtsp://localhost:8554/mytv/test02 -vf fps=1 -q:v 6 -f image2 out%03d.jpg
@iflamed
iflamed / bash.sh
Last active July 7, 2023 08:02
How to use nginx as RTMP server?
# create rtmp stream from video
ffmpeg -stream_loop -1 -i test02.mp4 -c:a copy -c:v libx264 -f flv rtmp://www.example.com/mytv/test02
ffmpeg -stream_loop -1 -i test02.mp4 -f flv rtmp://www.example.com/mytv/test02
// Package http
package http
import (
"github.com/gin-gonic/gin"
"net/http"
)
type Context struct {
*gin.Context
}
// Ok implement your context method like below
@iflamed
iflamed / hostip.sh
Created June 14, 2021 05:47
获取linux/mac 主机IP地址
ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v 169.254|grep -v 0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:" | head -n 1
@iflamed
iflamed / .drone.yml
Last active October 11, 2021 03:25
Drone CI: git clone with ssh in the clone step
---
kind: pipeline
type: docker
name: default
clone:
disable: true
steps:
- name: clone
@iflamed
iflamed / redis-key-delete-batch.sh
Created January 16, 2021 20:02
批量删除redis中的key
redis-cli -h host -a password --scan --pattern 'Name\\Path\\Value\\Patte*rn' | sed 's/\\/\\\\/g' | xargs redis-cli -h host -a password del