Docker create and push image

  1. create a dockerhub account and create repository
    here I call it “backend-server”


		


setup https for wordpress with docker

1. install docker-ce

https://docs.docker.com/install/linux/docker-ce/debian/

2. install docker-compose



		


3. setup domain name, and link it to the node you are setting up your web server; install letsencrypt on the webserver



		


4. install wordpress using docker with the docker-compose.yml below
https://docs.docker.com/compose/wordpress/; and do “sudo docker-compose up -d”



		


5. after start the wordpress docker container,



		


6. login to the wordpress docker container and do following



		


7. shutdown the container and put the letsencrypt key and certificate combo to the ~/blog/etc/apache2 folder



		


8. modify the docker-compose.yml file add the following two lines



		


9. start docker containers again and turn on the ssl redirect plugin



		



Multiprocessing 1

I have been using python multiprocessing for quite a bit time, but it was all simple pool and I would like to understand deeper than just blindly using the multiprocessing package.

  1. given a list of word and start two process to print out the list in sequence

The same functionality can also be achieved using pipe

672. Bulb Switcher II

There is a room with n lights which are turned on initially and 4 buttons on the wall. After performing exactly m unknown operations towards buttons, you need to return how many different kinds of status of the n lights could be.

Suppose n lights are labeled as number [1, 2, 3 …, n], function of these 4 buttons are given below:

  1. Flip all the lights.
  2. Flip lights with even numbers.
  3. Flip lights with odd numbers.
  4. Flip lights with (3k + 1) numbers, k = 0, 1, 2, …

Example 1:

Example 2:

Example 3:

Note: n and m both fit in range [0, 1000].

 

 

670. Maximum Swap

Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get.

Example 1:

Example 2:

Note:

  1. The given number is in the range [0, 108]

 

669. Trim a Binary Search Tree

Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so the result should return the new root of the trimmed binary search tree.

Example 1:

Example 2:

671. Second Minimum Node In a Binary Tree

Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. If the node has two sub-nodes, then this node’s value is the smaller value among its two sub-nodes.

Given such a binary tree, you need to output the second minimum value in the set made of all the nodes’ value in the whole tree.

If no such second minimum value exists, output -1 instead.

Example 1:

Example 2:

666. Path Sum IV

Given a list of ascending three-digits integers representing a binary with the depth smaller than 5. You need to return the sum of all paths from the root towards the leaves.
If the depth of a tree is smaller than 5, then this tree can be represented by a list of three-digits integers.
For each integer in this list:
  1. The hundreds digit represents the depth D of this node, 1 <= D <= 4.
  2. The tens digit represents the position P of this node in the level it belongs to, 1 <= P <= 8. The position is the same as that in a full binary tree.
  3. The units digit represents the value V of this node, 0 <= V <= 9.
Example 1:

Example 2:

665. Non-decreasing Array

Example 1:

Example 2:

Note: The n belongs to [1, 10,000].

 

 

667. Beautiful Arrangement II

Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n and obeys the following requirement:
Suppose this list is [a1, a2, a3, … , an], then the list [|a1 – a2|, |a2 – a3|, |a3 – a4|, … , |an-1 – an|] has exactly k distinct integers.

If there are multiple answers, print any of them.

Example 1:

Example 2:

Note:

  1. The n and k are in the range 1 <= k < n <= 104.