/images/avatar.png

How to set autocomplete in Ubuntu

Mofidy bash.bashrc

1
sudo vi /etc/bash.bashrc

Find those code in the file

1
2
3
4
5
6
7
8
#enable bash completion in interactive shells
#if ! shopt -oq posix; then
#      if [-f  /usr/share/bash-completion/bash_completion ]; then
#          . /usr/share/bash-completion/bash_completion
#      elif [ -f /etc/bash_completion]; then
#           . /etc/bash_completion
#      fi
#fi

Remove #

Like below:

1
2
3
4
5
6
7
8
#enable bash completion in interactive shells
if ! shopt -oq posix; then
     if [-f  /usr/share/bash-completion/bash_completion ]; then
          . /usr/share/bash-completion/bash_completion
      elif [ -f /etc/bash_completion]; then
           . /etc/bash_completion
      fi
fi

Source it

i2.How Many Times Do A Clock’s Hands Overlap In A Day?

Q. How Many Times Do A Clock’s Hands Overlap In A Day?

The most important is not the answer but the way to think and work out problems.

In total 22, because the clock hands approximately overlap at 12:00, 1:05, 2:10, 3:15, 4:20, 5:25, 6:30, 7:35, 8:40, 9:45 and 10:50 twice a day.

Although reaching the wrong answer is fine to an extent, you should avoid these common errors.

  • Don’t just blurt out an answer without thinking it through.
  • If you give the wrong answer, don’t get flustered.
  • Don’t say, “I don’t know.”
  • Don’t sit in silence.

If you just sit in your chair quietly, then the interviewer is not going to know how you came to your answer. Talking the answer out gives the hiring manager valuable insight into how you are able to think.

Miniserve, an elegant file server

Install

You can find it at here: https://github.com/svenstaro/miniserve/releases

Usage

 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
miniserve --help
miniserve 0.4.1
Sven-Hendrik Haase <svenstaro@gmail.com>, Boastful Squirrel <boastful.squirrel@gmail.com>
For when you really just want to serve some files over HTTP right now!

USAGE:
    miniserve [FLAGS] [OPTIONS] [--] [PATH]

FLAGS:
    -u, --upload-files       Enable file uploading
    -h, --help               Prints help information
    -P, --no-symlinks        Do not follow symbolic links
    -o, --overwrite-files    Enable overriding existing files during file upload
        --random-route       Generate a random 6-hexdigit route
    -V, --version            Prints version information
    -v, --verbose            Be verbose, includes emitting access logs

OPTIONS:
    -a, --auth <auth>                    Set authentication (username:password)
    -c, --color-scheme <color_scheme>    Default color scheme [default: Squirrel]  [possible values:
                                         Archlinux, Zenburn, Monokai, Squirrel]
    -i, --if <interfaces>...             Interface to listen on
    -p, --port <port>                    Port to use [default: 8080]

ARGS:
    <PATH>    Which path to serve

Serve single folder

i1.What is the most efficient way to sort a million integers?

Q. What is the most efficient way to sort a million integers?

Time Complexity

Sorting Algorithm Average Case Best Case Worst Case
Bubble Sort O(n^2) O(n) O(n^2)
Insertion Sort O(n^2) O(n) O(n^2)
Selection Sort O(n^2) O(n^2) O(n^2)
Quick Sort O(n.log(n)) O(n.log(n)) O(n^2)
Merge Sort O(n.log(n)) O(n.log(n)) O(n.log(n))
Heap Sort O(n.log(n)) O(n.log(n)) O(n.log(n))
Counting Sort O(n+k) O(n+k) O(n+k)
Radix Sort O(n*k) O(n*k) O(n*k)
Bucket Sort O(n+k) O(n+k) O(n^2)

Space Complexity

Publish python package on Anaconda

Install Conda Packaging Tool

1
conda install conda-build anaconda-client

File Structure

1
2
3
4
5
6
7
8
9
    - home/
        - my_package/
            - my_package/
                - package_lib/
                - setup.py
                - README.md
                - run_test.py
            - build.sh
            - meta.yaml    

meta.yaml

This file tells conda-build how to package files under my_package/

 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
    package:
      name: my_package
      version: 1.1.2
    
    source:
      path: my_package/my_package/
     
    build:
      number: 0
    
    requirements:
      build:
        - python >=3
        - setuptools
      run:
        - python >=3
        - numpy >=1.20
        - scipy
        - pandas
        - scikit-learn >=0.22
        - lightgbm
        - matplotlib
        - seaborn
        - plink >=1.9
    
    test:
      source_files:
        - run_test.py

    about:
      home: https://github.com/JoshuaChou2018
      license: MIT

build.sh

The build.sh script contains methods to compile and install. So we use setuptools to complete the compilation and installation process.