Medium interview questions

Based on Korean Version 1.9.6 (https://hamait.tistory.com/1054), last updated October 2019.

You are not expected to be 100% knowledgeable about those, but instead show your depth in understanding what you have experience with or is interested in. Focus on what you know well.

Part 1: Blockchain

What are Double spending, Replay attack, Eclipse attack

Part 2: Bitcoin

  • How can we ensure the integrity of Bitcoin transactions? How do you trust the previous output in the input of the next transaction?
  • What’s bloom filter SPV in Bitcoin?

Part 3: Ethereum

  • What’s the difference between Transaction and Raw Trasaction?
  • What’s nonce in an Ethereum transaction? Why is there no nonce in Bitcoin?

Part 4: Hyperledger fabric

  • Explain the transaction flow of Hyperledger fabric
  • What is MVCC Collision and Optimistic Lock on Hyperledger Fabric?
  • What is MSP in Hyperledger Fabric
  • What are channel MSPs and network MSPs in a Hyperledger fabric?
  • What’s nonce in Hyperledger fabric. What is the difference with Ethereum’s?
  • How events are created in Hyperledger fabric, how can the client know about an event?

Part 5: EOS

Part 6: Hyperledger Indy

Part 7: Consensus

  • What are the advantages and disadvantages of the E-O-V consensus process in Hyperledger Fabric?

Part 8: Software

  • Tell us about three design patterns you usually use. Write the pseudo-code Implementation of Observer Pattern
  • Implement pseudo-code to distribute work among multiple threads and wait for them to finish
  • Give me three examples of how to waste space (memory) to improve performance
  • What is padding, packing in memory alignment?

Part 9: Java

  • Explain Java’s method argument passing method. What’s Shallow Copy / Deep Copy.
  • What is the logic error of the following servlet call code (target is exected once after passing through filters)?
//// Filter 
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

        ...  인코딩처리 OR
        ...  로깅처리 OR
        ...  인증처리

        chain.doFilter(request, response);
     
        ...  
}

//// FilterChain

public class FilterChain { 
   private List filters = new ArrayList(); 
   private Target target; 
   
   int currentFilter = 0; 

   public void addFilter(Filter filter){ 
      filters.add(filter); 
   } 

   public Filter getNextFilter(){ 
      if(currentFilter < filters.size()){ 
           return filters.get(currentFilter++); 
      } 
      return null; 
   } 
   public void doFilter(String request, String response){ 
         Filter f = getNextFillter(); 
         if(f != null){  
           f.doFilter(request,response,this);         
         } 
           
         target.execute(request,response); 
   } 

   public void setTarget(Target target){ 
      this.target = target; 
   } 
} 

