西维蜀黍

【PVE】Install ProxMox VE (PVE)

Download

https://www.proxmox.com/en/downloads

Prepare a USB Flash Drive

  • use balenaEtcher
  ...


【macOS】制作 VMware vSphere Hypervisor (ESXi) 8.0 U3

Install

$ diskutil list

$ diskutil eraseDisk MS-DOS "ESXI" MBR /dev/disk4

$ diskutil unmountDisk /dev/disk4

$ sudo fdisk -e /dev/disk4
Password:
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
Enter 'help' for information
fdisk: 1> f 1
Partition 1 marked active.
fdisk:*1> write
Writing MBR at offset 0.
fdisk: 1> exit

$ hdiutil mount Downloads/VMware-VMvisor-Installer-8.0U3-24022510.x86_64.iso
/dev/disk6          	                               	/Volumes/ESXI-8.0U3-24022510-STANDARD
$ cp -R /Volumes/ESXI-8.0U3-24022510-STANDARD/* /Volumes/ESXI/
  ...


【Compile】ANTLR

Background

文法定义(Grammar Definition)

风控策略表达式的语法到底是什么样的?也就是说 风控策略表达式这种DSL的语法结构是什么?

在学习形式语言或编译原理课程时,想必大家肯定接触过BNF(Backus-Naur Form),即巴科斯范式。巴科斯范式是以美国人巴科斯(Backus)和丹麦人诺尔(Naur)的名字命名的一种形式化的语法表示方法,是用来描述语法的一种形式体系,是一种典型的元语言。自从编程语言Algol 60(Naur,1960)使用BNF符号定义语法以来,这种符号规则体系被证明适合作为形式化编程语言的语法,之后人们也开始习惯于使用此类元语言去定义语言语法。

BNF元语言的典型表达形式如下:

<symbol> ::= expression
<symbol> ::= expression1 | expression2
  • 这个式子左侧放在尖括号中的symbol是一个非终结符号,而expression这个表达式由一个或多个终结符号或非终结符号的序列组成,这个式子也被称为产生式(production)。
  • 产生式中的“::=”这个符号含义是“被定义为”,左边的非终结符号可以被推导为右边的表达式,右边的表达式也可以归约为左边的非终结符号。
  • 如果右侧有多种表达式形式可作为symbol的归约选择,可以使用”|”符号分隔。
  • 从未出现在左边的符号是终结符号。另一方面,出现在左侧的符号为非终结符号,并且总是被包围在一对<>之间。

随着BNF的广泛应用,一些以简化BNF或特定应用为目的的扩展BNF元语言被创建出来,其中典型的包括EBNF、ABNF等。

我们来定义一下能描述背景的例子的文法:

/* 关键字 */
USER: 'user';
CONTAINS: 'contains';
AND: 'and';
OR: 'or';

/* 符号和运算符 */
DOUBLE_QUOTE: '"';
COMMA: ',';
DOT: '.';
LT: '<';
LE: '<=';
GT: '>';
GE: '>=';
EQ: '==';
NE: '!=';
DOLLAR: '$';
L_PAREN: '(';
R_PAREN: ')';
L_CURLY: '{';
R_CURLY: '}';
L_BRACKET: '[';
R_BRACKET: ']';

/* 标识符 */
ID: [a-zA-Z][a-zA-Z0-9]+;

/* 无符号整数和字符串的字面量 */
NUM_LIT: ('0' | [1-9] ('_'? [0-9])*);
STR_LIT: DOUBLE_QUOTE ~["\\]* DOUBLE_QUOTE;

以上为词法规则,全部使用大写表示,定义了所有的终结符。

  ...


【Compile】Lex and Yacc

Lex

Lex is a computer program that generates lexical analyzers (“scanners” or “lexers”). It is commonly used with the yacc parser generator and is the standard lexical analyzer generator on many Unix and Unix-like systems.

Lex reads an input stream specifying the lexical analyzer and writes source code which implements the lexical analyzer in the C programming language.

  ...


【Compile】编译(Compilation)

编译原理(Fundamentals of Compiling)

  ...


【Engineering】规则引擎(Rule Engine)

  ...


【Network】端口转发(Port Forward)

Forward A Local Port to A Local/External Port

ssh

Refer to https://swsmile.info/post/linux-ssh-usage/

socat

Refer to https://swsmile.info/post/linux-socat/

iptables

Refer to https://swsmile.info/post/linux-iptables/

  ...


【FreeBSD】pfctl

PF (Packet Filter)

PF (Packet Filter, also written pf) is a BSD licensed stateful packet filter, a central piece of software for firewalling. It is comparable to netfilter (iptables), ipfw, and ipfilter.

PF was developed for OpenBSD, but has been ported to many other operating systems.

Usages

Show

# shows how it has interpreted the filtering rules in your config file, including substitutions and defaults
$ pfctl -s

# Shows the NAT rules
sudo pfctl -s nat (or pfctl -sn): 

# Shows all the things
sudo pfctl -s all (or pfctl -sa): 
  ...


【Database】Column-oriented DBMS(列式数据库管理系统)

Background

A relational database management system provides data that represents a two-dimensional table of columns and rows. For example, a database might have this table:

RowId EmpId Lastname Firstname Salary
001 10 Smith Joe 60000
002 12 Jones Mary 80000
003 11 Johnson Cathy 94000
004 22 Jones Bob 55000

This simple table includes an employee identifier (EmpId), name fields (Lastname and Firstname) and a salary (Salary). This two-dimensional format is an abstraction. In an actual implementation, storage hardware requires the data to be serialized into one form or another.

The most expensive operations involving hard disks are seeks. In order to improve overall performance, related data should be stored in a fashion to minimize the number of seeks. This is known as locality of reference, and the basic concept appears in a number of different contexts. Hard disks are organized into a series of blocks of a fixed size, typically enough to store several rows of the table. By organizing the table’s data so rows fit within these blocks, and grouping related rows onto sequential blocks, the number of blocks that need to be read or sought is minimized in many cases, along with the number of seeks.

A survey by Pinnecke et al.[1] covers techniques for column-/row hybridization as of 2017.

  ...


【Architecture】System Design - Budget/Quota System

Background

  • Operators of a E-commerce platform wanna control the budget allocated to a specified promotion.
    • E.g, for big sellers (especially), they would like to set a special Shipping Fee rule/promotion (cap, time period, etc) for certain days like Super Brand Day, or local Super Brand Day. And during those big events, a budget cap is involved.
  • So as to
    • Increase the adoption of promotions created by sellers, which may save the E-commerce’s platform’s costs
    • Provide an finer granularity to control promotions, in terms of especially costs
  ...