Diff: /Manifest.lock: No Such File or Directory: PODS_ROOT Not Defined

WeexSDK 增加 pods 依赖的时候提示:

diff: /Manifest.lock: No such file or directory

查看 shell script:

1
diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null

echo 发现 PODS_ROOT 为空,导致 diff 右值传递为 ‘/Manifest.lock’,所以文件找不到。

查看 Pods-WeexSDK.debug.xcconfig 中对 PODS_ROOT 有定义:

1
PODS_ROOT = ${SRCROOT}/Pods

而且 project Info -> Configuration 下面指定了正确的 xcconfig。怀疑 PODS_ROOT 被某优先级更高的设置覆盖为空了。

全局搜索 PODS_ROOT,发现 target -> Build Settings -> User Defined 中对 PODS_ROOT 设置了空值。删除后问题解决。

C++ 10分钟速成

IDE 选择

PC

MinGW
VSCode

macOS

CLion (花钱)
Xcode

文章例子编译环境:
方言: GNU++14[-std=gnu++14] Standard library:libc++ (LLVM C++ standard library with C++11 support)

1. 指针

声明

1
2
3
4
5
6
7
8
9
10
11
int main() {
    string food = "Pizza";
    string* ptr = &food;
    cout << food << "\n";
    cout << &food << "\n";
    cout << ptr << "\n";
    cout << &ptr << "\n";
    cout << sizeof(ptr) << "\n";
    cout << sizeof(food) << "\n";
  return 0;
}

执行结果

1
2
3
4
5
6
Pizza
0x7ffeefbff560
0x7ffeefbff560
0x7ffeefbff558
8
24

类型

1
2
food  std::__1::string    "Pizza"  
ptr   std::__1::string *  "Pizza" 0x00007ffeefbff560

内存 (macOS, big-endian)

