0%

异常和恢复流程

Problem 1: harddisk is removed

  1. 首先通过sudo mdadm -D /dev/md0 可以看到有两块disk显示removed
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
29
/dev/md0:
Version : 1.2
Creation Time : Thu Jan 2 15:23:16 2020
Raid Level : raid10
Array Size : 7813772288 (7451.79 GiB 8001.30 GB)
Used Dev Size : 3906886144 (3725.90 GiB 4000.65 GB)
Raid Devices : 4
Total Devices : 2
Persistence : Superblock is persistent

Intent Bitmap : Internal

Update Time : Tue Feb 18 20:55:04 2020
State : clean, degraded
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Layout : near=2
Chunk Size : 512K

Consistency Policy : bitmap

Number Major Minor RaidDevice State
- 0 0 0 removed
1 8 48 1 active sync set-B
- 0 0 2 removed
4 8 80 3 active sync set-B
  1. sudo fdisk -l 查看所有硬盘, 找到是哪些硬盘,例如/dev/sdc, /dev/sde没有添加上

  2. sudo mdadm --re-add /dev/md0 /dev/sdc 重新添加硬盘进raid,添加成功会显示is added

  3. 此时再 sudo mdadm -D /dev/md0 则会显示rebuilding

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    Consistency Policy : bitmap

    Rebuild Status : 99% complete

    Number Major Minor RaidDevice State
    0 8 32 0 spare rebuilding /dev/sdc
    1 8 48 1 active sync set-B
    2 8 96 2 spare rebuilding /dev/sdg
    4 8 80 3 active sync set-B
  4. 可以通过cat /proc/mdadm 查看状态

Debugging FUSE Filesystem.

Collect some tip/tricks for debugging FUSE.

Program options

  1. -f : Run foreground
  2. -s : Disable multiple threading
  1. Enable debugging
    1. Compiling with debugging symbols enabled(-g to gcc)
    2. enable core dumps: ulimit -c unlimited
    3. If program crashes, it will have core dump in current directory
    4. load the core file: `gdb

Tools

  1. Valgrind: Valgrind is an instrumentation framework for building dynamic analysis tools.

    #include <valgrind/valgrind.h>
    
    if (RUNNING_ON_VALGRIND) {
        fprintf(stderr,
            "******** Valgrind has been detected by %s\n"
            "******** If you have difficulties getting %s to work under"
            " Valgrind,\n"
            "******** see the following thread:\n"
            "******** http://www.nabble.com/valgrind-and-fuse-file-systems"
            "-td13112112.html\n"
            "******** Sleeping for 5 seconds so this doesn't fly by ....",
                progname, progname);
        sleep(5);
        fprintf(stderr, "\n");
    }

    Reference: Code from Tim Post

  2. User-Mode Linux

Documents/Tutorials

  1. CS135 FUSE Document
  2. Use GDB to Understand FUSE File System

最近VSCode真香中…人老了就感觉不喜欢话时间再折腾一些生产工具, 当然Emacs/Vim还是用的很多,但是越来越多在source code reading 的时候会更倾向与打开vscode了。

换一种编辑器最大问题在于熟悉快捷键(反之一款好编辑器就应该让快捷键很直观,就像”The design of Everyday Everything” 中有提到的那样, 符合人们的mentor model)

分享一些不常用但很有用的快捷键, 根据个人喜好可以改一下和系统的冲突。 有新发现的会继续更新

官方的文档可以通过Ctrl-P然后输入”> help keyboard shortcuts” 获取
文档

Select

原生支持:

  1. Expand Select

    1
    Shift + Alt + RightArrow
  2. Shrink Select

    1
    Shift + Alt + LeftArrow
  3. Select In Words

    这个我一直习惯用Ctrl+Alt+Left/Right, 但是和Ubuntu的workspace切换冲突了..

    1
    Ctrl + Shift + Right/LeftArrow

插件:

  1. “Quick and Simple Text Selection” by David Bankier. 支持更多的快速选择

    Ctrl+k 之后再按一个以下字符,可以选择被包括在其中的字符串

    1
    2
    3
    4
    5
    6
    7
    8
    Ctrl + K ' select everything between single quotes
    Ctrl + K " select everything between double quotes
    Ctrl + K ` select everything between back ticks
    Ctrl + K ( select everything inside parenthesis
    Ctrl + K ) select everything inside parenthesis and include them
    Ctrl + K [ or ] select everything between square brackets and include them
    Ctrl + K { or } select everything between curly braces and include them
    Ctrl + K < or > select everything between angle brackets and include them

