Good to know about ECMAScript6

  • Variation hoisting

  • Global or local variable?

    var/const/let/[none]

  • Arrow function

    this reference

Good to know about NoSQL

  • NoSQL is non-relational

  • ACID-compliant (only just recently with MongoDB)

    • Atomic/Atomacity: A change will not be saved but rolled back unless the entire transaction is completed.
    • Consistency: No intermediate state from one valid state to another. Always valid states.
    • Isolation: The effect of more than one concurrent transactions is the same as if they happen in sequence.
    • Durability: The data is there no matter whether database is shutdown, failures or crashes.

Miscellanies about Hexo deployment with purification

A scheme for running single docker-hexo server

Start PHP service:

1
docker run --name phpfpm -d -v ~/www:/app php:5.6-fpm

Use a pre-built hexo image:

1
docker run --name myhexo -v ~/blog:/root/blog -d sempr/hexo-al

Don’t forget to make links between containers:

1
docker run -d --name mynginx -p 80:80 -p 443:443 --link phpfpm:phpfpm --link myhexo:myhexo -v ~/https.conf:/etc/nginx/conf.d/default.conf -v ~/1_im.semprathlon.net_bundle.crt:/etc/nginx/ssl/nginx.crt -v ~/2_im.semprathlon.net.key:/etc/nginx/ssl/nginx.key --volumes-from phpfpm nginx

Miscellanies about initializing an Ubuntu Server

Having trouble with Windows SSH: Unprotected private key file

1
2
3
4
5
6
7
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions for 'private' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "private": bad permissions

You can use icacls in windows instead of chmod to adjust file permission.

1
2
icacls .\private.key /inheritance:r
icacls .\private.key /grant:r "%username%":"(R)"

Having trouble with SSH login: connection reset after idle for some time

[Ineffective]

1
ssh -o TCPKeepAlive=true root@host.com

For long term use you should modify /etc/ssh/sshd_config as follows:

1
2
ClientAliveInterval 30
ClientAliveCountMax 60

Error: Got permission denied while trying to connect to the Docker daemon socket

Follow the just a few steps and you do not have to access docker images with superuser privileges.

1
2
3
sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo service docker restart

Add a new sudoer

1
sudo usermod -aG sudo <username>

How to build a minimized docker image for Hexo

To start with, it is not easy for greenhands to write out an appropriate buildfile for hexo in docker.
As is suggested, Alpine is a minimized Linux environment designated for docker images, which appears to be tiny in size.
Yet it is tough to upgrade node and npm if the pulled version of alpine is outmoded, so take a look when choosing the right origin of the mirror.

The version of localization in China:

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
FROM daocloud.io/library/alpine:3.6

MAINTAINER CitruXonve, silveritdean@gmail.com

RUN \
# In China, switch to USTC mirror sources for better efficiancy
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
apk update && apk upgrade && apk add --update wget curl bash nodejs-npm && \
# Resolve error: could not get uid/gid 'nobody'
npm config set unsafe-perm true && \
# In China, use cnpm for better efficiancy
npm install -g cnpm --registry=https://registry.npm.taobao.org

WORKDIR /root

RUN \
cnpm install hexo-cli -g && \
mkdir blog && cd blog && \
# install hexo
cnpm install hexo-cli -g && \
hexo init && cnpm install

WORKDIR /root/blog/

EXPOSE 4000

CMD ["/usr/bin/hexo", "s"]

Otherwise:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
FROM daocloud.io/library/alpine:3.6

MAINTAINER CitruXonve, silveritdean@gmail.com

RUN \
apk update && apk upgrade && apk add --update wget curl bash nodejs-npm && \
# Resolve error: could not get uid/gid 'nobody'
npm config set unsafe-perm true

WORKDIR /root

RUN \
mkdir blog && cd blog && \
# install hexo
npm install hexo-cli -g && \
hexo init && npm install

WORKDIR /root/blog/

EXPOSE 4000

CMD ["/usr/bin/hexo", "s"]
1
docker build -t crxon/alpine-hexo -f hexo-in-docker-alpine .

Run after build:

1
docker run --name myhexo -p 4000:4000 -v ~/blog:/root/blog -d crxon/alpine-hexo:release

Debug:

1
docker run --rm --name myhexo -p 4000:4000 -v ~/blog:/root/blog -it crxon/alpine-hexo:debug /bin/bash

Hello Hexo

Welcome to Hexo! This is the very first post after the blog being rebuilt based on Hexo. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

自动草稿