无损迁移Linux系统到新磁盘

笔者的电脑原有一块SSD上装了Windows 10和Linux的双系统,其中Linux分配了大约300GB空间,但随着系统膨胀,发现空间逐步不够使用了,因此又买了一块1TB的SSD,打算将Linux整体迁移到1TB盘上,将原SSD上Linux部分都划给Windows 10。在此记录下迁移步骤,以供参考。
(此步骤基于Linux Mint,其他发行版应该大同小异。)

迁移步骤

Read More

个税改革分析,减税还是加税?

万众期待的个税改革草案昨天被发布出来征求公众意见,目前似乎讨论都只集中在起征点和级距上。然而,相比于另一个重大变化,也许起征点提高那么一点点的利得对于相当一部分人来说会被完全抵消。这个重大变化就是——年终奖要和工资合并计税了,从此以后年终奖的税是大大提高了的。。

为了仔细分析这一点的影响,先来看下目前的年终奖扣税规定:

以下内容引用自《国家税务总局关于调整个人取得全年一次性奖金等计算征收个人所得税方法问题的通知》(国税发〔2005〕9号):

二、纳税人取得全年一次性奖金,单独作为一个月工资、薪金所得计算纳税,并按以下计税办法,由扣缴义务人发放时代扣代缴:
(一) 先将雇员当月内取得的全年一次性奖金,除以12个月,按其商数确定适用税率和速算扣除数。
如果在发放年终一次性奖金的当月,雇员当月工资薪金所得低于税法规定的费用扣除额,应将全年一次性奖金减除“雇员当月工资薪金所得与费用扣除额的差额”后的余额,按上述办法确定全年一次性奖金的适用税率和速算扣除数。

Read More

MFC

Function call flow

1
2
3
4
5
6
CDialog::PreInitDialog()
CDialog::HandleInitDialog(WPARAM, LPARAM)
CDemoDlg::OnInitDialog()
CDialog::CheckAutoCenter()
CDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
CDialog::PreTranslateMessage(pMsg)

Solve “Opened in another editor” in Resource View

Close “Resource.h” and all “.rc” file. Then shrink and re-expand the “rc” folder in Resource View.

关于减轻功夫墙(GFW)造成的不便的一些探讨

使用gooreplacer重定向对Google的访问

众所周知,天朝无法访问任何Google的服务。但不幸很多外国网站,如码农必备的Stackoverflow等都会调用Google的API,这就导致了这些网站访问速度巨慢,功能不全等问题。在网上发现了有人开发的关于可以重定向Google API到国内镜像的插件,可以用于Firefox和Google Chrome上。特记录于此:
插件地址:https://github.com/jiacai2050/gooreplacer
如果只需要重定向Google的访问,可以复制如下Rules,保存为.gson格式后导入。

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
"createBy": "http://liujiacai.net/gooreplacer/",
"createAt": "Tue Jan 10 2017 17:45:39 GMT+0000",
"rules": {
"ajax.googleapis.com": {
"dstURL": "ajax.proxy.ustclug.org",
"kind": "wildcard",
"enable": true
},
"storage.googleapis.com": {
"dstURL": "storage-googleapis.proxy.ustclug.org",
"kind": "wildcard",
"enable": true
},
"gerrit.googlesource.com": {
"dstURL": "gerrit-googlesource.proxy.ustclug.org",
"kind": "wildcard",
"enable": true
},
"themes.googleusercontent.com": {
"dstURL": "google-themes.proxy.ustclug.org",
"kind": "wildcard",
"enable": true
},
"platform.twitter.com/widgets.js": {
"dstURL": "cdn.rawgit.com/jiacai2050/gooreplacer/gh-pages/proxy/widgets.js",
"kind": "wildcard",
"enable": true
},
"apis.google.com/js/api.js": {
"dstURL": "cdn.rawgit.com/jiacai2050/gooreplacer/gh-pages/proxy/api.js",
"kind": "wildcard",
"enable": true
},
"apis.google.com/js/plusone.js": {
"dstURL": "cdn.rawgit.com/jiacai2050/gooreplacer/gh-pages/proxy/plusone.js",
"kind": "wildcard",
"enable": true
}
}
}

Read More

Tesseract

Install

1. Required package

1
2
3
apt install autoconf-archive automake g++ libtool make pkg-config # for main recognization
apt install asciidoc # for document
apt-get install libicu-dev libpango1.0-dev libcairo2-dev # for training tool
1.1 Build libleptonica-dev from source
1
2
3
4
5
6
7
sudo -i # build as root
wget http://www.leptonica.org/source/leptonica-1.76.0.tar.gz # check http://www.leptonica.org/download.html for latest version
tar -xzf leptonica-1.76.0.tar.gz
cd leptonica-1.76.0/
./configure
make
make install

Read More

Git tricks

Caching GitHub password in Git

In Terminal, enter the following:

1
2
git config --global credential.helper cache
# Set git to use the credential memory cache

To change the default password cache timeout, enter the following:

1
2
git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)

Read More