Monday, August 31

关于回车符、换行符

 

打字机(这个组里用过原始机械打字机的人不多)上有两个机械装置,一个是回到句首,另一个是换行,真正使用时这两个机械装置是联合在一起的,成为回到句首并换行,就是 ENTER 键的作用。这就是我们所说的"回车".

 

回到句首在英文里是 Carriage Return, 就是让那个附带着纸的转盘回到原始位置,打字口对着行首

换行在英文里是"Line Feed",让纸往上走1行,打字口就对着下一行。有时也可以翻译成进纸

所以有时你能看到 CRLF,就是指这两个操作。



在电脑发明之后,国际标准设计了 ASCII表,比如 65来表示A66表示B;其中还用10(十六进制的 0x0A)来表示换行 Line Feed, 13(十六进制的 0x0D)来表示回到句首 Carriage Return。在Word, textpad上,只要发现文件里这字节是1013在一起,就从下一行开头显示下一个字节。

这样的不能直接显示,但是有意义的字符我们叫做控制字符

Unix/Linux/Mac里,设计人员偷懒,因为这两个字节总是连在一起的,那么就用其中一个就足以表示换行(并回到句首)了,所以他们只用 ASCII 10 Line Feed 来做这件事情。Linux是爽了,但是跟Windows交换文件时就经常出现混乱,所以还特地写了两个程序来替换回车符,一个叫做 dos2unix,另一个叫做 unix2dos (命名很没有创新感)。



总说“ASCII 13 Carriage Return ” “ASCII 10 Line Feed ” 很麻烦,写在程序上也乱,所以我们给了这两个字符别称,第一个叫做 '\r', 第二个叫做 '\n' 。在C语言里,单引号表征字符,比如 char c='\n';  大家一看就知道这是一个ascii 10 的控制字符,在显示时应该走到下一行;而如果用 string s="\n"; 这就是两个字符,分别是 ascii=92 '\' ascii=110'n' python语言里没有单引号和双引号的区别,所以它规定:如果 \ 后面带着有意义的字母,比如 \r, \n, \t, \f ,它就认为这是控制字符,就把 "\" 和后面的字母 (这两个字符)记录成一个控制字符的ascii码。 如果你要拒绝这个转义,在代码里你要写两个斜杠。例子:





>>> print("a\nb")

a

b

>>> print("a\\nb")

a\nb



能看到 "a\nb" 和 "axb"一样都是3个字节。

希望从这个例子里你能看出:我们必须分清楚,当我们说 "\n"的时候,是表示一个字节的控制字符?还是表示能够看得见得两个字符!



Saturday, August 22

中国央行的“数字货币"

 中国央行发布的“数字货币”也叫“数字人民币”,专业词是DC/EP,其实就是一个银行账号的电子支付手段而已。

换一句话说,你银行账号里的钱直接连接到手机上的专用APP里,收取、支付时,钱直接反应到你的银行账号中。以前大家也有用银行卡来交易,当然很少小额交易,但是概念是一致的,现在的“革命性的数字货币”就是用手机来实现那个银行卡的功能,增加小额支付的方式,如此而已。


除此之外,大家一般说起的“数字货币”是说比特币式的加密货币(Crypto-currency),因为比特币在前段时间(2017年底)升值到两万美金一枚而引起众人瞩目。它的特点是:发布之后,每一段时间发行的数量是确定的,没有政府可以改变。与之相对应的是各国家货币,随时可以由国家央行按照当前经济的运转状况而增发(或减少)。比特币的价值之一就是它的这个确定性和稀缺性,不会因货币滥发而贬值。当然,比特币是不是有价值,会不会因为其他原因而贬值,这是另外一回事。它就像贝壳一样,古代把贝壳当作货币(《盐铁论》中说:“夏后以玄贝,周人以紫石,后世(春秋战国)或金钱刀布。”),连“货”字都是以“贝”为字根,它就有了价值,当大家换以紫石、金银为货币之后,贝壳就一钱不值了。


简单介绍一下,比特币从2009年发布,以数字性、去中心化为特点,慢慢发展了一段时间,从“一个币买一块比萨饼”发展到2017年底“一个币换两万美金”,全球关注,它所采用的区块链技术被深深研究,众多追随货币(copy-cat)也不断发行。这类货币的特点是把账本完全公布出来,全球监督,因此只能一次性写入,无法改动。从这个角度(人人都能看到账本)上说,它们叫做“加密货币(crypto-currency)”是完全错的!在中国也经常说是“数字货币”,但是请一定把这种数字货币跟最近中国央行发行的数字人民币区别开来!


Thursday, August 6

Using Apple Magic mouse in Windows

The Apple Magic mouse is a bluetooth mouse, and it is compatible with most (if not all) windows computer. It can be easily paired with, then you can start using the left click and right click.

Except the scrolling functionality.