Windows management

原生支持:

  1. Re-open a closed editor

    1
    Ctrl+Shift+T

    这个操作和Chrome浏览器一样, Nice~!

Text Edition

原生支持

1. Move line up/down

1
Alt + Up/DownArrow


References

21 VSCode Shortcuts To Code Faster and Funner


欢迎在留言补充更多Tricks;)

《商业模式全史》这本书是日本作家三谷宏治所作。

在亚马逊关掉国内的网站前买了这本书,很早之前看到过,这位作者也还有另外一本和商业相关的书。

全书一共有以下几个章节。 会慢慢概括和罗列一些书中提到的公司和模式。

什么是商业模式

商业模式/Business Model, 这个词语听起来还挺高大上的。说通俗一点其实就是通过什么方法赚钱/盈利。

创生期(1673-1969)

变革期(1970=1990)

创造期(1991-2001)

巨无霸战争与“小个子”崛起

如何进行商业模式创新

相关

推荐另一本我读过的Business Model Generation。这是一本教读者怎么去“画”一个商业模式的书。像slide 一样一页一页的书, 能从中读出一些新的思考方式和角度。

Share a script I used today to generate batch of barcodes by using Python.

  1. generate the range of barcode you want.
  2. use label to generate an image.
  3. fill the image generated in step 2 into a PDF and save it.
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

#!/usr/bin/env python3
from itertools import product

from typing import List
from reportlab.lib.pagesizes import A4
from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics.barcode.eanbc import Ean13BarcodeWidget
from reportlab.graphics import renderPDF
from reportlab.pdfgen.canvas import Canvas

PAGESIZE = A4 # choose the final print page size
NUM_LABELS_X = 3 # how many barcodes per line
NUM_LABELS_Y = 5 # how many barcodes per column
BAR_WIDTH = 1.5 # barcode length
BAR_HEIGHT = 51.0 # barcode height
TEXT_Y = 80
BARCODE_Y = 17

LABEL_WIDTH = PAGESIZE[0] / NUM_LABELS_X
LABEL_HEIGHT = PAGESIZE[1] / NUM_LABELS_Y
SHEET_TOP = PAGESIZE[1]

def codes(number):
""" Generate all the possible barcodes
params
number: the range number of each position
"""
for barcode in product(range(10), repeat = number):
yield "".join(map(str, barcode))

def label(ean13: str, description: str) -> Drawing:
"""
Generate a drawing with EAN-13 barcode and descriptive text.
:param ean13: The EAN-13 Code.
:type ean13: str
:param description: Short product description.
:type description: str
:return: Drawing with barcode and description
:rtype: Drawing
"""
print(ean13)
text = String(0, TEXT_Y, description, fontName="Helvetica",
fontSize=10, textAnchor="middle")
text.x = LABEL_WIDTH / 2 # center text (anchor is in the middle)

barcode = Ean13BarcodeWidget(ean13)
barcode.barWidth = BAR_WIDTH
barcode.barHeight = BAR_HEIGHT
x0, y0, bw, bh = barcode.getBounds()
barcode.x = (LABEL_WIDTH - bw) / 2 # center barcode
barcode.y = BARCODE_Y # spacing from label bottom (pt)
label_drawing = Drawing(LABEL_WIDTH, LABEL_HEIGHT)
label_drawing.add(text)
label_drawing.add(barcode)
return label_drawing

def fill_sheet(canvas: Canvas, label_drawings: List[Drawing]):
"""
Simply fill the given ReportLab canvas with label drawings.
:param canvas: The ReportLab canvas
:type canvas: Canvas
:param label_drawing: Contains Drawing of configured size
:type label_drawing: Drawing
"""
index = 0
for u in range(0, NUM_LABELS_Y):
for i in range(0, NUM_LABELS_X):
x = i * LABEL_WIDTH
y = SHEET_TOP - LABEL_HEIGHT - u * LABEL_HEIGHT
if index >= len(label_drawings):
break
renderPDF.draw(label_drawings[index], canvas, x, y)
index += 1

if __name__ == '__main__':
raw_codes = [code for code in codes(3)]
labels = [label("490177241" + code, '') for code in raw_codes[:200]]
total = NUM_LABELS_X * NUM_LABELS_Y
page = 1
while labels:
canvas = Canvas("{}.pdf".format(page), pagesize=PAGESIZE)
page += 1
fill_sheet(canvas, labels[:min(total, len(labels))])
canvas.save()
labels = labels[min(total, len(labels)):]