Part 10: C++

  • What’s important about performance degradation and enhancements in C ++
  • Parse a single line to collect space-separated words, then code them to print out the word and the number of duplicates. (Performance and memory optimization
  • Write a function that takes a string as a parameter and returns a string with certain characters removed. (With performance optimization)
  • Briefly describe the auto / override / nullptr / constexpr / atomic keywords in C ++
  • Please explain the following code in C ++. (Consumers in the producer-consumer pattern, and there is only one consumer here)
Buffer BufferPool::get_buf(){   
   Buffer* buf = nullptr;
   std::unique_lock<std::mutex> ul(_mtx, std::defer_lock);

   while (buf == nullptr){
    ul.lock();
    if (_pool.empty()) _cond.wait(ul);

    if (!_pool.empty())  // 여기서 pool 이 empty 일 경우는?
    {
       buf = _pool.get();
    }
  }

   .... DO something ....
  return buf;
}

Part 11: Go

  • How is the select statement used in Go? Please explain the code below.
package main

import (
   "fmt"
   "time"
)

var scheduler chan string

func consuming (prompt string){
      fmt.Println("consuming 호출됨")
   select {
   case scheduler <- prompt:
      fmt.Println("이름을 입력받았습니다 : ", <- scheduler)
   case <-time.After(5 * time.Second):
      fmt.Println("시간이 지났습니다.")
   }
}

func producing (console chan string) {
   var name string
   fmt.Print("이름:")
   fmt.Scanln(&name)
   console <- name
}
func main() {
   console := make(chan string, 1)
   scheduler = make(chan string, 1)

   go func(){
      consuming(<-console)
   }()

   go producing(console)

   time.Sleep(100 * time.Second)
}

Part 12: Javascript

  • What are built-in Javascript objects / browser objects / HTML DOM objects
  • What is the difference between ajax and websocket communication
  • Show your previous works in React & CSS Styling

Part 13: Distributed systems

  • What is consistent hashing?
  • What is HAProxy?
  • What is Zookeeper and give two examples where you should use it

Part 14: Compilers

  • How does EOS charge for resources?
  • How to compute CPU, Memory and Storage usage in a program written in C ++ or Go?

Part 15: Cryptography

  • What is HMAC / PKI / ECDSA / ECDH
  • What is ECert in Hyperledger Fabric? Why does Hyperledger fabric use it?
  • How are zero knowledge proofs used in Fabric Identity Mixer?

Part 16: Database

  • Compare Red Black tree & B tree & Skip lists data structures.

Part 17: Messaging

Part 18: Networking / Socket

  • Tell me as much as you know the difference between socket communication between multithreaded / Select / Java NIO / ePoll / IOCP.

Experience with the following tools

  • Agile Management Techniques (* JIRA)
  • Product & Configuration Management (Bitbucket)
  • Containerization like Docker + Coobernate
  • Build Automation (* Bamboo)
  • Test Automation (* Unit Test gTest Study)
  • Issue Registration Automation (* JIRA)
  • Information sharing wiki management (confluence)
  • Information sharing chat management (slack)
  • Deployment Automation
  • Service Management Automation
  • Understanding Your Networking Infrastructure
  • Understanding Vertical / Horizontal Segmentation
  • Understanding and building a non-stop system (extending non-stop resources, etc.)
  • AWS Management

How to install nvm

This is a follow up to [How to install npm the right way]. It turns out that while convenient for Node development, nvm is notoriously slow. Thanks to reddit user sscotth we can solve that quite easily.

First, install nvm normally

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

Then find the lines nvm added to your .rc file (bashrc or zshrc), delete that shit

# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Next, add this to your .rc file

declare -a NODE_GLOBALS=(`find ~/.nvm/versions/node -maxdepth 3 -type l -wholename '*/bin/*' | xargs -n1 basename | sort | uniq`)

NODE_GLOBALS+=("node")
NODE_GLOBALS+=("nvm")

load_nvm () {
    export NVM_DIR=~/.nvm
    [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
}

for cmd in "${NODE_GLOBALS[@]}"; do
    eval "${cmd}(){ unset -f ${NODE_GLOBALS}; load_nvm; ${cmd} \$@ }"
done

Your globally installed programs like create-react-app will still use the current version of node, while it only loads once and not boggle down your terminal startup everytime.

Win-win

Gõ tiếng Việt trên Ubuntu

Cách gõ Dvorak trên Ubuntu với ibus-unikey

Các bộ gõ tiếng Việt trên ubuntu

  • ibus-unikey là bộ gõ có sẵn trong source, dễ cài nhất nhưng có vấn đề bị revert keyboard như ở trên
  • ibus-teni (telex-vni) mới hơn
  • ibus-bamboo: cùng tiêu chí với teni, bộ gõ mới nhất, được cập nhật thường xuyên, hỗ trợ nhiều chế độ gõ cho nhiều ứng dụng khác nhau, tuy nhiên chưa được nổi tiếng như ibus-unikey vì hầu hết các tài liệu hướng dẫn đều viết về ibus-unikey (có lẽ vì unikey namesake quá nổi tiếng trên Windows)

Install IP Time USB Wifi Adapter driver for Ubuntu Linux

It’s not that hard… provided you know where to look.

First, find out the model ID by going

lsusb

You’ll get something like this, where “Realtek” is the chip manufacturer, which is usually the case for IPTime

Next, google the ID, it will take you to stack overflow, in my case, this answer

Which leads me to this repository

A few commands later…

cd rtl88x2BU_WiFi_linux_v5.3.1_27678.20180430_COEX20180427-5959
VER=$(sed -n 's/\PACKAGE_VERSION="\(.*\)"/\1/p' dkms.conf)
sudo rsync -rvhP ./ /usr/src/rtl88x2bu-${VER}
sudo dkms add -m rtl88x2bu -v ${VER}
sudo dkms build -m rtl88x2bu -v ${VER}
sudo dkms install -m rtl88x2bu -v ${VER}
sudo modprobe 88x2bu

And voila, it works even without a reboot

How to type in Dvorak but keep Qwerty shortcuts

Every Dvorak user knows the pain: shortcuts in every program on earth is designed with Qwerty in mind. Cut – Copy – Paste is supposed to be next to each other but it’s not so in Dvorak.

As A Dvorak user, I’ve had to find and try many solutions for this problem over the years. It involved all sort of hacks and modifications to the deepest parts of the operating system: creating custom keyboard layouts, modifying the registry, write a new input method etc. Even so, it didn’t work in some applications (looking at you, IntelliJ, Java and Firefox – the bugs isn’t even fixed yet, and they are almost 10 years old!).

Almost 10 years later, in 2019, I finally found solutions that work for all major operating systems, and here they are:

MacOS

Apple makes great software, even though I don’t like their business practices, that’s an undeniable fact. MacOS is the simplest of the three OSes: Simply add Dvorak-QWERTY as an input method and you are good to go!

Windows

Used to be the second-easiest OS to work with, but recently Microsoft started cracking down on custom software and drivers so any custom keyboard layout not provided by them will get wiped out (and basically becomes very buggy with Windows 8 and up).

My solution? Use AutoHotKey! Yes, it’s an extra install, but it works reliably across all machines I’ve used with little setup required.

How to use Dvorak-QWERTY with AutoHotKey on Windows

  1. Install and set a Dvorak layout as your default (which language doesn’t matter)
  2. Install AutoHotKey
  3. Save this gist to your machine
  4. Optional: Convert the .ahk file to .exe with AutoHotKey so you can use it elsewhere without AHK
  5. Put the .ahk file in your startup folder
  6. Profit!

Notes about the AHK script

  • It will switch the layout to Qwerty when control keys or a combination of them is pressed (Ctrl, Alt, Win, Ctrl + Alt, Ctrl + Win)
  • It will disable itself when the input language is Korean (code = 68289554) so you can type Korean characters uninterfered. You can find similar code for Japanese, Chinese, etc. using AHK’s inspection tool
  • It will disable itself when scroll lock is on. This is for exceptional cases when you want to use Qwerty without pressing modifiers key
  • If you need additional combination of control keys, you must copy a whole section and add the control keys manually. For some reason, AHK’s * doesn’t work properly with control keys no there’s no way to make the script shorter

Linux

What worked for me: modifying the xkb keymaps! This idea came when I tried to replicate the AutoHotKey solution on Linux. I found source code of past projects that tried to achieve this. Sadly no step by step guide on how to apply them. Here’s how:

  • Press the plus button
  • Choose English (United States)
  • Choose any of the English (Dvorak-Qwerty), the flavor you prefer
  • Now switch the keyboard layout to your newly added layout
  • You’re done!

Conclusion

Dvorak is a good ergonomic layout but it hasn’t seen more widespread adoption due to entry barriers like the QWERTY shortcut problem. I hope this post solved part of that problem.