FunCoder

FunCoder

The Digital Abstraction

Q: the physical representation of bits?

Then ask what is a good bit?

  • small
  • cheap
  • stable
  • easy and fast to manipulate, access/transform/combine/store/transmit

Industry selected to use voltage to represent information.
But the system need to tolerate errors.

Read more »

6.004 Basic of information

Q: what is good representation of information?

What is information? Information is data that resolves uncertainty about a particular fact.

$X$ is discrete random variable, which has $N$ possible values ($x_i$) and associated probability $p_i$, Information received when learning that choice was $x_i$:

$$I(x_i)=log_2(\frac{1}{p_i})$$

Read more »

被时间“埋没”的高并发王者:Erlang

分布式、fault-tolerant、高并发等等这些名词变得越来越火爆,一个新的框架、数据库、语言如果不跟这几个名词沾边,都不好意思摆在台面上。可是,早在20-30年前的通信领域已经出现了这样的需求,比如 容错、超高并发、在线代码更新、99.9%在线率等等。而互联网领域直到最近10今年才特别关注这种系统。

大概在90年代初,Erlang诞生了,它的设计者正式为了满足通讯领域系统高并发、高容错、分布式的需求设计Erlang和它的虚拟机,BEAM。(当然BEAM不是第一代虚拟机,而是经过几轮迭代后被大规模投入使用的版本)。

虽然,很多年轻的程序员可能没有通过Erlang,提起分布式、高并发,他们更多想到的可能是 Golang,Scala/Akka等等。可是Erlang系统就在我们身边:Cisco超过90%的交换机仍然在使用Erlang;早在2012年,WhatApp的生产系统就实现了在单个Beam虚拟机节点上同时处理超过2百万个TCP/IP连接;RabbitMQ 服务器端代码是Erlang实现的;电信公司T-Mobile的短信业务也是Erlang实现的;Ericsson用Erlang生态构建新的5G基础设施软件;等等。

可以说,在分布式、高并发、高容错这个领域,Erlang得到了广泛的应用,多年的使用也证明了Erlang生态在这个领域的可靠性。

Read more »

Vim增加自定义帮助文件

首先,准备一份帮助文件,文件名必须是 *.txt,然后该文件必须存放在vim的runtimepath。可以通过 :echo &runtimepath 查看,通常就是在
~/.vim/doc 或者 如果是 neovim 在 ~/.config/nvim/

帮助文件的首行第一个字符必须是 *,文件的其余部分不限。但是文件中所有
包含在**内部的单词,都会被检索。所以应该注意不要与其他部分冲突。

一个帮助文件例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
*tidal.txt* Tidal documentation

this file is a consolidation of the official tidalCycles documentation : https://tidalcycles.org/index.php/Userbase

type Time = Rational

## CORE

*(<~)*:: Pattern Time -> Pattern a -> Pattern a
<~ is an operator that shifts a pattern backward in time, by the given amount.
For example, to shift a pattern by a quarter of a cycle, every fourth cycle:
d1 $ every 4 (0.25 <~) $ sound ("arpy arpy:1 arpy:2 arpy:3")
Or to alternate between different shifts:
d1 $ "<0 0.5 0.125>" <~ sound ("arpy arpy:1 arpy:2 arpy:3")
Read more »

总体感觉

总体感觉CS3110这门课程像是一个关于Coding的“大杂烩”,这里完全没有贬义,相反这门课对我这种转行背景的程序员非常有帮助。
正如这么课程介绍中说:

This course is about making you a better programmer.

为了实现这一目的,这门课程的内容涉及了较多方面的内容,而且每一个部分都有为这个目的贡献了力量:

  • Functional Programming with Ocaml:为了说明如何系统化学习任何一门新的计算机预言
  • Modular Programming: 为了说明如何构建大型程序
  • Data Structures: 深度讲解了基本的数据结构,Mutable and Immutable, 比如流、红黑树、哈希表等等
  • Interpreter: 讲解了计算机预言解释器,即更加了解程序员的工具:计算机语言
  • Formal Methods: 讲解进行软件Formal verification
Read more »

Part 1

