西维蜀黍

【Domain】领域模型(Domain Model)

Domain Models

A domain model is a system of abstractions that describes selected aspects of a sphere of knowledge, influence or activity (a domain). The model can then be used to solve problems related to that domain. The domain model is a representation of meaningful real-world concepts pertinent to the domain that need to be modeled in software. The concepts include the data involved in the business and rules the business uses in relation to that data. A domain model leverages natural language of the domain.

A domain model generally uses the vocabulary of the domain, thus allowing a representation of the model to be communicated to non-technical stakeholders. It should not refer to any technical implementations such as databases or software components that are being designed.

  ...


【Golang】Composition in Golang

Composition vs. Inheritance

Composition and inheritance are two ways to achieve code reuse and build complex systems. Inheritance is a mechanism that allows a class to inherit properties and behavior from a parent class. Composition is a way of building complex objects by combining smaller, simpler objects.

In Go, composition is favored over inheritance. This is because Go does not have classes like traditional object-oriented programming languages. Instead, Go uses structs to define objects and interfaces to define behavior. Composition is achieved by embedding one struct into another.

For example, a solution to compose a simple report in Go can be model as follows:

type celsius float64type temperature struct {
    maximum, minimum celsius
}type location struct {
    latitude, longitude float64
}type report struct {
    sol int
    temperature temperature
    location location
} 
  ...


【Python】Collection - tuple

Tuple

Tuples are used to store multiple items in a single variable.

Tuple is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Set, and Dictionary, all with different qualities and usage.

A tuple is a collection which is ordered and unchangeable.

Tuples are written with round brackets.

  ...


【Hardware】破解 IPMI 密码

Via metasploit

# brew install metasploit

$ msfconsole

msf > use auxiliary/scanner/ipmi/ipmi_dumphashes
msf auxiliary(ipmi_dumphashes) > show options
    ... show and set options ...
msf auxiliary(ipmi_dumphashes) > set RHOSTS ip-range
msf auxiliary(ipmi_dumphashes) > set RHOSTS 192.168.18.30
msf auxiliary(ipmi_dumphashes) > exploit
  ...


【Architecture】System Design - URL Shortener

Scope

Functional Requirements

  • 1

  • 2

    • Candidate: How long is the shortened URL?
    • Interviewer: As short as possible.
  • 3

    • Candidate: What characters are allowed in the shortened URL?
    • Interviewer: Shortened URL can be a combination of numbers (0-9) and characters (a-z, A-Z).
  • 4

  • Candidate: Can shortened URLs be deleted or updated?

  • Interviewer: For simplicity, let us assume shortened URLs cannot be deleted or updated.

  • 5

    • The link may be expired?
  • 6

    • Can a customer create a tiny url of his/her choice or will it always be service generated ? If user is allowed to create customer shortened links, what would be the maximum size of custom url ?
    • Yes user can create a tiny url of his/her choice. Assume maximum character limit to be 16.
  • 7

    • Do we expect service to provide metrics like most visited links ?
    • Yes. Service should also aggregate metrics like number of URL redirections per day and other analytics for targeted advertisements.

Non-Functional Requirements:

  • Service should be up and running all the time
  • URL redirection should be fast and should not degrade at any point of time (Even during peak loads)

Volumn

  • 1
    • Candidate: What is the traffic volume?
    • Interviewer: 100 million URLs are generated per day.
  • 2
    • Any SLA required? E.g., the SLA of URL redirecting
  • 3
    • Serve globally? need to deploy services to be close to users?

Here are the basic use cases:

  1. URL shortening: given a long URL => return a much shorter URL
  2. URL redirecting: given a shorter URL => redirect to the original URL
  3. High availability, scalability, and fault tolerance considerations

Estimation

  • Write operation: 100 million URLs are generated per day.
  • Write operation per second: 100 million / 24 /3600 = 1160
  • Read operation: Assuming ratio of read operation to write operation is 10:1, read operation per second: 1160 * 10 = 11,600
  • Assuming the URL shortener service will run for 10 years, this means we must support 100 million * 365 * 10 = 365 billion records.
  • Assume average URL length is 100.
  • Storage requirement over 10 years: 365 billion * 100 bytes * 10 years = 365 TB
  ...