Skip to content

Instantly share code, notes, and snippets.

View magicwenli's full-sized avatar
🥰
Focusing

magicWenli magicwenli

🥰
Focusing
View GitHub Profile
@magicwenli
magicwenli / iperf3_loopback.sh
Created March 6, 2023 01:02 — forked from pkorpine/iperf3_loopback.sh
Create external loopback between two network interfaces
#!/bin/sh
# Scripted from http://serverfault.com/questions/127636/force-local-ip-traffic-to-an-external-interface
DEV_0="ens6f0"
DEV_1="ens6f1"
MAC_0=`ifconfig ${DEV_0}|awk 'NR==1 {print $5}'`
MAC_1=`ifconfig ${DEV_1}|awk 'NR==1 {print $5}'`
IP_0="192.168.100.1"
IP_1="192.168.101.1"
FAKE_0="192.168.102.1"
$process_name = "notepad.exe"
$time_minute_limit = 0.1
while ($true) {
$process = Get-Process | Where-Object { $_.Path -like "*$process_name" }
if ($process) {
$last_time = (New-TimeSpan -Start ($process).StartTime).TotalMinutes
Write-Output "$process_name is running, live time is $([math]::round($last_time,3)) minutes"
if ($last_time -gt $time_minute_limit) {
$process | Stop-Process -Force
Write-Output "Now is $(Get-Date) , tried to kill $($process.ProcessName) , last_time is $([math]::round($last_time,5)) minutes"
@magicwenli
magicwenli / batch-rename-id3tag-from-filename.py
Created June 4, 2022 13:22
ID3Tag your *.(mp3|flac) from filename
# origin code by hiryu85
# https://github.com/hiryu85/python-ID3TagFromFilename/blob/master/id3fromfile.py
# rewrite at 2022.06.04
from glob import glob
from re import match
from string import Template
from sys import argv, exit
from mutagen import File
@magicwenli
magicwenli / MiaoCopy.ps1
Last active April 3, 2022 11:15
Copy files recursively, with GUI and filters!
<#
.NAME
MiaoCopy
.DESCRIPTION
Copy files recursively, with GUI and filters!
.LINK
github.com/magicwenli
#>
Add-Type -AssemblyName System.Windows.Forms
@magicwenli
magicwenli / mongo-id-generator.go
Created November 3, 2021 05:57
Create a collection called idgen, create a document for every other collection, and store the self-add id
// Create a collection called idgen, create a document for every other collection,
// and store the self-add id
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
@magicwenli
magicwenli / capture_window.py
Created October 30, 2021 04:24
Capture window with shortcuts on windows 10
# -*- coding:utf-8 -*-
#
# Author : magicwenli
# Date : 2021-10-30 11:54:32
# LastEditTime : 2021-10-30 11:54:32
# Useful links :
#
# Virtual Keys List:
# https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
# RegisterHotKey function:
@magicwenli
magicwenli / main.py
Last active September 23, 2021 12:53
calculate combinatorial problems
# This is a sample Python script.
# You can use it to calculate combinatorial problems
# magicwenli on 2021.09.23
import argparse
import math
from fractions import Fraction
def combA(arguments: list):
@magicwenli
magicwenli / make_gif
Last active May 21, 2021 07:10
使用pillow将cv2读入的图片创建为GIF
from PIL import Image
import cv2
import numpy as np
def make_gif(target_path, images, duration=80):
images[0].save(target_path,
save_all=True, append_images=images[1:], optimize=False, duration=duration, loop=1)
imgs=[]
@magicwenli
magicwenli / addMirror.txt
Created November 7, 2020 16:30
给OpenEuler添加软件源
/* 给OpenEuler添加软件源 */
step1: cd /etc/yum.repos.d/
step2: ls
/* 显示结果例如:openEuler.repo */
step3: sudo vi openEuler.repo
/* 进入vi,依次输入注释前的东西 */
G // 即shift+g,跳转到最后一行