Skip to content

Commit c0a417a

Browse files
committed
Create build 3642
0 parents  commit c0a417a

32 files changed

Lines changed: 2705 additions & 0 deletions

.nojekyll

Whitespace-only changes.

404.html

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Berrysoft.Pages</title>
6+
<script type="text/javascript">
7+
// Single Page Apps for GitHub Pages
8+
// https://github.com/rafrex/spa-github-pages
9+
// Copyright (c) 2016 Rafael Pedicini, licensed under the MIT License
10+
// ----------------------------------------------------------------------
11+
// This script takes the current url and converts the path and query
12+
// string into just a query string, and then redirects the browser
13+
// to the new url with only a query string and hash fragment,
14+
// e.g. http://www.foo.tld/one/two?a=b&c=d#qwe, becomes
15+
// http://www.foo.tld/?p=/one/two&q=a=b~and~c=d#qwe
16+
// Note: this 404.html file must be at least 512 bytes for it to work
17+
// with Internet Explorer (it is currently > 512 bytes)
18+
// If you're creating a Project Pages site and NOT using a custom domain,
19+
// then set segmentCount to 1 (enterprise users may need to set it to > 1).
20+
// This way the code will only replace the route part of the path, and not
21+
// the real directory in which the app resides, for example:
22+
// https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
23+
// https://username.github.io/repo-name/?p=/one/two&q=a=b~and~c=d#qwe
24+
// Otherwise, leave segmentCount as 0.
25+
var segmentCount = 0;
26+
var l = window.location;
27+
l.replace(
28+
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
29+
l.pathname.split('/').slice(0, 1 + segmentCount).join('/') + '/?p=/' +
30+
l.pathname.slice(1).split('/').slice(segmentCount).join('/').replace(/&/g, '~and~') +
31+
(l.search ? '&q=' + l.search.slice(1).replace(/&/g, '~and~') : '') +
32+
l.hash
33+
);
34+
</script>
35+
</head>
36+
<body>
37+
</body>
38+
</html>

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[![Build Status](https://strawberry-vs.visualstudio.com/Berrysoft.github.io/_apis/build/status/Berrysoft.Berrysoft.github.io?branchName=dev)](https://strawberry-vs.visualstudio.com/Berrysoft.github.io/_build/latest?definitionId=6&branchName=dev)
2+
3+
My personal page, written with Rust.

blogdata/20190906_First.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
这是第一篇博文,也是测试页面。
2+
## Blazor
3+
框架还好,VS有点慢。自己做了一个Localization的功能,各种坑。
4+
## Markdig
5+
这个博客页面使用的是[Markdig](https://github.com/lunet-io/markdig)做Markdown解析,效率据说不错,不过不知道到了WASM会怎么样。
6+
## iOS
7+
最令人担心的还是iOS上Safari的兼容情况,大概是Mono和Apple的锅,现在的方案似乎可以运行了,但是Localization还是有显示不出来的问题。

blogdata/20190908_Gains.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
最近有一些收获。
2+
3+
## iOS Safari
4+
Safari真是坑,怎么样都不能完美显示,不如弃疗。
5+
6+
## 前端渲染
7+
能交给浏览器做的事情不要写什么C#。
8+
9+
一个比较好的是bootstrap的navbar,可以通过bootstrap js实现小屏幕上的展开。
10+
11+
``` html
12+
<header class="navbar navbar-expand-lg">
13+
<div class="container">
14+
<a class="navbar-brand" href="">...</a>
15+
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
16+
<span class="navbar-toggler-icon"></span>
17+
</button>
18+
19+
<div id="navbarSupportedContent" class="navbar-collapse collapse" onclick="$('#navbarSupportedContent').collapse('hide');">
20+
<ul class="navbar-nav mr-auto">
21+
<li class="nav-item">
22+
...
23+
</li>
24+
</ul>
25+
</div>
26+
</div>
27+
</header>
28+
```
29+
30+
## Blazor
31+
Blazor的Route千万不要和wwwroot里面的文件夹名字重复了,不然浏览器会懵。
32+
33+
使用过了`@inherits`仍然可以用`@code`
34+
35+
Blazor的许多指令令人想起了VB……可怜的语言,姥姥不疼舅舅不爱。
36+
37+
看到了Blazor和Electron结合起来效果也许不错?是不是不该费心用Eto和Xamarin的……
38+
39+
## UWP
40+
如果部署后无法激活,卸载后重启、清理、重新编译可解。
41+
42+
`AppBarButton`的尺寸bug已经修复了。
43+
44+
## 远程桌面
45+
挂VPN连学校里面的电脑,好评。

blogdata/20190912_Gains.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
复习了一下概率方面的知识,顺便测试一下[Markdig](https://github.com/lunet-io/markdig)的数学函数功能。
2+
3+
## 二项分布
4+
$$
5+
P_N(n)=\frac{N!}{n!(N-n)!}p^n {(1-p)}^{N-n}
6+
$$
7+
8+
## 二项式定理
9+
$$
10+
\sum_{n=0}^{N}C_N^n p^n q^{N-n}={(p+q)}^N
11+
$$
12+
13+
当 $q=p-1$ ,即可证明二项分布满足归一化要求。

blogdata/20190922_XXTea.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
今天才刚发现原来清华大学校园网的Auth连接方式,使用了XXTea加密算法。
2+
3+
由于不确定是否魔改过,在这里贴一份。
4+
5+
``` csharp
6+
private static uint[] ToUInt32Array(byte[] data, bool includeLength)
7+
{
8+
int length = data.Length;
9+
int n = (length + 3) / 4;
10+
uint[] result;
11+
if (includeLength)
12+
{
13+
result = new uint[n + 1];
14+
result[n] = (uint)length;
15+
}
16+
else
17+
{
18+
result = new uint[Math.Max(n, 4)];
19+
}
20+
Unsafe.CopyBlock(ref Unsafe.As<uint, byte>(ref result[0]), ref data[0], (uint)length);
21+
return result;
22+
}
23+
private static byte[] ToByteArray(uint[] data, bool includeLength)
24+
{
25+
int d = data.Length;
26+
uint n = (uint)(d << 2);
27+
if (includeLength)
28+
{
29+
uint m = data[d - 1];
30+
n -= 4;
31+
if (m < n - 3 || m > n)
32+
{
33+
return Array.Empty<byte>();
34+
}
35+
n = m;
36+
}
37+
byte[] result = new byte[n];
38+
Unsafe.CopyBlock(ref result[0], ref Unsafe.As<uint, byte>(ref data[0]), n);
39+
return result;
40+
}
41+
private static uint MX(uint sum, uint y, uint z, int p, uint e, uint[] k)
42+
{
43+
return ((z >> 5) ^ (y << 2)) + ((y >> 3) ^ (z << 4) ^ (sum ^ y)) + (k[(p & 3) ^ (int)e] ^ z);
44+
}
45+
public static byte[] XXTeaEncrypt(string str, string key)
46+
{
47+
if (str.Length == 0)
48+
{
49+
return Array.Empty<byte>();
50+
}
51+
uint[] v = ToUInt32Array(Encoding.UTF8.GetBytes(str), true);
52+
uint[] k = ToUInt32Array(Encoding.UTF8.GetBytes(key), false);
53+
int n = v.Length - 1;
54+
uint z = v[n];
55+
uint y;
56+
int q = 6 + 52 / (n + 1);
57+
uint sum = 0;
58+
unchecked
59+
{
60+
while (q-- > 0)
61+
{
62+
sum += 0x9E3779B9;
63+
uint e = (sum >> 2) & 3;
64+
for (int p = 0; p <= n; p++)
65+
{
66+
y = v[(p + 1) % (n + 1)];
67+
z = v[p] += MX(sum, y, z, p, e, k);
68+
}
69+
}
70+
}
71+
return ToByteArray(v, false);
72+
}
73+
```

blogdata/20190925_Gains.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
试图用统计的方法推导热力学定律。
2+
3+
## 热力学第一定律
4+
总能量
5+
6+
$$
7+
E=\sum_s \rho_s E_s
8+
$$
9+
10+
求微分
11+
12+
$$
13+
\mathrm{d}E=\sum_s (E_s\mathrm{d}\rho_s+\rho_s\mathrm{d}E_s)=\sum_s E_s\mathrm{d}\rho_s+\sum_s \rho_s\mathrm{d}E_s
14+
$$
15+
16+
定义 $\delta Q=\sum_s E_s\mathrm{d}\rho_s, \delta W=\sum_s\rho_s\mathrm{d}E_s$ ,则有热力学第一定律
17+
18+
$$
19+
\mathrm{d}E=\delta Q+\delta W
20+
$$
21+
22+
## 热力学第二定律
23+
孤立系统由子系统A、B组成,则有熵
24+
25+
$$
26+
S_t(E_A,E_B)=k\ln\Omega_t(E_A,E_B)=k\ln\Omega_A(E_A)+k\ln\Omega_B(E_B)=k\ln\Omega_A(E_A)+k\ln\Omega_B(E_t-E_A)
27+
$$
28+
29+
则有
30+
31+
$$
32+
\mathrm{d}S=k\mathrm{d}\ln\Omega_t(E_A,E_B)\geqslant 0
33+
$$
34+
35+
## 热力学第零定律
36+
达到平衡态即 $\mathrm{d}S=0$ ,此时
37+
38+
$$
39+
\delta S_t=\delta S_A+\delta S_B=\frac{\partial S_A}{\partial E_A}\delta E_A+\frac{\partial S_B}{\partial E_B}\delta E_B=\frac 1 T_A \delta E_A-\frac 1 T_B \delta E_A=0
40+
$$
41+
42+
则有
43+
44+
$$
45+
T_A=T_B
46+
$$

blogdata/20191012_Gains.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
总结一下Klein-Gordon场的一些相关知识点。
2+
3+
## 二次量子化
4+
所谓二次量子化,是把波函数及其正则共轭坐标变成算符,并满足
5+
6+
$$
7+
[p,\phi]=\mathrm{i}
8+
$$
9+
10+
仍然由薛定谔方程出发,有
11+
12+
$$
13+
H\phi=\mathrm{i}\frac{\partial}{\partial t}\phi
14+
$$
15+
16+
在相对论情况下,哈密顿量
17+
18+
$$
19+
H^2=|\mathbf{p}|^2+m^2
20+
$$
21+
22+
则有
23+
24+
$$
25+
\left[\frac{\partial^2}{\partial t^2}+(|\mathbf{p}|^2+m^2)\right]\phi(\mathbf{p},t)=0
26+
$$
27+
28+
由这个方程反推哈密顿量
29+
30+
$$
31+
H(p,\phi)=\frac 12 p^2+\frac 12 \omega_{\mathbf{p}}^2\phi^2
32+
$$
33+
34+
引入在解决谐振子问题时的升降算符,有
35+
36+
$$
37+
\phi(\mathbf{x})=\int\frac{\mathrm{d}^3 p}{{(2\pi)}^3}\frac{1}{\sqrt{2\omega_{\mathbf{p}}}}(a_\mathbf{p}\mathrm{e}^{\mathrm{i}\mathbf{p}\cdot\mathbf{x}}+a_\mathbf{p}^\dagger \mathrm{e}^{-\mathrm{i}\mathbf{p}\cdot\mathbf{x}})=\int\frac{\mathrm{d}^3 p}{{(2\pi)}^3}\frac{1}{\sqrt{2\omega_{\mathbf{p}}}}(a_\mathbf{p}-a_{-\mathbf{p}}^\dagger)\mathrm{e}^{\mathrm{i}\mathbf{p}\cdot\mathbf{x}}
38+
$$
39+
40+
$$
41+
\pi(\mathbf{x})=\int\frac{\mathrm{d}^3 p}{{(2\pi)}^3}(-\mathrm{i})\sqrt{\frac{\omega_{\mathbf{p}}}{2}}(a_\mathbf{p}\mathrm{e}^{\mathrm{i}\mathbf{p}\cdot\mathbf{x}}-a_\mathbf{p}^\dagger \mathrm{e}^{-\mathrm{i}\mathbf{p}\cdot\mathbf{x}})=\int\frac{\mathrm{d}^3 p}{{(2\pi)}^3}(-\mathrm{i})\sqrt{\frac{\omega_{\mathbf{p}}}{2}}(a_\mathbf{p}-a_{-\mathbf{p}}^\dagger)\mathrm{e}^{\mathrm{i}\mathbf{p}\cdot\mathbf{x}}
42+
$$
43+
44+
这样就有
45+
46+
$$
47+
[\phi(\mathbf{x}),\pi(\mathbf{x}')]=\mathrm{i}\delta(\mathbf{x}-\mathbf{x}')
48+
$$
49+
50+
## 含时场
51+
使用比较简单的定义方式
52+
53+
$$
54+
\phi(x)=\phi(\mathbf{x},t)=\mathrm{e}^{\mathrm{i}H t}\phi(\mathbf{x})\mathrm{e}^{-\mathrm{i}H t}
55+
$$
56+
57+
根据递推关系有
58+
59+
$$
60+
\phi(x)=\mathrm{e}^{\mathrm{i}P\cdot x}\phi(0)\mathrm{e}^{-\mathrm{i}P\cdot x}
61+
$$
62+
63+
## 因果律
64+
判断因果关系,看两个事件的时空间隔是类时还是类空。类时间隔的时间具有因果关系。
65+
66+
又计算联络子
67+
68+
$$
69+
D(x-y)=\langle 0|\phi(x)\phi(y)|0 \rangle=\int\frac{\mathrm{d}^3 p}{{(2\pi)}^3}\frac{1}{2E_\mathbf{p}}\mathrm{e}^{-\mathrm{i}p\cdot(x-y)}
70+
$$
71+
72+
73+
74+
$$
75+
[\phi(x),\phi(y)]=D(x-y)-D(y-x)
76+
$$
77+
78+
则对于类空间隔,总可以找到一个洛伦兹变换,使得 $(x-y)$ 变成 $-(x-y)$ 。对于类时间隔,由于有奇点,无法变换。则因果律成立。

blogdata/20191202_ROOT.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
终于在Windows上成功编译了支持C++ 17的32位ROOT。
2+
3+
## 为啥不编译64位
4+
最大的拦路虎不是Long是32位的问题,这个好改。主要是ROOT的CMake有问题,导致Windows的一系列头文件挂掉,无法编译LLVM。
5+
6+
## 使用vcpkg
7+
最大的助攻是`vcpkg`。尽管每个库都是源码编译安装有些慢,但是毕竟避免了可能的ABI问题,并很好地与CMake集成了。
8+
9+
`vcpkg`主要Hook了`find_package`。不幸的是,ROOT的CMake Module也这么干了……因此需要更改`cmake/modules/SearchInstalledSoftware.cmake`,搞掉`find_package`的定义。
10+
11+
## 魔改STL
12+
MSVC的标准库实现得太好了,导致LLVM5根本编译不过去。需要修改`yvals_code.h`中的`_HAS_AUTO_PTR_ETC`为1。为了其他代码方便,也要改`_HAS_STD_BYTE`为0。当然如果加`-D`也是一样的。
13+
14+
此外,由于LLVM5的C++ 17实现不全,加上MSVC的标准库动不动就是intrinsic,导致一处的代码用不了。具体来说是`type_traits`中的`has_unique_object_representations``is_aggregate`。它们被`ifdef`块包着,暂时搞掉就行。换一个思路,也可以考虑魔改LLVM,不过这个难度就大了……
15+
16+
由于魔改了STL,万一以后还要用到正确实现就不好玩了。需要修改`interpreter/llvm/src/tools/clang/include/clang/Serialization/Module.h`中的`clang::serialization::InputFile::InputFile(const FileEntry*, bool, bool)`,去掉里面有关文件过时的`assert`。这样的话不管头文件怎么魔改都不会报错,但愿别的地方不要出奇奇怪怪的问题……
17+
18+
所以为什么不用LLVM9呢?因为时代变了,接口变了,根本编译不过去……
19+
20+
## CMake
21+
一定要有`vcpkg`的Toolchain文件,不然费好大劲安装的库就没用了。安装库的过程中它还下载了一个`python 3.7.3`,所以也顺便拿来用了。
22+
23+
ROOT死脑筋非要找名为`lib***.dll`的库,而MSVC编译出来的库默认没有这个前缀,需要在CMake配置的时候加上。
24+
25+
给一个我用的CMake命令,用的是Ninja,要比MSBuild快一点:
26+
27+
```
28+
cmake <ROOT_DIR> -GNinja -DCMAKE_TOOLCHAIN_FILE=<VCPKG_PATH>/scripts/buildsystems/vcpkg.cmake -DCMAKE_CXX_STANDARD=17 -Dpython=off -DPYTHON_EXECUTABLE="<VCPKG_PATH>\downloads\tools\python\python-3.7.3\python.exe" -DCMAKE_BUILD_TYPE=Release -Dbuiltin_freetype=off -Dbuiltin_lzma=off -Dbuiltin_pcre=off -Dfftw3=off -Dfitsio=off -Dxrootd=off -Dclad=off -DCMAKE_SHARED_LIBRARY_PREFIX=lib -DCMAKE_SHARED_LIBRARY_PREFIX_C=lib -DCMAKE_SHARED_LIBRARY_PREFIX_CXX=lib
29+
```
30+
31+
## 编译
32+
编译可能遇到很多坑。上面做的这一系列工作就是为了尽量减少这些坑,但还有一些是编译期才能解决的。
33+
34+
在编译得到`rootcling_stage1.exe`之后,会使用这一程序生成许多待编译的文件。然而ROOT试图使用`LD_LIBRARY_PATH`环境变量来指定程序要寻找的库目录,这显然是不可行的。由于生成的命令过于复杂,最简单的方法是在`<BUILD_DIR>\core\rootcling_stage1`下建立一个`etc`文件夹的软链接。使用`cmd`(PowerShell不行)运行
35+
36+
```
37+
mklink /J etc <BUILD_DIR>\etc
38+
```
39+
40+
这一步骤最为艰难,我这里光dump就有几十个。如果出现找不到`std::string_view`,是因为LLVM编译的时候没有打开C++ 17,一定要有`-DCMAKE_CXX_STANDARD=17`。如果出现`byte`歧义,是因为没有设置`_HAS_STD_BYTE`为0。不设置这个宏而是手动更改生成的代码也可以,主要问题在于它在`namespace std {} using namespace std;`后面包含头文件……这样的Bug在C++ 17出现之前一直没有被人发现,也是一大怪事。当然了,Windows的头文件自己居然随便用`byte`当作类型别名,也是应该谴责的,不过相比之下是C++标准更年轻一些……
41+
42+
如果直到最后一步开始测试才发现找不到`libCore.dll`,那是因为没有给编译的库设置prefix。
43+
44+
## 使用
45+
上面的这些坑绕过,再把STL改回来,这个时候root应该是能用的。如果是高DPI,可以设置一下它的DPI选项。输入`.demo`,大部分应该是能正常运行的。之后`ninja install`,然后把安装路径的`bin`文件夹添加到环境变量`PATH`里面。
46+
47+
为了验证C++ 17标准支持,可以`#include <filesystem>`,然后输入一个`std::filesystem::path{}`看看。大括号里面不要输入字符串,否则直接崩掉,Linux上也一样,这已经是ROOT对于标准支持的极限了……
48+
49+
这就结束了?不,还没完!这个时候如果直接`find_package(ROOT REQUIRED)`然后`target_link_libraries(app ${ROOT_LIBRARIES})`,会出现奇奇怪怪的错误。这是因为MSVC的动态库不能直接链接,而是链接那个`.lib`文件。需要更改的文件是安装目录下的`cmake/ROOTConfig.cmake`,直接给出与`ROOT_LIBRARIES`有关的地方的修改结果:
50+
51+
```
52+
set(ROOT_LIBRARIES)
53+
set(CMAKE_FIND_LIBRARY_PREFIXES "") # 也可以不要了
54+
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
55+
# 下面这里删了一个我没有编译的文件,请酌情挑选
56+
foreach(_cpt Core Imt RIO Net Hist Graf Graf3d Gpad ROOTDataFrame Tree TreePlayer Rint Postscript Matrix Physics MathCore Thread ${ROOT_FIND_COMPONENTS})
57+
list(APPEND ROOT_LIBRARIES ${CMAKE_FIND_LIBRARY_PREFIXES}${_cpt}${CMAKE_FIND_LIBRARY_SUFFIXES})
58+
endforeach()
59+
```
60+
61+
## 待完成
62+
cling半残废,可能是即时编译挂掉了,无法编译一些C++函数,导致不能像python一样调用脚本。
63+
64+
## 结论
65+
安装VcSrc或者Xming然后用WSL里面的ROOT吧,这个可是64位的,而且cling也几乎是好的。

0 commit comments

Comments
 (0)