Debug

2021

2019

C++中将结构体放置在 std::vector 容器内的操作风险

有一组长度不固定的参数需要传输,且参数形式为结构体,那么一个比较简单的方法是将这些参数作为一个std::vector。例如

1
void f(std::vector<struct ExampleStruct> data);

由于 C++是采用值传递的方式,每次对std::vector进行元素的存取操作时,都会对涉及的结构体进行复制。如果结构体的数量比较多,或者结构体的体积比加大,那么这种方式对于计算和内存资源的浪费就比较大了。

Jun 28
MAC: @rpath的坑

1 Problem

这篇文章的缘由是我在尝试使用ns3带的NetAnim程序时,显示了下面这个错误:

1
2
3
4
dyld: Library not loaded: @rpath/QtGui.framework/Versions/4/QtGui
Referenced from: /path/to/ns-allinone-3.28/netanim-3.108/./NetAnim
Reason: image not found
[1] 86663 abort ./NetAnim
Jun 28
Python下的音频处理库librosa打开文件是显示NoBackendError的解决

近日在 django 项目中采用了 librosa 来分析用户上传的音频,主要是对其做一定间隔的采样用于绘制波形图。在本地(MacOS)上工作正常,部署到 Ubuntu 服务器后,自己手动用 python 方式运行 django 的 server 时,工作都是正常的,然而当我用 superviosr 挂起之后就一直报 NoBackendError 的错误,反复检查了 FFmpeg 的安装,应该是没有问题的。网上搜了一下没有看到比较合适的解决办法,故不得不自己读源码来调试了。

Jun 26
Matplotlib in Virtualenv

我使用的是 macOS 系统。当在虚拟环境中尝试使用 matplotlib 时,会出现如下的报错:

1
ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more informatio
May 16
Docker Volume的权限问题

这里我们要解决的是使用 Docker 过程中常见的 Volume 权限问题。具体而言,当我们用-v将宿主机的路径绑定到 Docker 镜像的内部路径时,有时候会导致 Docker 镜像缺少对这个目录的访问权限,从而导致进程出错。

May 08