突突唧之家

我的疑问 & 我的解决方案

前言

在 Matplotlib 中一般有三种绘图方式: matplotlib.pyplotpylab 和面向对象编程。在绘图时推荐使用面向对象编程的方法,因为它可以更好地控制和自定义绘图。

官方教程中说:

The pyplot API is generally less-flexible than the object-oriented API. Most of the function calls you see here can also be called as methods from an Axes object. We recommend browsing the tutorials and examples to see how this works.

下图展示了大部分绘图元素:

阅读全文 »

前言

Python 中 Matplotlib 的作图功能很强大。本文教你将多条数据曲线画到一起,并且用不同颜色标志每条数据曲线。

如果你对 Matplotlib 的使用不太熟悉,可以参考此教程

将所有曲线画进一个子图

利用 Matplotlib 的默认方式来执行此操作。

例如:

1
2
3
4
5
6
7
8
9
import numpy as np
import matplotlib.pyplot as plt

x = np.arange(10)
plt.plot(x, x)
plt.plot(x, 2 * x)
plt.plot(x, 3 * x)
plt.plot(x, 4 * x)
plt.show()
阅读全文 »

由于安全权限限制,在 PowerShell 中执行第三方脚本会失败。此时需要手动设置脚本的执行策略。

执行策略

脚本的执行策略有如下几种:

AllSigned

  • Scripts can run.
  • Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.
  • Prompts you before running scripts from publishers that you haven't yet classified as trusted or untrusted.
  • Risks running signed, but malicious, scripts.

Bypass

  • Nothing is blocked and there are no warnings or prompts.
  • This execution policy is designed for configurations in which a PowerShell script is built in to a larger application or for configurations in which PowerShell is the foundation for a program that has its own security model.
阅读全文 »

本方法可能不适用于非 Windows 系统。

在 Python 中使用 Matplotlib 显示中文时,如果遇到字体显示不全等问题,可以添加如下代码片段解决。

# 用来正常显示中文汉字
plt.rcParams['font.sans-serif'] = ['SimHei']

# 用来正常显示负号
plt.rcParams['axes.unicode_minus'] = False

Data types of MySQL and Java programming language are not same, its need some mechanism for transferring data between an database using MySQL data types and a application using Java data types. We need to provide Java mappings for the common MySQL data types. We have to confirm that we have proper type information then only we can correctly store and retrieve parameters and recover results from MySQL statements.

There is no particular reason that the Java data type needs to be exactly isomorphic to the MySQL data type. For example, Java String don't precisely match any of the MySQL data CHAR type, but it gives enough type information to represent CHAR, VARCHAR or LONGVARCHAR successfully.

阅读全文 »

CMake has a standard module for testing if the compiler supports OpenMP.

1
2
3
4
5
6
7
8
9
cmake_minimum_required(VERSION 3.17)
project(OpenMPTest)

set(CMAKE_CXX_STANDARD 20)

add_executable(${PROJECT_NAME} main.cpp)

find_package(OpenMP REQUIRED) # Find the package
target_link_libraries(${PROJECT_NAME} PRIVATE OpenMP::OpenMP_CXX) # Link against it for C++

When using images for API 27 or later, the emulator can render the Android UI with Skia, which can render more smoothly and efficiently.

To enable Skia rendering, use the following commands in adb shell:

su
setprop debug.hwui.renderer skiagl
stop
start

问题描述

通过远程桌面访问 Windows 上安装好的 MATLAB 的时候,出现了 License Manager Error -103 的错误。

解决办法

这是由于 MATLAB 使用了 FLEXlm 进行 license 管理,而 FLEXlm 不支持从远程桌面访问。不过,对 license 文件稍加修改,就能够使用了。

修改 安装目录/licenses 目录下的许可证文件,用任何编辑工具打开 .lic 文件,然后在每一行的 SIGN=xxxxxxxxxx 前面,加入 TS_OK 这个参数(注意 OK 后面有一个空格)。

修改之后即可使用。

Concatenation of Files with Same Codecs

There are two methods within FFmpeg that can be used to concatenate files of the same type: the concat demuxer & the concat protocol

The demuxer is more flexible – it requires the same codecs, but different container formats can be used; and it can be used with any container formats, while the concat protocol only works with a select few containers.

The Concat Demuxer

create a text file named vidlist.txt in the following format:

file '/path/to/clip1'
file '/path/to/clip2'
file '/path/to/clip3'

Note that these can be either relative or absolute paths.

Then issue the command:

ffmpeg -f concat -safe 0 -i vidlist.txt -c copy output

The files will be stream copied in the order they appear in the vidlist.txt into the output container. the "copy codec" is blazing fast.

Edit: Note that although the docs say you don't need -safe 0 if the paths are relative, my testing indicates it's a requirement. It's possible that this may vary with your version of FFmpeg.

There are tips for auto generating the file available in the docs.

Note: All the clips must already exist or the command will fail because decoding won't start until the whole list is read.

The Concat Protocol

ffmpeg -i "concat:video1.ts|video2.ts|video3.ts" -c copy output.ts

Note: as mentioned above the concat protocol is severely limited in what streams and containers it supports so I never use it. The above is only included in an attempt to create a thorough answer. The concat demuxer is a far better choice for most projects.

An alternative suggestion: Personally I prefer using the Matroska container due to it's flexibility and low overhead and join videos with the same encoding using

mkvmerge -o output.mkv input1.mkv + input2.mkv

Concatenation of Files with Different Codecs

If your clips don't use the same codecs for audio and video and/or have different rates, your stuck re-encoding to intermediate files prior to joining which as we all know is both time and resource consuming.

Note that special characters can break things so if you have these in your filenames you'll need to deal with them.