Monday, January 29, 2018

Windows_Protocols__2017_Dec_01_cfb

2 Structures

2.1 Compound File Sector Numbers and Types

Each sector, except for the header, is identified by a nonnegative, 32-bit sector number. The following sector numbers above 0xFFFFFFFA are reserved and MUST NOT be used to identify the location of a sector in a compound file.

Followings are definitions of SectIDs:

#define SID_MAXREG (0xfffffffa)

#define SID_FUTURE  ((SectID)(SID_MAXREG + 1))

#define SID_MSAT_SECTOR ((SectID)(SID_MAXREG + 2))

#define SID_SAT_SECTOR ((SectID)(SID_MAXREG + 3))

#define SID_END_OF_CHAIN    ((SectID)(SID_MAXREG + 4))

#define SID_UNUSED_SECTOR ((SectID)(SID_MAXREG + 5))

/*
[MS-CFB] or [MS-CFB] errata 2.9 Compound File Size Limits:
...4,096 bytes/sector x MAXREGSECT (0xFFFFFFFA) sectors...
so SID_MAXREG is also a special ID.
*/
#define SID_IS_SPECIAL(sid) ((SectID)(sid) >= SID_MAXREG)

The following list contains the types of sectors that are allowed in a compound file:

Header: A single sector with fields that are needed to read the other structures of the compound file.For version 4 compound files, the header size (512 bytes) is less than the sector size (4,096 bytes), so the remaining part of the header (3,584 bytes) MUST be filled with all zeroes. We can take head_size as equals with sect_size.

FAT: Sector Allocation Table(OpenOffice: SAT).

DIFAT: Used to locate FAT sectors in the compound file(OpenOffice: MSAT).

Mini FAT: FAT for short streams(OpenOffice: SSAT).

Directory:
User-defined Data:
Unallocated Free:

Range Lock:A single sector that is used to manage concurrent access to the compound file. This sector must cover file offset 0x7FFFFFFF(OpenOffice:Not used).

2.6 Compound File Directory Sectors

2.6.1 Compound File Directory Entry

The valid values for a stream ID, which are used in the Child ID, Right Sibling ID, and Left Sibling ID fields, are 0 through MAXREGSID (excluding).
Directory Entry Name (64 bytes):
storage and stream names are limited to 32 UTF-16 code points, including the terminating null character. When locating an object in the compound file except for the root storage, the directory entry name is compared by using a special case-insensitive uppercase mapping, described in Red-Black Tree. The following characters are illegal and MUST NOT be part of the name: '/', '\', ':', '!'.

Directory Entry Name Length (2 bytes):
This field MUST match the length of the Directory Entry Name Unicode string in bytes. The length MUST be a multiple of 2 and include the terminating null character in the count.
A secured parser shall not use this field.

Object Type (offset 66, 0x42): This field MUST be 0x00, 0x01, 0x02, or 0x05, depending on the actual type of object. All other values are not valid: 0 for Unknown or unallocated; 1 for Storage Object; 2 for Stream Object; 5 for Root Storage Object. 

Color Flag (offset 67, 0x43): This field MUST be 0x00 (red) or 0x01 (black). 

Left Sibling ID(offset 68, 0x44): This field contains the stream ID of the left sibling. If there is no left sibling, the field MUST be set to NOSTREAM (0xFFFFFFFF).

Right Sibling ID (offset 72, 0x48): 

Child ID (offset 76, 0x4C): This field contains the stream ID of a child object. If there is no child object, the field MUST be set to NOSTREAM (0xFFFFFFFF). 

CLSID (offset 80, 0x50): This field contains an object class GUID(can be used as a parameter to start applications.), if this entry is a storage or root storage. If no object class GUID is set on this object, the field MUST be set to all zeroes. 

State Bits (offset 96, 0x60): This field contains the user-defined flags if this entry is a storage object or root storage object. If no state bits are set on the object, this field MUST be set to all zeroes. 

Creation Time(8 bytes):Modified Time (8 bytes): 

Starting Sector Location (offset 116, 0x74): This field contains the first sector location if this is a stream object. For a root storage object, this field MUST contain the first sector of the mini stream, if the mini stream exists.

Stream Size (8 bytes): Streams whose size is less than the Cutoff value exist in the mini stream. Parsers must trust Stream Size to decide it's mini or standard stream,
while maintains a size telling the size figured out through sector chain of this stream.

2.6.4 Red-Black Tree