1
2
3
4
5
6
7
0x7ffeefbff558          0x7ffeefbff560
⬇️                      ⬇️
60 F5 BF EF FE 7F 00 00 0A 50 69 7A 7A 61 00 00
`  õ  ¿  ï  þ  .  .  .     P  i  z  z  a  .  .

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
Read on →

Pytorch Walkthrough on macOS

Env

macOS 10.15 | python 3.8.2 | torch 1.4.0 | torchvision 0.5.0

Install via pip

macOS binary 安装不支持 CUDA,如果需要 CUDA 请翻阅官网 install via source 安装指引。

1
2
pip3 install torch
pip3 install torchvision

安装成功后发现报错:

1
2
3
4
5
6
7
8
>>> import torch
toTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/__init__.py", line 97, in <module>
    from torch._C import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/_C.cpython-38-darwin.so, 9): Library not loaded: @rpath/libc++.1.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/_C.cpython-38-darwin.so
  Reason: image not found

libc++.1.dylib/usr/lib 下,使用 install_name_tool 解决:

1
install_name_tool -add_rpath /usr/lib /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/torch/_C.cpython-38-darwin.so

Hands-on-ml-readle

下载数据集

from sklearn.datasets import fetch_openml

mnist = fetch_openml(‘mnist_784’, data_home=‘./’) # downloaded from www.openml.org print(mnist)

如果提示 SSL: CERTIFICATE_VERIFY_FAILED,需要先更新证书:

1
sudo /Applications/Python\ 3.7/Install\ Certificates.command

修复 _adjustContentOffsetIfNecessary 导致 Scroll View 闪动问题

方法一

继承 scroll view,override _adjustContentOffsetIfNecessary 到空方法。

方法二

swizz scroll view _adjustContentOffsetIfNecessary 到其 category 的一个空方法中。

方法三

对应 UIViewController 的 automaticallyAdjustsScrollViewInsets 设置为 NO。

Gitbook Install and Use

首先安装 Node.js

https://nodejs.org/en/download/

然后安装 Gitbook

1
sudo npm install -g gitbook-cli

再安装 Calibre

Gitbook 的电子书格式转换需要调用 Calibre 的命令行工具。

https://calibre-ebook.com

然后:

1
ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert ~/bin

最后切换到书的 git 目录下

1
gitbook mobi ./ ./book-name.mobi

Over

单页面隐藏 Navigation Bar,同时保持右滑手势退出页面的终极方案

1. 隐藏 navigation bar

在需要隐藏 navigation bar 的 view controller 中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self hideNavBar];
}

- (void)viewDidDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [self showNavBar];
}

- (void)hideNavBar
{
    if (self.navigationController.viewControllers.lastObject == self) //避免推出下一个隐藏bar bar的vc过场动画展示了nav bar
    {
        [self.navigationController setNavigationBarHidden:YES animated:YES];
    }
}

- (void)showNavBar
{
    if (self.navigationController.viewControllers.lastObject == self) //避免推出下一个隐藏bar bar的vc过场动画展示了nav bar
    {
        [self.navigationController setNavigationBarHidden:NO animated:YES];
    }
}
Read on →

iOS 模拟器键盘无响应和剪贴板不响应问题修复(Xcode 10.3)

键盘无响应

iOS Simulator main menu - Hardware - Keyboard
首先取消 Use the Same Keyboard Language as macOS
点击 Connect Hardware Keyboard

剪贴板无响应

iOS Simulator 使用的剪贴板服务挂了,还是 main menu
Edit - 取消 Automatically Sync Pasteboard
再 Edit - 选中 Automatically Sync Pasteboard

Over

macOS 卸载 Symantec 和 McAfee 和 Sentinel

Activity Monitor 查一下相关几个进程的 pid,假设 McAfee 的 pid 为 1001,Symantec 的 pid 为 1002,Sentinel 的 pid 为 1003:

lsof 看一下 pid 相关的 file handle:

1
2
3
lsof -p 1001 -Fn | grep Mc
lsof -p 1002 -Fn | grep Sym
lsof -p 1003 -Fn | grep Sen

记录 McAfee 和 Symantec 的 executable file 位置:

1
2
3
4
5
6
7
/Applications/Symantec Solutions/*
/Applications/McAfee Endpoint.app
/Library/Application Support/Symantec
/Library/Application Support/McAfee
/usr/local/McAfee
/private/var/McAfee
/Library/Sentinel

1. 如果未开启 file vault

关机,长按 command + S, 开机,进入 macOS single user mode, 检查磁盘并挂载磁盘:

1
2
fsck -fy
mount -uw /

删除 McAfee、Symantec、Sentinel 相关文件:

1
2
3
4
5
6
7
rm -rf /Applications/Symantec Solutions/*
rm -rf /Applications/McAfee Endpoint.app
rm -rf /Library/Application Support/Symantec
rm -rf /Library/Application Support/McAfee
rm -rf /usr/local/McAfee
rm -rf /private/var/McAfee
rm -rf /Library/Sentinel

2. 如果已开启 file vault

关机,长按 command + R,开机,进入 Recovery mode;
打开 Disk Ultility,挂载 “Macintosh HD - 数据”;
退出 Disk Ultility,顶部菜单栏进入 Terminal;
cd /Volumes/Macintosh\ HD\ -\ 数据,然后删除 McAfee、Symantec、Sentinel 相关文件:

1
2
3
4
5
6
7
rm -rf ./Applications/Symantec Solutions/*
rm -rf ./Applications/McAfee Endpoint.app
rm -rf ./Library/Application Support/Symantec
rm -rf ./Library/Application Support/McAfee
rm -rf ./usr/local/McAfee
rm -rf ./private/var/McAfee
rm -rf ./Library/Sentinel

重启:

1
reboot

开机 Activity Monitor 里看看还有没有相关进程,如果有,从文章最开始再来一遍。。。

Over

Demark Sequential Using Numpy

一个算命指标 demark 的 python 实现:

1
import numpy as np
Read on →