# Buffer

#### 命名

[MS][T]Buffer[AM][BO]

• MS - memory scheme: Heap or Direct.
• T - type: int, short, float, double, char or byte.
• AM - access mode: W writable (default), R read-only.
• BO - byte ordering: S - non-native, U - native.
• B - BigEndian or L - LittleEndian.

Classes whose names dont include R, by default are W - writable.

1. [T]Buffer
2. Heap[T]Buffer
3. Heap[T]BufferR
4. Direct[T]Buffer[S|U]
5. Direct[T]BufferR[S|U]
6. ByteBufferAs[T]Buffer[B|L]
7. ByteBufferAs[T]BufferR[B|L]

ByteBufferAsCharBufferB

ByteBufferAsCharBufferL

ByteBufferAsCharBufferRB

DirectCharBufferS

DirectCharBufferU

#### Buffer基础

0 <= mark <= position <= limit <= capacity

• flip: limit=position, position。 基本就是读写切换，进行read操作(from buffer)
• clear: position=0, limit=capacity。开启一个新的write(for buffer)

mark默认-1, undefined. mark()操作使得mark=position, reset() 使得 position=mark

buffer.flip().position(5).limit(100)

# Distributed systems for fun and profit读书笔记

• 梳理一些关键概念
• 总结梳理分布式里的一些细节思想

• 信息以光速传递
• 不相干的个体不相关连的失败

###Distributed systems at a high level

Distributed programming is the art of solving the same problem that you can solve on a single computer using multiple computers.

• 存储 (Storage)
• 计算 (Computation)

performance gap. 机器的增长带来的性能增长是非线性的

is the ability of a system, network, or process, to handle a growing amount of work in a capable manner or its ability to be enlarged to accommodate that growth.

• Size scalability
• Geographic scalability

A scalable system is one that continues to meet the needs of its users as scale increases. There are two particularly relevant aspects - performance and availability - which can be measured in various ways.

Performance (and latency)

Performance is characterized by the amount of useful work accomplished by a computer system compared to the time and resources used.

• 低延迟 Short response time/low latency for a given piece of work
• 高吞度 High throughput (rate of processing work)
• 低资源利用率 Low utilization of computing resource(s)

Latency The state of being latent; delay, a period between the initiation of something and the occurrence.

Availability (and fault tolerance)

the proportion of time a system is in a functioning condition. If a user cannot access the system, it is said to be unavailable.

Availability = uptime / (uptime + downtime)

Availability % How much downtime is allowed per year?
90% (“one nine”) More than a month
99% (“two nines”) Less than 4 days
99.9% (“three nines”) Less than 9 hours
99.99% (“four nines”) Less than an hour
99.999% (“five nines”) ~ 5 minutes
99.9999% (“six nines”) ~ 31 seconds

# 高效使用Xcode[译]

You’ve all seen the all-star Hollywood programmer hacking through the mainframe, fingers racing on the keyboard while terminals fly across the screen. If you’ve ever wanted to be like that, you’re in the right place!
This tutorial will teach you how to be more like that programmer, in Xcode. Call it what you like — magic, mad skillz, pure luck or hacks, there is no doubt you’ll feel much cooler (and have improved Xcode efficiency) after following along this tutorial, and maybe even save the world from destruction with your newly found prowess.