跳转至

software

软工平台踩坑记

老师要求我们搞 CI/CD,CI 自然是很快就搞好了,不过 CD 还得配一下。今天研究了一下它的 Deployer 架构,发现了若干易用性问题:

  1. 缺乏文档
  2. 只有样例配置没有讲解
  3. 已有的文档 语焉不详
  4. 官方对此回复:功能太多,还没忙过来写文档

于是只好经常戳助教然后尝试理解这个东西。。然后遇到了很多的 BUG:

  1. 容器没有重启功能。。。
  2. 容器死了还是活着看一个图的颜色。。。毫无说明
  3. 容器虽然有 Console,但是输入过长后直接回到行首没有换行。。。
  4. 容器对外的域名里有下划线。。。Django 上来就一句 Invalid HTTP_HOST header: 'xxxx_xxx.app.secoder.net'. The domain name provided is not valid according to RFC 1034/1035. Express 直接就 Invalid Host header 放弃治疗。。。
  5. 助教对上一条的回复是,等我忙完 DDL 有空再做吧。。。也就是说现在要做只能自己再开一个 Nginx 容器然后自己在 proxy_set_header 上做手脚。。。

绕过 GPGMail 的激活检测

前段时间 GPGMail 宣布不再免费,在三十天的试用期后就不给用了。唉,可能是官方实在没钱维护了,也可能是官方想赚钱了。不过,既然 GPGMail 采用的是自由的许可证,意味着我们可以自己对代码进行更改。和许可证验证相关的代码如下:

- (BOOL)hasActiveContract {
    NSDictionary *contractInformation = [self contractInformation];
    return [contractInformation[@"Active"] boolValue];
}

我们只要改成 return TRUE ,在自己的电脑上手动编译、并复制到 /Library/Application Support/GPGTools/GPGMail 下即可。

另:还有一个直接对二进制打 patch 的方法(仍然符合许可证),利用了最近打 CTF 学到的一些知识。找到以上这个函数,然后把返回值修改成非零即可。这里就不提供方法了。最后的更改:

$ radiff2 -D
--- 0x0000282f  410fbec7
- movsx eax, r15b
+++ 0x0000282f  4c89e090
+ mov rax, r12
+ nop

当然了,还需要额外 codesign --remove-signature 一下。

谨慎对非自由软件采用这个方法。可能有法律风险。

在 Ubuntu 上跨版本迁移 MongoDB

由于 MongoDB 只支持当前版本和上一个版本的数据库格式,然后刚刚滚系统升级的时候升级到了 3.6.x,而数据库格式仍然是 3.2.x 的,于是需要先安装回 3.4.x 版本的 MongoDB,输入命令把数据库升级到 3.4.x 版本后,再用 3.6.x 的数据库进行升级。

以 从 Ubuntu 14.04 LTS 升级到 Ubuntu 18.04.1 LTS 为例,方法如下:

$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-3.4.17.tgz
$ tar xvf mongodb-linux-x86_64-ubuntu1604-3.4.17.tgz
$ cd mongodb-linux-x86_64-ubuntu1604-3.4.17/bin/
$ sudo ./mongod --config /etc/mongodb.conf &
$ mongo
> db.adminCommand( { setFeatureCompatibilityVersion: '3.4' } )
{ "ok" : 1 }
$ fg
^C
$ sudo chown -R mongodb:mongodb /var/lib/mongodb
$ sudo systemctl start mongodb
$ mongo
> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
{ "featureCompatibilityVersion" : { "version" : "3.4" }, "ok" : 1 }
> db.adminCommand( { setFeatureCompatibilityVersion: '3.6' } )
{ "ok" : 1 }
> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
{ "featureCompatibilityVersion" : { "version" : "3.6" }, "ok" : 1 }
$ # Okay now

在 Xcode 9 上启用 Vim 模拟(XVim 2)

作为一个不用 vim 编辑会死星人,用 Xcode 总是止不住自己想 Escape 的心。于是找到了 XVimProject/XVim2 进行配置。

大致方法如下:

  1. 按照 Signing Xcode 对 Xcode 进行重签名。套路和对 GDB 进行签名一样。不过这次,签名完成的时间可长多了,毕竟 Xcode 这么大。
  2. 接着按照项目的 README,首先 git clone 然后 make ,第一次打开 Xcode 的时候选择 Load Bundle 即可。

终于可以满足我 Escape Xcode 的欲望了。

Logo is a lisp dialect

Most of us have learnt how to use PCLogo to draw some graphics. Logo is a dialect of Lisp in fact, so most of us used a Lisp dialect at a early time! For some people, it is earlier than C++. Cool.

Screen Capturing Tips in macOS

I'm sure many people have already known this. But i haven't memorize it yet.

How to screen capture:

Shift+Command+3: Capture fullscreen.
Shift+Command+4: Capture region.
               : Press space to capture window. 
               : Hold option and drag, then
               : you will capture a region with its center in where you started dragging 
               : and one of its corners under your cursor.
Ctrl+OneOfTheTwoAbove: Capture to clipboard.
defaults write com.apple.screencapture location: Change the default location storing the images.

Apps enhancing the snapshots: Snappy and Mapture.

See more detailed here.