Posts

How to use gitbook right in local

1. Set up `node.js` env
    ```
    sudo apt-get install nodejs npm
    ```

2. Install Gitbook
    ```
    sudo npm install -g gitbook-cli
    export PATH=$PATH:/opt/node/bin
    ```

3. Clone your `Gitbook` project from `Github`
    ```
    git clone your_github_project_address
    cd your_github_project_address
    ```

4. Install necessary gitbook plugins
    ```
    gitbook install ./
    ```

5. `Build and View` or `Output as pdf`
    ```
    gitbook build .
    gitbook serve .

    gitbook pdf .
    ```

6. Write in local

    https://github.com/GitbookIO/editor-legacy#how-to-install-it-on-linux

How to create an chrome extension

1. See the useless official document

    https://developer.chrome.com/extensions/getstarted

2. See my codes

    https://github.com/yingshaoxo/No_More_Chinese/tree/example-of-chrome-extension

3. Core question

    + [Content scripts](https://developer.chrome.com/extensions/content_scripts) have only limited access to Chrome APIs. This access does not include the API you are trying to use (e.g. `chrome.tabs`). If you need to use that API, you will have to do so in a [background script](https://developer.chrome.com/extensions/background_pages).

Make a always running service in android based on kotlin

### 0. What is `service`?
You could see `service` as a always running program

But by default, a service runs in the same process as the main thread of the application

Therefore, you need to use asynchronous processing in the service to perform resource intensive tasks in the background
___

### 1. Basic idea or resources
Official but you can't understand: [Google Developer Guide](https://developer.android.com/training/run-background-service/create-service.html)

Unofficial but reachable: [tutorials_point](https://www.tutorialspoint.com/android/android_services.htm)
___

### 2. Getting started
+ Create a kotlin file which names `MyService.kt`, and put the following codes in:
```
class MyService : Service() {
    @Nullable
    override fun onBind(intent: Intent): IBinder? {
        return null
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        // Let it continue running until it is stopped.
        Toast.makeText(this, "Service Started&…

Running Jupyter on server

#### 1. install
```
sudo -H pip install jupyter
```

#### 2. create config
```
jupyter notebook --generate-config
```

#### 3. set password
```
jupyter notebook password
```

#### 4. set ip
```
vim ~/.jupyter/jupyter_notebook_config.json
```
```
{
  "NotebookApp": {
    "ip": "0.0.0.0",
  }
}
```

#### 5. run it
```
jupyter notebook
```

Master FFmpeg

#### I just want to see my beautiful face
```
ffplay -window_title "yingshaoxo" -vf hflip /dev/video0
```
___

#### Maybe record my screen with my voice
```
ffmpeg -y -f alsa -i hw:0 -f x11grab -framerate 30 -video_size 1920x1080 -i :0.0+0,0 -c:v libx264 -pix_fmt yuv420p -qp 0 -preset ultrafast ~/Videos/$(date +%F_%A_at_%H:%M:%S).mp4
```
___

#### You got it, I couldn't record without my beautiful face
```
ffmpeg -hide_banner -loglevel info -thread_queue_size 512 -y -f alsa -i hw:0 -thread_queue_size 512 -f x11grab -video_size 1920x1080 -i ":0.0" -thread_queue_size 512 -f v4l2 -video_size 320x240 -i "/dev/video0" -c:v libx264 -crf 30 -preset ultrafast -filter_complex 'overlay=main_w-overlay_w-10:main_h-overlay_h-10' -threads 0 ~/Videos/$(date +%F_%A_at_%H:%M:%S).mp4
```
___

#### Maybe do something to my face (camera)
```
ffmpeg -hide_banner -loglevel info -thread_queue_size 512 -y -f alsa -i hw:0 -itsoffset -1.266 -thread_queue_size 512 -f x11gr…

Best way to fix grub problem

Try the following
```
grub rescue > ls

grub rescue > ls (hd0,msdos2) # let's assume this is the linux partition

grub rescue > set root=(hd0,msdos2)

grub rescue > set prefix=(hd0,msdos2)/boot/grub # or wherever grub is installed

grub rescue > insmod normal # if this produced an error, reset root and prefix to something else ..

grub rescue > normal
```


Run the following after you successfully boot
```
sudo update-grub

sudo grub-install /dev/sdX
# where /dev/sdX is your boot drive.
```


If you have to copy a whole linux system, you could use `Clonezilla`

Master docker for developing

#### 0. Read This
```
FROM ubuntu:17.10

ENV LANG C.UTF-8

RUN apt-get update
RUN apt-get install -y python3
RUN apt-get install -y python3-pip
RUN apt-get install -y python3.6-dev

COPY ./requirements.txt /usr/src/Local_Show/requirements.txt
RUN pip3 install --no-cache-dir -r /usr/src/Local_Show/requirements.txt

COPY . /usr/src/Local_Show/

RUN chmod +x /usr/src/Local_Show/tool.sh

RUN mkdir -p /usr/src/Local_Show/files

EXPOSE 2018

CMD ["bash", "/usr/src/Local_Show/tool.sh", "docker_run"]
```

#### 1. Basic Things
`FROM` indicates what image you are based on.

`ENV LANG C.UTF-8` sets what encoding your system will use, something will wrong in Chinese Showing without it

`RUN` represents every stage you are going, docker will store that stage every time after that line is executed

`COPY` is like `cp`

The important thing is: **`CMD` is always the final line of your docker file, that command should be running forever as long as docker container is running**

#### 2.…