突突唧之家

我的疑问 & 我的解决方案

引用自:#1963 (comment)

以管理员身份启动 PowerShell 后运行下列命令:

foreach($f in Get-ChildItem $env:LOCALAPPDATA\Packages) {CheckNetIsolation.exe LoopbackExempt -a "-n=$($f.Name)"}

如果只需要少量应用:

CheckNetIsolation.exe LoopbackExempt –a –n=<App Directory>

<App Directory> 替换成出现在 %LOCALAPPDATA%\Packages 目录中的应用目录名即可。

Introduction

In this quick article we'll focus on packaging a Maven project into an executable Jar file.

Usually, when creating a jar file, we want to execute it easily, without using the IDE. To that end, we'll discuss the configuration and pros/cons of using each of these approaches for creating the executable.

Configuration

In order to create an executable jar, we don't need any additional dependencies. We just need to create Maven Java project, and have at least one class with the main method.

In our example, we created Java class named ExecutableMavenJar.

We also need to make sure that our pom.xml contains the following elements:

<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>core-java</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

The most important aspect here is the type – to create an executable jar, double-check the configuration uses a jar type.

Now we can start using the various solutions.

阅读全文 »

Most of the answers you'll find around the internet will suggest you to either install the dependency to your local repository or specify a "system" scope in the pom and distribute the dependency with the source of your project. But both of these solutions are actually flawed.

Why you shouldn't apply the "Install to Local Repo" approach

When you install a dependency to your local repository it remains there. Your distribution artifact will do fine as long as it has access to this repository. The problem is in most cases this repository will reside on your local machine, so there'll be no way to resolve this dependency on any other machine. Clearly making your artifact depend on a specific machine is not a way to handle things. Otherwise this dependency will have to be locally installed on every machine working with that project which is not any better.

Why you shouldn't apply the "System Scope" approach

The jars you depend on with the "System Scope" approach neither get installed to any repository or attached to your target packages. That's why your distribution package won't have a way to resolve that dependency when used. That I believe was the reason why the use of system scope even got deprecated. Anyway you don't want to rely on a deprecated feature.

阅读全文 »

前言

在 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++