Skip to content

Instantly share code, notes, and snippets.

View ShinChven's full-sized avatar
🌟

ShinChven ✨ ShinChven

🌟
View GitHub Profile
@ShinChven
ShinChven / wechat-useragent.js
Last active October 17, 2024 04:28 — forked from GiaoGiaoCat/wechat-useragent.js
微信内置浏览器UserAgent的判断
// 检测浏览器的 User Agent 应该是非常简单的事情
// 微信在 Android 下的 User Agent
mozilla/5.0 (linux; u; android 4.1.2; zh-cn; mi-one plus build/jzo54k) applewebkit/534.30 (khtml, like gecko) version/4.0 mobile safari/534.30 micromessenger/5.0.1.352
// 微信在 iPhone 下的 User Agent
mozilla/5.0 (iphone; cpu iphone os 5_1_1 like mac os x) applewebkit/534.46 (khtml, like gecko) mobile/9b206 micromessenger/5.0
// 通过javascript判断
// 很容易看出来,微信的 User Agent 都有‘micromessenger’字符串标示,我们判断是否含有这些字符串就OK了
function isWeixinBrowser(){
@ShinChven
ShinChven / git-tag
Last active July 22, 2021 02:19
git short cut
#!/bin/bash
## make a git tag, and push to origin remote
git tag -d $1 || true
git tag $1
echo "Push tag to origin remote?"
select yn in "Yes" "Force" "No"; do
@ShinChven
ShinChven / exceljs-util.ts
Created June 8, 2021 02:53
exceljs auto adjust column width
import ExcelJS, {Worksheet} from "exceljs";
/**
* Autofit columns by width
*
* @param worksheet {ExcelJS.Worksheet}
* @param minimalWidth
*/
export const autoWidth = (worksheet: Worksheet, minimalWidth = 10) => {
worksheet.columns.forEach((column) => {
"docker-compose.yml" 17L, 339C 1,1 All
version: '3.5'
services:
web:
image: odoo
depends_on:
- db
ports:
- "8069:8069"
environment:
@ShinChven
ShinChven / dir-size.sh
Created October 23, 2020 09:18
dir-size
#!/bin/bash
du -d 1 -lh $1
@ShinChven
ShinChven / search-text.sh
Last active October 23, 2020 09:15
search text in bash
#!/bin/bash
# https://stackoverflow.com/a/16957078/2108080
grep -rnw $1 -e $2
@ShinChven
ShinChven / sharp-bulk.js
Created September 25, 2020 17:26
sharp-bulk
const path = require('path');
const fs = require('fs-extra');
const sharp = require('sharp');
const dir = '';
const convert = async () => {
const files = await fs.readdir(dir);
for (let i =0 ; i<files.length;i++){
const image = path.join(dir,files[i]);
#!/bin/bash
NETWORK_INTERFACE=$1
ifconfig $NETWORK_INTERFACE && systemd-resolve --status $NETWORK_INTERFACE
# usage
# network-status.sh <Your network interface name>
@ShinChven
ShinChven / bionic.list
Created September 20, 2019 16:07
Aliyun's mirror of Ubuntu sources
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
@ShinChven
ShinChven / clean_dangling_images.sh
Created September 16, 2019 02:32
Clean docker host
#!/bin/bash
docker images -q -f dangling=true | xargs --no-run-if-empty docker rmi