Locking up men does nothing more than keep them off the streets.

Locking up men does nothing more than keep them off the streets.
要翻译这句话,首先要理解下面两个短语的意思:
nothing more than
可以翻译成就是,不过是

If you say that someone or something is nothing more than a particular
thing, you are emphasizing that they are only that thing, and nothing more
interesting or important.

keep sb off the streets.
直译就是使某人离开街道。
但是它的引申义是:使某人远离坏的事情

This depends on the context of that particular family, but there are three
possibilities:

“…so that you won’t become destitute and sleep in the street?”
“…so that you won’t join a gang and engage in street crime?”
“…so that you won’t become a prostitute and find clients on the streets?”

所以整体这句话的意思就是:
把一个人锁在家里,就是让他远离麻烦。

https://www.collinsdictionary.com/dictionary/english/nothing-more-than
http://forum.wordreference.com/threads/the-meaning-of-to-keep-someone-off-
the-streets.2559569/

how to export eclipse RCP for multiple platforms

1. First, you need write your RCP in Eclipse and make sure it can run

successful

2. Using below step to install the dependency of other platforms

This is works not only with the Mars release, but also previous releases, as
well.

Open Window/Preferences.
Find PDE/Target Platform
Select your (active) target platform
Click Edit
Click Add
Select "Software Site"
Click Next
In "Work With" type: http://download.eclipse.org/eclipse/updates/4.7 (replace 4.7 with your current version)
Check "Eclipse RCP Target Components"
Check "Equinox Target Components"
Uncheck "Include required software"
Check "Include all environments"
Press Finish
Press Finish
Press OK

Open your product file and select the “Export” option. You will see that the
“Export for multiple platforms” checkbox is available.
attention
这里写图片描述
这里写图片描述

https://wiki.eclipse.org/A_Brief_Overview_of_Building_at_Eclipse

Mbit/s vs MB/s vs MiB/s

Mbit/s的意思是每秒中传输10^6 bit的数据,也写成Mbps
MB/s的意思是每秒中传输10^6 byte的数据
MiB/s的意思是每秒中传输2^20 byte的数据,不太常用
所以如果一个运营商声称自己的传输带宽是1 Mbps的话,
按照MB/s来算的话,它只有0.125 MB/s (megabyte per second);
按照MiB/s来算的话,它更是只有0.1192 MiB/s (mebibyte per second)

具体的换算公式是:
Mbit/s / 8 = MB/s

因为:
Mbit/s = 10^6 bit/s
MiB/s = 2^20 8 bit/s
所以:
Mbit/s = MiB/s
0.1192

refs:
https://en.wikipedia.org/wiki/Data_rate_units
单位转换:

https://toolstud.io/data/bandwidth.php?compare=network&speed=1&speed_unit=Gbps

如何用命令测试Linux 硬盘的读写速度

Use dd command to monitor the reading and writing performance of a disk
device:

  1. Open a shell prompt.
  2. Or login to a remote server via ssh.
  3. Use the dd command to measure server throughput (write speed)
    dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync

  4. Use the dd command to measure server latency
    dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync

ref:
https://www.cyberciti.biz/faq/howto-linux-unix-test-disk-performance-with-
dd-command/

Linux下如何查看你的disk的信息

可以使用smartctl来查看你的disk的信息;
smartctl的disk路径和名字可以通过命令cat /proc/partitions 来得到。

