need to install the Win32::Console module

ActivePerl-5.26.3.XXXX.msi安装后,命令行执行cpan,会出现如下提示而无法继续。

Can't locate Win32/Console.pm in @INC (need to install the Win32::Console module) (@INC contains: C:\Perl64\site\lib C:\Perl64\lib) at C:\Perl64\lib/ActivePerl/Config.pm line 400.

解决办法,修改C:\Perl64\lib\ActivePerl\Config.pm,大约在400行左右:

392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# Prevent calling Win32::Console::DESTROY on a STDOUT handle
#my $console;
sub _warn {
#    my($msg) = @_;
#    unless (-t STDOUT) {
#	print "\n$msg\n";
#	return;
#    }
#    require Win32::Console;
#    unless ($console) {
#	$console = Win32::Console->new(Win32::Console::STD_OUTPUT_HANDLE());
#    }
#    my($col,undef) = $console->Size;
#    print "\n";
#    my $attr = $console->Attr;
#    $console->Attr($Win32::Console::FG_RED | $Win32::Console::BG_WHITE);
#    for (split(/\n/, "$msg")) {
#	$_ .= " " while length() < $col-1;
#	print "$_\n";
#    }
#    $console->Attr($attr);
#    print "\n";
}

qt5.6编译后运行designer

直接双击运行bin/designer.exe会报如下错误:

This application failed to start because it could not find or load the Qt platform plugin "windows" in ...

解决办法是,在bin目录中新建qt.conf文件,其内容如下:

1
2
[Paths]
Prefix=d:/qt5.6.1.x64/

其中d:/qt5.6.1.x64/是根目录,该目录直接下面是bin目录及plugins目录。同时要注意这里的路径字符串中是Linux下的斜杠,不是Windows的反斜杠。

美化输出xml或json

xml

1
2
3
from xml.dom.minidom import *
with open('d:/xml.txt', 'r') as f:
    print(parseString(f.read()).toprettyxml())

json

1
python -m json.tool d:\json.txt

下载文件

1
2
3
4
import requests
resp = requests.get('http://file.url', headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'})
with open("aa.dat", "wb") as f:
    f.write(resp.content)

android cmake命令行

ninja这个工具是google的cmake特有的一个工具,不能用CMake官网下载安装的cmake编译安卓程序。

1
2
3
4
5
6
7
8
9
10
set SDK_PATH=E:\euhat\android-sdk
set path=%SDK_PATH%\cmake\3.10.2.4988404\bin;%path%
 
cd app
mkdir manBuild
cd manBuild
 
cmake -DANDROID_ABI=armeabi-v7a -DANDROID_STL=c++_shared -DBUILD_SHARED_LIBS=ON -DCMAKE_C_FLAGS="-s" -DANDROID_PLATFORM=android-27 -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=%SDK_PATH%\ndk-bundle -DCMAKE_TOOLCHAIN_FILE=%SDK_PATH%\ndk-bundle\build\cmake\android.toolchain.cmake -DCMAKE_GENERATOR=Ninja ..
 
ninja

refer to: https://bbs.csdn.net/topics/392257691?list=lz

视频在微信手机端看不了

比如用ffmpeg在电脑端录的mp4视频,拖到微信电脑端是可以看的,但打开微信手机端就不动了,只能看到第一帧。

解决办法是先将mp4格式转为mpg格式,再将mpg格式转为mp4格式,最后得到的mp4就可在微信手机端播放了:

1
2
ffmpeg.exe -i old.mp4 temp.mpg
ffmpeg.exe -i temp.mpg new.mp4

附ffmpeg在windows下录屏方法:

1
ffmpeg -f gdigrab -framerate 30 -offset_x 655 -offset_y 517 -video_size 511x374 -i desktop capture.mpg

ffmpeg在ubuntu下录屏方法:

1
ffmpeg -framerate 25 -f x11grab -s 800x600 -i :0.0+100,200 capture.mp4

转码为mp4的方法:

1
2
3
ffmpeg.exe -ss 5 -sseof 5 -i %1 -vf scale=-2:600 -y output.mp4
 
rem ffmpeg.exe -ss 5 -sseof 5 -i %1 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" output.mp4

refer to:
https://github.com/GyanD/codexffmpeg/releases/tag/2021-12-02-git-4a6aece703
https://www.xzcblog.com/post-173.html

用curl发送json请求

以下是json.bat的内容:

1
2
3
4
set /P json=<%1
set result=%json:"=\"%
curl -H "Content-Type:application/json" -X POST -d %result% http://you.url
pause

然后把只含json内容的文件拖到json.bat上面运行就可以了。

注意1,我测试时下载的curl命令行工具是不支持json串中包含空格的,这里只作测试用途,空格先都去掉。
注意2,json.bat第2行包含了Windows批处理脚本中,往字符串里插入字符的方法,此处是把json字符串中每一个双引号前插入一个反斜杠。

linux获取窗口对应进程

在图形界面下打开一个终端,输入命令:

xwininfo -all

再点击想要查询的窗口,会打印很多信息,其中Window manager hints下会有Process id,用这个pid就可找到进程对应的执行文件路径。

-fprofile-arcs -ftest-coverage
ps aux | sort -k2rn | head -n 3

caffe gemv
https://blog.csdn.net/langb2014/article/details/50986678

sed
https://www.toutiao.com/a6738939489579696651/

grep
https://www.toutiao.com/a6738675495363150344/

lsof
lsof cc.txt 显示开启文件cc.txt的进程
lsof -i :22 知道22端口被哪个进程占用
lsof -c a.out 显示a.out进程现在打开的文件
lsof -g gid 显示归属gid的进程情况
lsof -n 不将IP转换为hostname,缺省是不加上-n参数
lsof -p 12 看进程号为12的进程打开了哪些文件
lsof -u username 查看用户打开哪些文件
lsof -i @192.168.1.111 查看远程已打开的网络连接(连接到192.168.1.111)
lsof -i tcp@192.168.1.55 -r

fuser -k /mnt/test
umount /mnt/test

1
2
3
4
5
6
::chcp 65001
for /f "tokens=1,2 usebackq delims=." %%a in (`dir /o:n /b`) do (
	if not "%%a.%%b" == "%%a." (
		echo ^<%%a^>-[%%b]	
	)
)
1
2
3
body * {
 outline: 1px solid red
}

document.designMode='on'

VAR_A="hello, world, hello, me"
echo ${#VAR_A}
echo ${VAR_A:1:4}
echo ${VAR_A/hello/yes}
echo ${VAR_A//hello/yes}

# objdump -d c.elf | grep -A 2 function2
000084e8 <_Z9function2v>:
84e8: b580 push {r7, lr}
84ea: af00 add r7, sp, #0
# addr2line -e c.elf 84e8
testB/c.cpp:12
# nm c.elf | grep -Ei "function|main|globalvar"
00011028 D globalvar
U __libc_start_main@@GLIBC_2.4
00008500 T main
000084d0 T _Z9function1v
000084e8 T _Z9function2v

# nc 192.168.1.123 80
GET / HTTP/1.1

watch -d=cumulative 'ls -rtlh | tail'

exec 2>/tmp/run.log
exec 1>&2
set -x

for /r %i in (*.dll) do echo "%i"