Skip to content

Instantly share code, notes, and snippets.

@nguyensinhtu
nguyensinhtu / System Design.md
Created July 8, 2020 15:12 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
# some my alias
alias gb='git branch'
alias gd='git diff'
alias gp='git push'
alias gf='git fetch'
alias gs='git status'
alias ...="cd ../.."
alias ....="cd ../../.."
alias cssh="cd ~/.ssh"
# find ssh host by name
# your ssh's config will be
# Host your_host
# Hostname your_ip
# User your_username
_find_host() {
local your_host=$1
host="$( awk -v your_host=$your_host '

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

buildscript {
ext {
grpcVersion = "1.39.0"
protobufVersion = "3.17.3"
protoGenValidateVersion = "0.4.1"
}
}
plugins {
id "com.google.protobuf" version "0.8.16"

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
# Usage: python proto-to-druid-ingestion.py path_to_generated_proto entity_name
from google.protobuf.descriptor import FieldDescriptor, Descriptor
import sys
import json
from typing import Any, Dict, List
import yaml
import importlib
import logging
# minify json to insert into mysql
cat payload.json | sed -e "s/'/''/g" | jq -R -s '.' > minify_json.json
package abc;
import java.util.HashSet;
import java.util.Set;
/**
* @author tu.nguyen12
*/
public class EfficientTeam {
package abc;
import java.util.Arrays;
/**
* @author tu.nguyen12
*/
public class MinimumCost {
private int maxCost = 1000000009;