First thing, what does it mean by saying cs:ip?
This is a old but still being used memory addressing method. Segment: Offfset. The absolute memory addres = (Segment * 16) + Offset. For example, F000:FFFD means address FFFFD. This strange way of expressing address is due to the fact that in the old days, CPU’s regeisters are only 16bit, which can only address a memeory address of 2^16 (which is 64KiB memory). This is even too small at that age. So CPU manufacturers combines two regiesters to express larger address, which is this segment: offset thing.
cs means “code segment” and ip means “instruction pointer”. The combination represents the location where CPU is currently fetching instructions to execute.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/\/\/\/\/\/\/\/\/\/\
| |
| Unused |
| |
+------------------+ <- depends on amount of RAM
| |
| |
| Extended Memory |
| |
| |
+------------------+ <- 0x00100000 (1MB) [Intel 8088]
| BIOS ROM |
+------------------+ <- 0x000F0000 (960KB)
| 16-bit devices, |
| expansion ROMs |
+------------------+ <- 0x000C0000 (768KB)
| VGA Display |
+------------------+ <- 0x000A0000 (640KB)
| |
| Low Memory | [Conventional Memory]
| |
+------------------+ <- 0x00000000

Exercise 2: debug boot

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
 [CS:IP]    address: command  args
[f000:fff0] 0xffff0: ljmp $0xf000,$0xe05b # goto 0xfe05b
[f000:e05b] 0xfe05b: cmpl $0x0,%cs:0x6c48
[f000:e062] 0xfe062: jne 0xfd2e1
[f000:e066] 0xfe066: xor %dx,%dx
[f000:e068] 0xfe068: mov %dx,%ss
[f000:e06a] 0xfe06a: mov $0x7000,%esp
[f000:e070] 0xfe070: mov $0xf3691,%edx
[f000:e076] 0xfe076: jmp 0xfd165
[f000:d165] 0xfd165: mov %eax,%ecx
[f000:d168] 0xfd168: cli
[f000:d169] 0xfd169: cld
[f000:d16a] 0xfd16a: mov $0x8f,%eax
[f000:d170] 0xfd170: out %al,$0x70
[f000:d172] 0xfd172: in $0x71,%al
[f000:d174] 0xfd174: in $0x92,%al
[f000:d176] 0xfd176: or $0x2,%al
[f000:d178] 0xfd178: out %al,$0x92
[f000:d17a] 0xfd17a: lidtw %cs:0x6c38
[f000:d180] 0xfd180: lgdtw %cs:0x6bf4
[f000:d186] 0xfd186: mov %cr0,%eax
[f000:d189] 0xfd189: or $0x1,%eax
[f000:d18d] 0xfd18d: mov %eax,%cr0
[f000:d190] 0xfd190: ljmpl $0x8,$0xfd198
=> 0xfd198: mov $0x10,%eax
=> 0xfd19d: mov %eax,%ds
=> 0xfd19f: mov %eax,%es
=> 0xfd1a1: mov %eax,%ss
Read more »

Efficiently Inefficient Market

hackmd-github-sync-badge

感受

作者认为,市场足够的有效,但是不是完全有效,也正式基金经理的主动挖掘无效性,才进一步促进了市场的有效。只不过,主动投资是有花销的,比如人力、技能、电脑、场地等等,这些都会为主动管理资金设立门槛,导致超过容量有限。

作者在AQR从事量化投资相关研究,具有很好的学术和工业背景,所以他的见解更加贴合真是市场,但是又包含严谨的说明,没有任何玄学。比如,他就明确的说出:想要盈利就必须要预测,而且要做好的预测。

Read more »

Computer System: A Programmer’s Perspectives

hackmd-github-sync-badge

一个读书笔记。

总结

这本书首先自底向上介绍现代计算机的基本工作原理,论述了计算软件和硬件如何协调工作。在此基础上,介绍了一个程序是如何从源代码,被编译,然后被执行的。然后,详细展开说明一个应用程序在硬件和操作系统层面是如何被执行的。 最后,介绍了多个程序之间是如何互动,比如IO、网络、以及并发。

Read more »

In previous chapter, value functions are defined. Dynamic Programming method is used here to use value functions to organize and structure the search for agent best policy.

In other words, DP algorithms are obtained by turning Bellman equations such as these into assignments, that is, into update rules for improving approximations of the desired value functions.

Policy Evaluation

Read more »

Markov Decision Process, MDP

hackmd-github-sync-badge

High level overview of RL

At the heart of RL theory, it is Markov Decision Process.

The general rule we follow is that anything that cannot be changed arbitrarily by the agent is considered to be outside of it and thus part of its environment.

Read more »
0%