Compare commits

...

5 Commits

Author SHA1 Message Date
veypi
6273369c68 update 2024-05-23 16:11:36 +08:00
veypi
f64a97ecb0 update 2024-05-23 16:11:06 +08:00
veypi
bc0cf47785 freecad 2024-04-16 17:19:14 +08:00
veypi
237a91cc4b docker register 2024-04-16 15:43:12 +08:00
veypi
2d56423b62 victoria 2024-04-16 15:43:02 +08:00
18 changed files with 481 additions and 4 deletions

View File

@ -17,10 +17,6 @@ $$
\end{matrix}
$$
[
^]:123

12
database/victoria.md Normal file
View File

@ -0,0 +1,12 @@
# victoria
```bash
docker run -dit --name=tsdb -v /share/Public/db/ts:/victoria-metrics-data -p 8428:8428 victoriametrics/victoria-metrics -search.latencyOffset=1s
# http://192.168.6.2:8428/prometheus/api/v1/label/__name__/values
curl -d 'foo 3' -X POST 'http://192.168.6.2:8428/api/v1/import/prometheus'
curl 'http://192.168.6.2:8428/api/v1/query?query=foo'
```

View File

@ -24,4 +24,23 @@ docker run -d -p 5000:5000 --restart=always --name docker-registry \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
registry
docker run -e REGISTRY_HTTP_HOST=https://dockerlocal:1953 -d \
--network host \
--name registry \
--restart=always \
-e REGISTRY_HTTP_ADDR=0.0.0.0:1953 \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
-v `pwd`/data:/var/lib/registry \
-v `pwd`/certs:/certs \
registry:2
docker run -d \
--network host \
--name registry2 \
--restart=always \
-e REGISTRY_HTTP_ADDR=0.0.0.0:1953 \
-v `pwd`/data:/var/lib/registry \
registry:2
```

211
freecad/main.md Normal file
View File

@ -0,0 +1,211 @@
# freecad 二次开发文档
## freecad 源代码目录结构
**src/**此目录包含 FreeCAD 的核心源代码。
**src/App**包含 FreeCAD 的应用程序对象的实现,如文档、事务管理和撤销/重做系统。
**src/Base**包含一些基本类和函数,如向量、矩阵和几何实体。
**src/Main**包含 FreeCAD 的主程序入口点。
**src/Mod**包含 FreeCAD 的各个模块和工作台的实现,如 Part、Sketcher、FEM 等。
**src/Gui**包含 FreeCAD 的图形用户界面GUI的实现使用 Qt 框架构建。
**src/Tools**包含一些实用工具,如编译和构建脚本。
**data/**:此目录包含 FreeCAD 的一些资源文件,如图标、模板、样式表等。
**doc/**此目录包含 FreeCAD 的开发文档,包括编码规范、开发指南等。
**ext/**此目录包含 FreeCAD 依赖的外部库,如 Open CASCADE、Eigen 等
## fem步骤
1. 创建或导入一个几何模型。
2. 转到 FEM 工作台。
3. 创建一个分析对象Analysis Container
4. 定义材料属性。
5. 为模型添加约束,例如固定、力和压力。
6. 创建一个网格,将几何体划分为有限元。
7. 选择求解器,如 CalculiX、Elmer 或 Z88。
8. 运行分析。
9. 查看和分析结果。
## python 自动创建fem分析脚本
```python
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2023 veypi <i@veypi.com>
#
# Distributed under terms of the Apache license.
"""
"""
doc = App.newDocument("Scripted_CalculiX_Cantilever3D")
import Part
box_obj = doc.addObject('Part::Box', 'Box')
box_obj.Height = box_obj.Width = 1000
box_obj.Length = 8000
# see how our part looks like
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
import ObjectsFem
# analysis
analysis_object = ObjectsFem.makeAnalysis(doc, "Analysis")
# solver (we gone use the well tested CcxTools solver object)
solver_object = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiX")
solver_object.GeometricalNonlinearity = 'linear'
solver_object.ThermoMechSteadyState = True
solver_object.MatrixSolverType = 'default'
solver_object.IterationsControlParameterTimeUse = False
analysis_object.addObject(solver_object)
# material
material_object = ObjectsFem.makeMaterialSolid(doc, "SolidMaterial")
mat = material_object.Material
mat['Name'] = "Steel-Generic"
mat['YoungsModulus'] = "210000 MPa"
mat['PoissonRatio'] = "0.30"
mat['Density'] = "7900 kg/m^3"
material_object.Material = mat
analysis_object.addObject(material_object)
# fixed_constraint
fixed_constraint = ObjectsFem.makeConstraintFixed(doc, "FemConstraintFixed")
fixed_constraint.References = [(doc.Box, "Face1")]
analysis_object.addObject(fixed_constraint)
# force_constraint
force_constraint = ObjectsFem.makeConstraintForce(doc, "FemConstraintForce")
force_constraint.References = [(doc.Box, "Face2")]
force_constraint.Force = 9000000.0
force_constraint.Direction = (doc.Box, ["Edge5"])
force_constraint.Reversed = True
analysis_object.addObject(force_constraint)
## fem mesh
femmesh_obj = ObjectsFem.makeMeshGmsh(doc, box_obj.Name + "_Mesh")
femmesh_obj.Part = doc.Box
doc.recompute()
from femmesh.gmshtools import GmshTools as gt
gmsh_mesh = gt(femmesh_obj)
error = gmsh_mesh.create_mesh()
print(error)
analysis_object.addObject(femmesh_obj)
doc.recompute()
# activating analysis
import FemGui
FemGui.setActiveAnalysis(doc.Analysis)
#from femtools import ccxtools
#fea = ccxtools.FemToolsCcx()
#fea.purge_results()
#fea.run()
from femtools import ccxtools
fea = ccxtools.FemToolsCcx()
fea.update_objects()
fea.setup_working_dir()
fea.setup_ccx()
message = fea.check_prerequisites()
if not message:
fea.purge_results()
fea.write_inp_file()
# on error at inp file writing, the inp file path "" was returned (even if the file was written)
# if we would write the inp file anyway, we need to again set it manually
# fea.inp_file_name = '/tmp/FEMWB/FEMMeshGmsh.inp'
fea.ccx_run()
fea.load_results()
else:
FreeCAD.Console.PrintError(
"Houston, we have a problem! {}\n".format(message)) # in report view
print("Houston, we have a problem! {}\n".format(
message)) # in Python console
###
# show resutlt
for m in analysis_object.Group:
if m.isDerivedFrom('Fem::FemResultObject'):
result_object = m
break
femmesh_obj.ViewObject.setNodeDisplacementByVectors(
result_object.NodeNumbers, result_object.DisplacementVectors)
print(result_object.DisplacementVectors[-1])
import time
femmesh_obj.ViewObject.applyDisplacement(20)
import requests
d = requests.get(url="http://192.168.5.172:8015/file/123")
print("|%s|" % (d.text.strip()))
# 每秒请求服务器渲染变形程度
n = 0
data = 0
while 1:
time.sleep(0.01)
d = requests.get(url="http://192.168.5.172:8015/file/123")
data = int(d.text.strip())
# 更新ui
FreeCAD.Gui.updateGui()
#print("%s/%s"%(n, data))
femmesh_obj.ViewObject.applyDisplacement(n)
if data > n:
n = n + 1
if data < n:
n = n - 1
```
## 添加有限元fem 求解器
[参考源码](https://github.com/FreeCAD/FreeCAD/compare/a03eb6b9625ba...dfc01ec949525)
步骤:
[添加mesh导出程序](https://github.com/FreeCAD/FreeCAD/commit/e100971fa0a0c17b5e4906ac540fa31ac0d11766)
[添加求解器,写入程序,任务程序,约束程序](https://github.com/FreeCAD/FreeCAD/commit/cdcd271b4c97a27431dc28d852f6ed7e171dba67)
[添加求解器单元测试](https://github.com/FreeCAD/FreeCAD/commit/005c66f4ecc7fb1690a54592a00ec490146b985d)
[添加文档](https://github.com/FreeCAD/FreeCAD/commit/cfc08b811ff09628b1468e21e9e823587efc799a)
[添加界面参数](https://github.com/FreeCAD/FreeCAD/commit/dfc01ec949525162c70648ea6d6d93c818907f1f)

10
linux/aptcacheng.md Normal file
View File

@ -0,0 +1,10 @@
# apt cache mirror
```bash
apt-get install apt-cacher-ng
systemctl enable apt-cacher-ng
service apt-cacher-ng start
#/etc/apt-cacher-ng/acng.conf
```

14
linux/check_sys.md Normal file
View File

@ -0,0 +1,14 @@
# linux 检查 系统资源
| 命令 | 含义 |
| :------------------: | :----------: |
| uname -a | 查看内核 |
| head -n 1 /etc/issue | 查看操作系统 |
| cat /proc/cpuinfo | 查看cpu |
| lscpu | 查看cpu |
| | |
| free -m | 查看mem |
| df -h | 查看分区使用 |
| du -h | 查看目录大小 |
| | |

35
linux/create_ap.md Normal file
View File

@ -0,0 +1,35 @@
# create ap
### ubuntu netplan
```bash
sudo apt install hostapd
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo vim /etc/hostapd/hostapd.conf
```
```yaml
interface=wlan0
driver=nl80211
hw_mode=g
channel=1
ieee80211d=1
country_code=DE
ieee80211n=1
wmm_enabled=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
ssid=yourSSID
wpa_passphrase=yourpassphrase
```
```bash
sudo vim /etc/default/hostapd
# DAEMON_CONF="/etc/hostapd/hostapd.conf"
```

13
linux/date.sh Normal file
View File

@ -0,0 +1,13 @@
#! /bin/sh
#
# date.sh
# Copyright (C) 2023 veypi <i@veypi.com>
#
# Distributed under terms of the MIT license.
#
sudo date -s "$(bash ~/.date.sh 01)"
a=$RANDOM
a1=$1
echo $(printf "202310${a1}T%02d:%02d:%02d" $(($RANDOM%24)) $(($RANDOM%24)) $(($RANDOM%24)) )

4
linux/lazygit.md Normal file
View File

@ -0,0 +1,4 @@
# lazy git 使用
https://github.com/jesseduffield/lazygit

15
linux/lvm.md Normal file
View File

@ -0,0 +1,15 @@
# lvm
## lvm 扩容
```bash
sudo lvdisplay
sudo pvdisplay
sudo lvextend -L +1.5TB /dev/ubuntu-vg/ubuntu-lv
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
df -h
```

43
linux/nvidia_driver.md Normal file
View File

@ -0,0 +1,43 @@
# ubuntu22 install 4090 dirver
## ubuntu server
```bash
sudo apt install nvidia-driver-550-server nvidia-utils-550-server
reboot
nvidia-smi
```
```bash
sudo apt install pkg-config libglvnd-dev gcc-12 make
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12
sudo systemctl set-default multi-user.target
sudo reboot -h now
sudo ./NVIDIA-Linux-x86_64-535.171.04.run
sudo systemctl set-default graphical.target
sudo reboot -h now
```
## cuda
https://developer.nvidia.com/cuda-toolkit-archive
https://developer.nvidia.com/cuda-12-1-1-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_local
```bash
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda-repo-ubuntu2204-12-1-local_12.1.1-530.30.02-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2204-12-1-local_12.1.1-530.30.02-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2204-12-1-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt update
sudo apt -y install cuda
```

20
linux/passthrough_4090.md Normal file
View File

@ -0,0 +1,20 @@
# 4090直通
```bash
lspci -nn | grep NVIDIA
10de:2684,10de:22ba
echo "vfio vfio_iommu_type1 vfio_virqfd vfio_pci ids=10de:2684,10de:22ba" >> /etc/initramfs-tools/modules
echo "options vfio-pci ids=10de:2684,10de:22ba" > /etc/modprobe.d/vfio.conf
echo "options kvm ignore_msrs=1" > /etc/modprobe.d/kvm.conf
echo "blacklist nouveau" > /etc/modprobe.d/blacklist-nvidia.conf
echo "blacklist nvidiafb" >> /etc/modprobe.d/blacklist-nvidia.conf
sed -ri "/^GRUB_CMDLINE_LINUX_DEFAULT=/ s/\"$/ intel_iommu=on vfio-pci.ids=10de:2684,10de:22ba\"/" /etc/default/grub
update-initramfs -u
update-grub
reboot -h now
```

View File

@ -3,6 +3,7 @@
``` bash
sudo apt install -y zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
sh -c "$(curl -fsSL https://public.veypi.com/install_zsh.sh)"
echo 'PROMPT=%m\ $PROMPT' >> ~/.zshrc
@ -11,4 +12,9 @@ sed -i '1i\DISABLE_AUTO_UPDATE="true"' ~/.zshrc
chsh -s /bin/zsh
sudo reboot -h now
git clone https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git
cd ohmyzsh/tools
REMOTE=https://mirrors.tuna.tsinghua.edu.cn/git/ohmyzsh.git sh install.sh
```

14
mac/latex.md Normal file
View File

@ -0,0 +1,14 @@
# mac latex zathura nvim
### mactex
### [zathura](https://github.com/zegervdv/homebrew-zathura)
```bash
brew tap zegervdv/zathura
brew install zathura
brew install zathura-pdf-poppler
mkdir -p $(brew --prefix zathura)/lib/zathura
ln -s $(brew --prefix zathura-pdf-poppler)/libpdf-poppler.dylib $(brew --prefix zathura)/lib/zathura/libpdf-poppler.dylib
```

46
mac/phpmyadmin.md Normal file
View File

@ -0,0 +1,46 @@
# mac 安装phpmyadmin
https://www.simplified.guide/macos/apache-php-homebrew-codesign
从macos12后已经默认不安装php
```bash
brew install php@7.4
# 添加环境变量
echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.4/sbin:$PATH"' >> ~/.zshrc
# 查看php版本
php -v
```
对phpmodul进行签名
钥匙串访问->证书助理->创建证书颁发机构
![image-20220718015633872](https://public.veypi.com/img/screenshot/20220718015812.png)
返回钥匙串访问的证书列表,信任此证书
![image-20220718020005930](https://public.veypi.com/img/screenshot/20220718020012.png)
```bash
# 执行签名
codesign --sign "php_ca_1" --force --keychain ~/Library/Keychains/login.keychain-db /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so
codesign --sign "php_ca_1" --force --keychain ~/Library/Keychains/login.keychain-db /usr/local/opt/php@7.4/lib/php/20190902/opcache.so
```
修改apache2 配置文件
```bash
sudo vim /etc/apache2/other/php7.conf
# 添加
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so "phpca"
# 重启
sudo apachectl -k restart
```

10
nats/nats.md Normal file
View File

@ -0,0 +1,10 @@
# nats
## install
```bash
go install github.com/nats-io/nats-server/v2@latest
go install github.com/nats-io/natscli/nats@latest
```

View File

@ -50,4 +50,6 @@ sudo n stable
https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install 20
npm install --global yarn
```

7
vue/chrome_debug.md Normal file
View File

@ -0,0 +1,7 @@
# chrome 调试方法
![image-20220925150013418](https://public.veypi.com/img/screenshot/20220925150020.png)
在控制台源代码页 暂停程序, 可以查看函数调用堆栈