According rbtree, followings are true:
The root storage object MUST always be black. 
wo consecutive nodes MUST NOT both be red.(if one node is red, it's left/right must be black)
The left sibling MUST always be less than the right sibling. (root object has const name, its name don't compare; root object has no left and right)

This sorting relationship is defined as follows:

A node that has a shorter name is less than a node that has a longer name. 

For each UTF-16 code point, convert to uppercase by using the Unicode Default 
Case Conversion Algorithm

Saturday, January 27, 2018

股票投资

股票选股
https://wallstreetcn.com/articles/3052005

++++++++++++++++++++++++ 电动汽车 ++++++++++++++++++++++++ 谷歌旗下Waymo和Lyft 联手开发自动驾驶汽车技术 601777 力帆股份 特斯拉 腾讯一季度总收入495.52亿元人民币(71.82亿美元 ),同比增长55%;网络游戏收入增长34% 腾讯向美国游戏公司Pocket Gems追加9000万美元投资

Friday, January 26, 2018

Double Precision Floating's Encodings

double's Encodings are as fllowing

+Infinity  0   11..11 (1)  00..00
+Normals  0   11..10 (1)  11..11  the max is less than 1 SHL (2046-1023) * 2 = 1 SHL 1024 = 2 ^ 1024; intel manual says it's less than 2 ^ 1023, which is proved to be in-correct
+Normals  0   00..01 (1)  00..00  the min is 2^-1022;  checked with javascript's normal min and normal max
+Denormals  0   00..00 (0)  11..11  the max is less than 1 SHL (1-1023) = 2 ^ -1022; Will explain later
+Denormals  0   00..00 (0)  00..01  the min is 1 SHL (1-1023)  SHR 52 = 2 ^ -1074; 

as Denormals.min's minimal  Fraction is 00..01, not 00..00(00..00 is left for zero), so if assume  Denormals.min's integer|J bit as 1, then it's Significand is 1.00..01.

processing 1.00..01 is not convinient, so we let Denormals.min's Exponent to be -1022 instead of -1023,
by doing this, Denormals.min can be caculated in above way; so does Denormals.max.

+0: all zeros;
-0   1   00..00 (0)  00..00

-Denormals  1   00..00 (0)  00..01  the max is (-1) * (+Denormals min)
-Denormals  1   00..00 (0)  11..11  the min is (-1) * (+Denormals max)
-Normals  1   the max is (-1) * (+Normals.min)
-Normals  1   the min is (-1) * (+Normals.max)
-Infinity

NaNs are not detailed here, but Numbers of NaNs is easy to get:

NaNs's Exponent parts are the same with Infinitys, so 
 Numbers of NaNs = 2^53 - 2

CreateGoogleCloudPlatformProject

Login Google Cloud Platform, tt "Manage resources" page, select create project( one can create at most 12 free projects at the cloud )

Project name example: LilyJohnGoogle

Project ID(Project ID can have lowercase letters, digits or hyphens and must start with a lowercase letter): lily-trade-com-rev01

Wait for google to finish, if the right-upper-corner icon stop from waiting state and you still can't see the project, use F5 to refresh.

done, now you can use the project( I use it for a static website )

Thursday, January 18, 2018

ECMA404_Dec2017_JSON

JSON shares a small subset of ECMAScript’s syntax with all other programming languages.

A JSON value can be an object, array, number, string, true, false, or null. Note, ECMA value undefined is not a JSON value.

8 Numbers

Following is grammar for Numbers:

image_not_loaded

Note, Numeric values that cannot be represented as sequences of digits (such as Infinity and NaN) are not permitted.

Monday, January 15, 2018

Stop Out level

What is Stop Out
A certain required margin level (in percentage) at which your trading positions will start to automatically close in order to prevent further account losses into the negative territory.
For example:
Your balance is $10,000.
You open a trading position with $1,000 margin.
If the loss on this position reaches $9,500, your account equity becomes:
$10,000 — $9,500 = $500
(50% of your used margin)
At that time, a Stop Out will be issued and your positions will start closing.( 
AvaTrade has Stop Out level as 50%)

Sunday, January 7, 2018

BC省公平药物计划

BC省Fair PharmaCare

介绍

Fair PharmaCare即传说中的公平药物计划,就是药费报销。

就好像车保险, Fair PharmaCare同样有一个Deductible, 不同收入的家庭, 这个扣除额不一样, 零收入家庭这一项为0 。过了扣除额的部分,FairPharma Care可以报销70%, 数额更高一点之后, 报销额度就是100%。

需要注意Fair PharmaCare也有不报的药物或医疗器械,即使是报的项目,也有一个限定,酱紫如果医生如果给你开很贵的药的时候,你就要小心了。

申请

第一步: 在 https://pharmacare.moh.hnet.bc.ca/ 注册。

第二步: Health Insurance BC 给回信 Re: Confirmation of FairPharma Care Assistance. 告诉你Reg Num(注册号格式是“大写字母-三个数字-三个数字-两个数字”).如果你有extended health benefits plan, 它可能要求你在报销的时候提供FairPharma Care信息(记得Manulife就要求客户填这一项信息)。

第三步: 填同意书. 因为HIBC 需要知道你的收入以决定报销额度,所以取得你的申请先, 尽快把这个同意书寄过去就行了。