The scrolling functionality of the Magic mouse is so different from the traditional Windows mouse, that I can't really describe how it is, if you haven't use it yet. But it is so unique, that every Mac user can't forget. And yes, that is pretty much the reason why I want to use the Magic mouse in this Windows laptop.

Now I need to find the driver of it.

There are some apple community discussion  suggested to get the Boot Camp Support software and install the mouse driver, but the page gave a five year old package. I got to brigadier to get the source code running and download some Book Camp packages and finally found the driver I need.

Now I uploaded the package into AppleWirelessMouse.zip  so you can download, unzip, right click the AppleWirelessMouse.inf to install the driver, then the scrolling functionality is in effect immediately.

Disclaimer: The  Boot Camp Support software is supposed to be used to install Windows in a Mac device. I went all the way through to exact the Magic Mouse driver from it, hopefully it is not violating the copyright of the software.

Labels: ,

Saturday, August 1

一首黑人劳动歌曲 Po Lazuras

首先,有这么一首黑人的劳动歌曲,是说可怜的 Lazurus被警察追踪的事。

现在能查到 Bob Dylan在50年代写了同一个名字的歌,在Youtube上也能找到,但说实话,不好听。



坊间还流传着一个老录音拷贝,大概也是50年代的,节奏、韵律更黑人,更劳动一些,所以在2000年一个电影制作过程中要找这段素材时,辗转买到了版权并重新制作,大获成功,长期登上排行榜,并获得格莱美音乐奖!

下面这段是在电影中的音乐片段:


其实这也就是这电影的开头。

回到音乐来,得奖之后,他们反复查找当时的资料,包括监狱记录等等,才确认了这是密西西比一些监狱犯人的录音,甚至找到了一个带头领唱的犯人James Carter,现在在芝加哥生活。飞到那里,当面给了他一张支票,他已经完全不记得40年前曾经唱过这歌,曾经录音。

当他听说歌曲热卖,比 Michael Jackson 的记录还强时,他很高兴,说:“你告诉Michael, 我会慢下来,让他赶上。”

这首歌现在的署名是“James Carter和他的狱友们”,因为其他狱友的名字再也找寻不到了。


歌词 (source: Musixmatch):

Lyrics
James Carter & The Prisoners
Po LazarusPo LazarusJames Carter & The Prisoners(O Brother, Where Art Thou?)Well, the high sheriffHe told his deputyWant you go out and bring me LazarusWell, the high sheriffTold his deputyI want you go out and bring me LazarusBring him dead or alive,Lawd, LawdBring him dead or aliveWell the deputy he told the high sheriffI ain't gonna mess with LazarusWell the deputy he told the high sheriffSays I ain't gonna mess with LazarusWell he's a dangerous manLawd, LawdHe's a dangerous manWell then the high sheriff, he found LazarusHe was hidin' in the chill of a mountainWell the high sheriff, found LazarusHe was hidin' in the chill of the mountainWith his head hung downLawd, LawdWith his head hung downWell then the high sheriff, he told LazarusHe says Lazarus I come to arrest youWell the high sheriff, told LazarusSays Lazarus I come to arrest youAnd bring ya dead or aliveLawd, LawdBring you dead or aliveWell then Lazarus, he told the high sheriffSays I never been arrestedWell Lazarus, told the high sheriffSays I never been arrestedBy no one manLawd, LawdBy no one manAnd then the high sheriff, he shot LazarusWell, he shot him mighty big numberWell the high sheriff, shot LazarusWell he shot him with a mighty big numberWith a forty fiveLawd, LawdWith a forty fiveWell then they take old LazarusYes they laid him on the commissary gharryWell they taken poor LazarusAnd the laid him on the commissary gharryHe said my wounded sideLawd, LawdMy wounded side

Labels: ,

面包发展史 bacteria

这5张相片,分别是2月7日,18日,18日,28日,和3月1日拍的。







第一天,在孩子们回到家时,一进门就带到厨房,跟他们讲了要做的实验,先把一块干净的白面包放进塑料袋里作为对照组,(图片上第一排第一个),然后在他们面前各摆出一块面包,让他们把手在这面包上抹抹擦擦。我们的目的就是检查这刚从学校带回来的手上有多脏

然后去用水洗手,再来擦一块面包;去用肥皂洗手,回来擦第三块面包。

第一排的后三个是姐姐的,第二排的三个是弟弟的,分别是:直接的“原生态手”,水洗后的手,肥皂洗后的手。

为了让细菌更容易地成长,在这7个装着面包片的塑料袋里,还特地各放了1勺子的清水,然后就按顺序订在饭桌前的墙上。

结果比我想象的要慢,到了10天后才在弟弟原生态面包上发现一个小霉点,当然20天后霉点很明显了。其他几个居然都没有长出霉点来。本来我还期待水洗的手不够干净的。

温度不是问题,虽然是在二月份,基本都是短袖天气,况且,在厨房饭厅前,能有多冷呢。

看了这一个月的面包发展史,孩子们回家后洗手,就不用再提醒了。