sudo smartctl -d ata -a /dev/sda           
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.10.0-327.36.3.el7.x86_64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     MTFDDAK512MBF-xx
Serial Number:    xxx
LU WWN Device Id: xxx
Firmware Version: xxx
User Capacity:    512,110,190,592 bytes [512 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-3 (unknown minor revision code: 0x011b)
SATA Version is:  SATA >3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Wed Dec  6 10:22:40 2017 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
...

从Device
Model中,可以知道,我的硬盘是MTFDDAK512MBF,在网址google一下,就知道它是Micron产的,具体的内容为了安全考虑,我就不贴出来了。

smartctl中的type的解释:
ATA, SCSI command sets and SAT

In the past there has been a clear distinction between storage devices that
used the ATA and SCSI command sets. This distinction was often reflected in
their device naming and hardware. Now various SCSI transports (e.g. SAS, FC
and iSCSI) can interconnect to both SCSI disks (e.g. FC and SAS) and ATA disks
(especially SATA). USB and IEEE 1394 storage devices use the SCSI command set
externally but almost always contain ATA or SATA disks (or flash). The storage
subsystems in some operating systems have started to remove the distinction
between ATA and SCSI in their device naming policies.

99% of operations that an OS performs on a disk involve the SCSI INQUIRY, READ
CAPACITY, READ and WRITE commands, or their ATA equivalents. Since the SCSI
commands are slightly more general than their ATA equivalents, many OSes are
generating SCSI commands (mainly READ and WRITE) and letting a lower level
translate them to their ATA equivalents as the need arises. An important note
here is that “lower level” may be in external equipment and hence outside the
control of an OS.

SCSI to ATA Translation (SAT) is a standard (ANSI INCITS 431-2007) that
specifies how this translation is done. For the other 1% of operations that an
OS performs on a disk, SAT provides two options. First is an optional ATA
PASS-THROUGH SCSI command (there are two variants). The second is a
translation from the closest SCSI command. Most current interest is in the
“pass-through” option.

The relevance to smartmontools (and hence smartctl) is that its interactions
with disks fall solidly into the “1%” category. So even if the OS can happily
treat (and name) a disk as “SCSI”, smartmontools needs to detect the native
command set and act accordingly. As more storage manufacturers (including
external SATA drives) comply with SAT, smartmontools is able to automatically
distinguish the native command set of the device. In some cases the ‘-d sat’
option is needed on the command line.

There are also virtual disks which typically have no useful information to
convey to smartmontools, but could conceivably in the future. An example of a
virtual disk is the OS’s view of a RAID 1 box. There are most likely two SATA
disks inside a RAID 1 box. Addressing those SATA disks from a distant OS is a
challenge for smartmontools. Another approach is running a tool like
smartmontools inside the RAID 1 box (e.g. a Network Attached Storage (NAS)
box) and fetching the logs via a browser.

ref: https://linux.die.net/man/8/smartctl
http://www.tutorialspoint.com/unix_commands/smartctl.htm

硬盘的分类

从介质来分类:
可以分为HDD(hard disk driver),它有传统的磁盘+控制器组成;

SSD(solid-state driver),它有memory+控制器组成,相比前者,后者没有寻轨时间,比较快;但是也有缺点:使用寿命没有HDD时间长。

从连接方式来分类:
parallel ATA(PATA): 有时候ATA或者IDE(integrated drive electronics)也指的是PATA

Serial ATA(SATA):就是我们通常说的SATA硬盘

SCSI(small computer system interface):一般的个人电脑比较少见

Serial attached SCSI(SAS)

Fiber Channel

IEEE 1394 and USB

Google Protocol Buffer的编解码原理

简单来说,pb就是讲结构化的数据可以序列号和反序列化,而且速度比xml快。

pb的序列化数据的编码格式是 Base 128 Varints,结构中的每一个field对应序列号之后的一对键值对。
这里写图片描述
具体的key是怎么编码,value是怎么编码的,请参见以下链接。

ref:
https://developers.google.com/protocol-buffers/docs/encoding
https://www.sigmainfy.com/blog/protocol-buffers-encoding-and-message-
structure.html

https://www.ibm.com/developerworks/cn/linux/l-cn-gpb/
http://originlee.com/2015/03/18/encoding-and-decoding-of-google-protocol-
buffer/

http://blog.csdn.net/Shreck66/article/details/50926276

怎样获得你的系统中使用的C++标准库的版本

使用locate找到你系统中有的libstdc++.so文件,然后看最后两个数字,然后在下面的网址中去查找就可以了。
例如我的系统的locate输出为:

$ locate libstdc++.so
/xx/libstdc++.so.6
/xx/libstdc++.so.6.0.13
/sometool/linux-x86-64/shlib/libstdc++.so.5
/usr/lib/libstdc++.so.6
/usr/lib/libstdc++.so.6.0.19
/usr/lib/coverity-analysis/bin/libstdc++.so
/usr/lib/coverity-analysis/bin/libstdc++.so.6
/usr/lib/coverity-analysis/bin/libstdc++.so.6.0.20
/usr/lib/debug/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libstdc++.so.debug
/usr/lib/debug/usr/lib64/libstdc++.so.6.0.19.debug
/usr/lib/debug/usr/lib64/libstdc++.so.6.debug
/usr/lib/debug/usr/lib64/libstdc++.so.debug
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/libstdc++.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libstdc++.so
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.19

从上面可以看出,我的系统上安装了以下版本的g++:

libstdc++.so.5
4.8.2
6.0.13
6.0.19
6.0.20

第一个需要使用strings命令来查找:

strings /xxx/libstdc++.so.5|grep LIB  
GLIBCPP_3.2
GLIBCPP_3.2.1
GLIBCPP_3.2.2
GLIBCPP_3.2.3

所以它对应的C++版本时GCC 3.3.3;
第二个一看就是4.8.2

后面三个,只要更具版本号就可以在下面的网址查询到,分别是:GCC 4.4.2, GCC 4.8.3, GCC 4.9.0

Note:有时候你用命令找出来的版本可以在这个网址上找不到,原因可能是你的系统是发行商自己基于某个snapshot,自己编译的。
https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning

如何检查你的应用程序的ABI兼容性

首先要获得你share出去的lib的符号表:

$ find . -name '*.a'|xargs nm -f posix|cut -f1 -d' '|LANG=C sort -u > all_symbols
$ find . -name '*.so'|xargs nm -f posix -D|cut -f1 -d' '|LANG=C sort -u >> all_symbols
$ grep '^_Z' all_symbols | c++filt|sort > demangled_c++_symbols

然后分一下三种情况:
如果你的文件是空的,恭喜你了,你的lib都是C写的,不需要重新编译,是ABI兼容的。

如果你的文件中没有包含 std:: 这样的字符,并且你的函数中没有一个的参数或返回值用到了标准类库中的对象,你的库有90%的就会是ABI兼容的。

如果你的文件中有包含 std:: 这样的字符,或者你的函数中有一个的参数或返回值用到了标准类库中的对象,你的库有90%的就会不是ABI兼容的。

https://gcc.gnu.org/wiki/Cxx11AbiCompatibility
https://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/