How serious is COVID-19?

It’s the new viral disease caused by the novel SARS CoV-19 virus, it causes cough, sneezing, fever, diarrhea, those who are more ill develop a viral pneumonia people can die of, overal mortality in general is 2,3%, higher in males 2,8% than in female 1,7%, higher in the elderly: in those <50 yo <0,5%, in those >80 yo approaching 15%. 80% of those infected aren’t sick, but are infectious anyway, thus makes recognizing who is infected so very, very hard. Infection is by droplets of saliva containing the virus formed when coughing and sneezing, all those who cough and sneeze should wear a simple facemask to prevent saliva droplets from reaching other people.

Posted in Uncategorized | Leave a comment

Irrigation

    According to the requirements of crop water demand, artificially to the farmland to replenish water and other measures of farmland. Irrigation can meet the demand for water for crops in time, improve soil water, fertilizer, gas, heat and salt, improve the microclimate of farmland, and achieve the goal of increasing agricultural production.

    China is one of the earliest countries in the world to develop farmland irrigation. Qin and Han before the irrigation of farmland is called “immersion”, to the Han Dynasty has the name of “over- " or “irrigation”, the West Han time “irrigation” and “irrigation”, “irrigation” and use. After Tang used to use the word “irrigation”, and continue to use it to this day.

    Irrigation PrincipleS Crops require a lot of moisture from seed germination to plant maturation. Crop water demand includes both physiological water and ecological water demand. Crop physiological water demand refers to the water required for various physiological activities (such as steaming, photosynthesis, etc.) in the course of crop life, and the water needed for the development and development of crops in the process of fertility. The former is represented by leaf steaming, which accounts for about 60 to 80% of the amount of water needed for crops, while the latter is represented by evaporation between plants, which represents about 20 to 40% of the amount of water needed for crops. If the amount of water absorbed by the plant is less than the amount of water consumed, i.e. when the water balance in the plant is out of balance, light causes temporary wilting and heavy dry death. Atmospheric drought or soil drought will cause the crop stems and leaves to suffer in varying degrees of wilting, resulting in the weakening of photosynthesis, affecting the production and accumulation of organic matter, while the root system water absorption function is weak, the body organic nutrient transport is destroyed. Water scarcity is more harmful to young crops and organs.

detail Irrigation

Posted in Uncategorized | Leave a comment

Museum of Nature

    Collection, production and display of historic specimens of astronomy, geology, plants, animals, paleontology and humans for scientific research and cultural education. Also known as the Natural History Museum.

    A brief history Of the prototype of the Modern Museum of Nature, dating back to the 17th century in Europe. Initially for a few private collectors or palace collections, it was gradually opened to the public, becoming a place for publicity, popularization of scientific and cultural knowledge, and gradually developed into a modern museum form. The Ahsimolin Museum in Oxford, England, founded in 1683, may be the earliest museum ever created. In 1716, Russia established the Museum of Mineralogy in St. Petersburg. In 1753, the British Museum of Nature was established in London. In 1794, paris established the French National Museum of Nature. Subsequent lying were the first museums in the world, such as the American Museum of Nature in New York, the Royal Belgian Museum of Natural Science in Brussels, the Swedish National Museum of Nature in Stockholm, and the National Museum of Science in Tokyo. Development has been particularly rapid since the 1950s, with more than 30,000 natural museums of various types, according to incomplete statistics.

detail Museum of Nature

Posted in Uncategorized | Leave a comment

Price Economics

    A discipline to study the formation of commodity prices and the regularity of their movements.

    The development of price theory as early as the 7th century BC, China recorded the management of the economic thought of the “tube” book, there is a discussion on the change of market price: “the collection is heavy, the hair is light”, “the people are lighter, the people are less than”; Gold is heavy and light,” “the valley is heavy and everything is light, the valley is light and everything is heavy”, “the currency is heavy and everything is light, the coin is light and everything is heavy”. In the 6th century B.C., Fan Wei put forward the “drought boat, water is a car”, advocated that in the society is not in urgent need of a certain commodity pre-storage, waiting for the time to sell at a high price, indicating that Fan Wei has understood the relationship between supply and demand and price, the use of price changes for profit. In the 5th century B.C., Li said, advocating that the government buy at low grain prices, high grain prices when selling, swallow inggling grain to stabilize grain prices and adjust supply and demand. Although the ancient Chinese thinkers have made exploration and research on the theory of price, because China has been stagnant in feudal society for a long time, the commodity economy is underdeveloped, and the price theory has been limited to the discussion of how the government can stabilize the price of flatness and parity theory (see the theory of loss and equalization).

detail Price Economics

Posted in Uncategorized | Leave a comment

Care for children

    Health and technical measures related to the prevention and treatment of diseases and the promotion of health in childhood. Including treatment operations, general care, preventive health care, feeding, mental health and corrections. Children live most of the time in the family or child care institutions, so nursing work is not only the responsibility of paediatric nurses, children's relatives, kindergarten care workers and school teachers, should master the knowledge and skills of child care, such as how to judge children's growth, development is normal, how to observe the severity of the disease, To distinguish what circumstances can be treated at home, those symptoms should be treated in the hospital, etc.

detail care for children

Posted in Uncategorized | Leave a comment

Arctic ocean

The world's smallest and coldest ocean. Located at the northernmost tip of the earth, largeto the Arctic as its center, the Arctic Circle is the ocean surrounded by the northern coasts of Asia, Europe and North America.

Read More Arctic ocean

Posted in Uncategorized | Leave a comment

Northern wei dynasty

    After the division of the 16 countries, the unified feudal dynasty was rebuilt in northern China. one of the Northern Dynasty dynasties. The Ministry of Tuo-Tui-tao is built by the fresh-and-humble nobles (see Wei Daowu Emperor).

Read more Northern wei dynasty

Posted in Uncategorized | Leave a comment

Golang Getting Started Series 7: Use of redis

The previous talk is about some basic knowledge of the Go language. If you are interested, you can take a look at the previous article. http://quickintro123.com/index.php/category/golang/

Let's talk about how to use Redis in go today.
 

Installation

  1. The installation of Redis is very simple. I use the windows version directly for testing. How to install will not go into details. Want to know can read the previous article: https://quickintro123.com/index.php/2019/03/02/golang-entry-series-1-go-environment-construction/
     
  2. golang client, using go-redis,
  • go get github.com/go-redis
  • Then import this package in the code:
import &quot;github.com/go-redis/redis&quot;

Basic operation

Create Redis Connection Client

You can create a redis client through the redis.NewClient function. This method receives a redis.Options object parameter. Through this parameter, we can configure redis-related properties, such as the redis server address, database name, database password, and so on.
// create redis client

func GetRedisClient() *Client {
    redisdb := NewClient(&Options{
        Addr:     "127.0.0.1:6379",
        Password: "", // no password set
        DB:       0,  // use default DB
    })

    pong, err := redisdb.Ping().Result()
    if err != nil {
        fmt.Println(pong, err)
    }
    return redisdb
}

Cient.Ping () to check if you have successfully connected to the redis server

String operation

  • Set (key, value): assign a value to the string named key in the database valueget (key): return the value of the string named key in the database
  • GetSet (key, value): assign the last value to the string named key
  • MGet (key1, key2,…, key N): Returns the value of multiple strings in the library
  • SetNX (key, value): add string, name is key, value is value
  • SetXX (key, time, value): add string to the library, set the expiration time time
  • MSet (key N, value N): set multiple string values in batches
  • MSetNX (key N, value N): if all strings named key i do not exist
  • Incr (key): Increment 1 by the string named key
  • Incrby (key, integer): add integer to the string named key
  • Decr (key): subtract 1 from the string named key
  • Decrby (key, integer): reduce the integer for the string named key
  • Append (key, value): The value of the string named key is appended with valuesubstr (key, start, end): Returns the substring of the value of the string named key
func StringDemo() {
    fmt.Println("-----------------------welcome to StringDemo-----------------------")
    redisClient:=GetRedisClient()
    if redisClient ==nil{
        fmt.Errorf("StringDemo redisClient is nil")
        return
    }

    name := "Jack"
    key :="name:Jack"
    redisClient.Set(key , name,1 * time.Second)
    val := redisClient.Get(key)
    if val == nil {
        fmt.Errorf("StringDemo get error")
    }
    fmt.Println("name", val)
}

List operation

  • RPush (key, value): Add a value element to the end of the list named key
  • LPush (key, value): add a value element to the head of the list named key
  • LLen (key): Returns the length of the list named key
  • LRange (key, start, end): Returns the elements in the list named key from start to end
  • LTrim (key, start, end): intercept the list named key
  • LIndex (key, index): Returns the element at index position in the list named key
  • LSet (key, index, value): assign a value to the element at index position in the list named key
  • LRem (key, count, value): delete the value element from the list of count keys
  • LPop (key): return and delete the first element in the list named key
  • RPop (key): return and delete the tail element in the list named key
  • BLPop (key1, key2, ... key N, timeout): The block version of the lpop command.
  • BRPop (key1, key2, ... key N, timeout): Block version of rpop.
  • RPopLPush (srckey, dstkey): Returns and deletes the tail element of the list named srckey, and adds this element to the head of the list named dstkey
func ListDemo(){
    fmt.Println("-----------------------welcome to ListDemo-----------------------")
    redisClient:=GetRedisClient()
    if redisClient == nil {
        fmt.Errorf("ListDemo redisClient is nil")
        return
    }
    articleKey := "article"
    result,err:=redisClient.RPush(articleKey, "a","b","c").Result() //
    if err!=nil {
        fmt.Println(err)
        return
    }
    fmt.Println("result:",result)

    result,err = redisClient.LPush(articleKey, "d").Result() //
    if err!=nil {
        fmt.Println(err)
        return
    }
    fmt.Println("result:",result)

    length, err := redisClient.LLen(articleKey).Result()
    if err != nil {
        fmt.Println("ListDemo LLen is nil")
    }
    fmt.Println("length: ", length) 

    mapOut,err1:=redisClient.LRange(articleKey,0,100).Result()
    if err1!=nil {
        fmt.Println(err1)
        return
    }
    for inx, item := range mapOut {
        fmt.Printf("\n %s:%s", inx, item)
    }
}

Hash operations

  • HSet (key, field, value): add element field to the hash named key
  • GetHGet (key, field): Returns the value corresponding to the field in the hash named key
  • HMget (key, (fields)): returns the value corresponding to field i in the hash named key
  • HMset (key, (fields)): add element field to the hash named key
  • InHIncrby (key, field, integer): increase the value of field in the hash named key by integer
  • HExists (key, field): Whether a field with key field exists in the hash named key
  • HDel (key, field): delete the field whose key is field in the hash named key
  • HLen (key): Returns the number of elements in the hash named key
  • KeyHKeys (key): Returns all keys in the hash named key
  • ValHVals (key): Returns the value corresponding to all keys in the hash named key
  • HGetall (key): Returns all keys (field) in the hash named key and their corresponding values
func HashDemo() {
    fmt.Println("-----------------------welcome to HashDemo-----------------------")
    redisClient := GetRedisClient()
    if redisClient == nil {
        fmt.Errorf("HashDemo redisClient is nil")
        return
    }
    article := Article{18, "test22222", "test22222test22222test22222", 10, 0}
    articleKey := "article:18"

    redisClient.HMSet(articleKey, ToStringDictionary(&article))
    mapOut := redisClient.HGetAll(articleKey).Val()
    for inx, item := range mapOut {
        fmt.Printf("\n %s:%s", inx, item)
    }
    fmt.Print("\n")

    redisClient.HSet(articleKey, "Content", "test")
    mapOut = redisClient.HGetAll(articleKey).Val()
    for inx, item := range mapOut {
        fmt.Printf("\n %s:%s", inx, item)
    }
    fmt.Print("\n")

    view, err := redisClient.HIncrBy(articleKey, "Views", 1).Result()
    if err != nil {
        fmt.Printf("\n HIncrBy error=%s ", err)
    } else {
        fmt.Printf("\n HIncrBy Views=%d ", view)
    }
    fmt.Print("\n")

    mapOut = redisClient.HGetAll(articleKey).Val()
    for inx, item := range mapOut {
        fmt.Printf("\n %s:%s", inx, item)
    }
    fmt.Print("\n")

}

connection pool

go-redis has implemented redis connection pool management, so we don't need to manually manage redis connections by ourselves.

By default, the connection pool size is 10. You can set the size of the redis connection pool to 5 through the PoolSize property of redis.Options.

func GetRedisClientPool() *Client{
    redisdb := NewClient(&amp;Options{
        Addr: &quot;127.0.0.1:6379&quot;,
        Password: &quot;&quot;,
        DB: 0,
        PoolSize: 5,})

    pong, err := redisdb.Ping().Result()
    if err != nil {
        fmt.Println(pong, err)
    }
    return redisdb
}
// test
func connectPoolTest() {
    fmt.Println(&quot;-----------------------welcome to connect Pool Test-----------------------&quot;)
    client :=GetRedisClientPool()
    wg := sync.WaitGroup{}
    wg.Add(10)

    for i := 0; i &lt; 10; i++ {
        go func() {
            defer wg.Done()

            for j := 0; j &lt; 1000; j++ {
                client.Set(fmt.Sprintf(&quot;name%d&quot;, j), fmt.Sprintf(&quot;xys%d&quot;, j), 0).Err()
                client.Get(fmt.Sprintf(&quot;name%d&quot;, j)).Result()
            }

            fmt.Printf(&quot;PoolStats, TotalConns: %d, IdleConns: %d\n&quot;, client.PoolStats().TotalConns, client.PoolStats().IdleConns);
        }()
    }

    wg.Wait()
}

Complete code

package main

import (
    &quot;fmt&quot;
    . &quot;github.com/go-redis/redis&quot;
    . &quot;redisDemo/models&quot;
    &quot;time&quot;
    &quot;sync&quot;
)

func main() {
    fmt.Println(&quot;-----------------------welcome to redisdemo-----------------------&quot;)
    //StringDemo()
    //ListDemo()
    //HashDemo()
    connectPoolTest()
}

func StringDemo() {
    fmt.Println(&quot;-----------------------welcome to StringDemo-----------------------&quot;)
    redisClient:=GetRedisClient()
    if redisClient ==nil{
        fmt.Errorf(&quot;StringDemo redisClient is nil&quot;)
        return
    }

    name := &quot;Jack&quot;
    key :=&quot;name:Jack&quot;
    redisClient.Set(key , name,1 * time.Second)
    val := redisClient.Get(key)
    if val == nil {
        fmt.Errorf(&quot;StringDemo get error&quot;)
    }
    fmt.Println(&quot;name&quot;, val)
}

func ListDemo(){
    fmt.Println(&quot;-----------------------welcome to ListDemo-----------------------&quot;)
    redisClient:=GetRedisClient()
    if redisClient == nil {
        fmt.Errorf(&quot;ListDemo redisClient is nil&quot;)
        return
    }
    articleKey := &quot;article&quot;
    result,err:=redisClient.RPush(articleKey, &quot;a&quot;,&quot;b&quot;,&quot;c&quot;).Result() //Add an element with value to the end of the list named key
    if err!=nil {
        fmt.Println(err)
        return
    }
    fmt.Println(&quot;result:&quot;,result)

    result,err = redisClient.LPush(articleKey, &quot;d&quot;).Result() //Add a value element to the head of the list named key
    if err!=nil {
        fmt.Println(err)
        return
    }
    fmt.Println(&quot;result:&quot;,result)

    length, err := redisClient.LLen(articleKey).Result()
    if err != nil {
        fmt.Println(&quot;ListDemo LLen is nil&quot;)
    }
    fmt.Println(&quot;length: &quot;, length) 

    mapOut,err1:=redisClient.LRange(articleKey,0,100).Result()
    if err1!=nil {
        fmt.Println(err1)
        return
    }
    for inx, item := range mapOut {
        fmt.Printf(&quot;\n %s:%s&quot;, inx, item)
    }
}

func HashDemo() {
    fmt.Println(&quot;-----------------------welcome to HashDemo-----------------------&quot;)
    redisClient := GetRedisClient()
    if redisClient == nil {
        fmt.Errorf(&quot;HashDemo redisClient is nil&quot;)
        return
    }
    article := Article{18, &quot;test22222&quot;, &quot;test22222test22222test22222&quot;, 10, 0}
    articleKey := &quot;article:18&quot;

    redisClient.HMSet(articleKey, ToStringDictionary(&amp;article))
    mapOut := redisClient.HGetAll(articleKey).Val()
    for inx, item := range mapOut {
        fmt.Printf(&quot;\n %s:%s&quot;, inx, item)
    }
    fmt.Print(&quot;\n&quot;)

    redisClient.HSet(articleKey, &quot;Content&quot;, &quot;test&quot;)
    mapOut = redisClient.HGetAll(articleKey).Val()
    for inx, item := range mapOut {
        fmt.Printf(&quot;\n %s:%s&quot;, inx, item)
    }
    fmt.Print(&quot;\n&quot;)

    view, err := redisClient.HIncrBy(articleKey, &quot;Views&quot;, 1).Result()
    if err != nil {
        fmt.Printf(&quot;\n HIncrBy error=%s &quot;, err)
    } else {
        fmt.Printf(&quot;\n HIncrBy Views=%d &quot;, view)
    }
    fmt.Print(&quot;\n&quot;)

    mapOut = redisClient.HGetAll(articleKey).Val()
    for inx, item := range mapOut {
        fmt.Printf(&quot;\n %s:%s&quot;, inx, item)
    }
    fmt.Print(&quot;\n&quot;)

}

func GetRedisClient() *Client {
    redisdb := NewClient(&amp;Options{
        Addr:     &quot;127.0.0.1:6379&quot;,
        Password: &quot;&quot;, // no password set
        DB:       0,                 // use default DB
    })

    pong, err := redisdb.Ping().Result()
    if err != nil {
        fmt.Println(pong, err)
    }
    return redisdb
}

func GetRedisClientPool() *Client{
    redisdb := NewClient(&amp;Options{
        Addr: &quot;127.0.0.1:6379&quot;,
        Password: &quot;&quot;,
        DB: 0,
        PoolSize: 5,})

    pong, err := redisdb.Ping().Result()
    if err != nil {
        fmt.Println(pong, err)
    }
    return redisdb
}

// test
func connectPoolTest() {
    fmt.Println(&quot;-----------------------welcome to connect Pool Test-----------------------&quot;)
    client :=GetRedisClientPool()
    wg := sync.WaitGroup{}
    wg.Add(10)

    for i := 0; i &lt; 10; i++ {
        go func() {
            defer wg.Done()

            for j := 0; j &lt; 1000; j++ {
                client.Set(fmt.Sprintf(&quot;name%d&quot;, j), fmt.Sprintf(&quot;xys%d&quot;, j), 0).Err()
                client.Get(fmt.Sprintf(&quot;name%d&quot;, j)).Result()
            }

            fmt.Printf(&quot;PoolStats, TotalConns: %d, IdleConns: %d\n&quot;, client.PoolStats().TotalConns, client.PoolStats().IdleConns);
        }()
    }

    wg.Wait()
}

At last

Go language is very simple to use Redis, the basic usage of Redis has been covered above. You can try it yourself.

Posted in development, golang | Tagged , , | 107 Comments

Golang Getting Started Series 6: understand Goroutine

The previous talk is about some basic knowledge of the Go language. If you are interested, you can take a look at the previous article. http://quickintro123.com/index.php/category/golang/

Today, let's talk about the advanced functions in go, which is also an important feature of the go language: Goroutine.

What is a Goroutine?

A Goroutine is a function that runs simultaneously with other functions. You can think of Goroutine as lightweight threads that are managed by the Go runtime.

Add the go keyword before the function call, and this call will be executed concurrently in a new goroutine. When the called function returns, this goroutine also ends automatically. It sounds like Task in C#.

It should be noted that if this function has a return value, the return value will be discarded.

Goroutine communicate through channels, which is simply a communication channel between multiple goroutines. Channels can prevent resource contention when multiple goroutines access shared memory.

How to use

package main

import (  
    "fmt"
    "time"
)

func hello() {  
    fmt.Println("Hello world goroutine")
}
func main() {  
    go hello()
    time.Sleep(1 * time.Second)
    fmt.Println("main function")
}

Channel

Channel can be thought of as a channel of communication between goroutines. Just as water flows from one end of the pipe to the other, data can be sent from one end of the channel and received at the other.

1. Definitions

Each channel has a type. This type is the type of data that the channel is allowed to transmit. Channels are type-dependent. A channel can only pass one type of value. This type needs to be specified when the channel is declared.

2. Declarations

a. We need to create a channel through the built-in function make.

The following code declares a channel:

var ch chan int

b. As with other variable definitions, quick declarations are an effective and concise way to define channels:

a := make(chan int) 

c. Create a buffered channel

c := make(chan int, 1024)

// Read data from buffered channel
for i:=range c {
  ...
}

3. Send and receive data

The syntax for sending and receiving data over a channel is as follows:

data := <- a   // read data from channel a
a <- data      // write data to channel a  

The direction of the arrow indicates whether the data is sent or received.

Complete example

Let‘s talk directly about the complete example of Goroutine and channel used together:

Package code

import (
    "fmt"
    "time"
)

func Producer(queue chan<- int) {
    for i := 0; i < 10; i++ {
        queue <- i // Write
        fmt.Println("create :", i)
    }
}

func Consumer(queue <-chan int) {
    for i := 0; i < 10; i++ {
        v := <-queue  // Read out
        fmt.Println("receive:", v)
    }
}

func main() {
    queue := make(chan int, 88)
    go Producer(queue)
    go Consumer(queue)
    time.Sleep(1 * time.Second)
}

At last

Above, I have briefly introduced the goroutines and channels in Go. These two features are important features in the Go language. You can write other examples and get familiar with them.

Posted in development, golang | Tagged , , | 1 Comment

Golang Getting Started Series 5: object-oriented in GO language

I talked a lot about the basics of the Go language, including the installation of the go environment, the syntax of the go language, etc. If you are interested, you can read the previous article first. http://quickintro123.com/index.php/category/golang/

Object-oriented in GO

In fact, GO is not a pure object-oriented programming language. It does not provide the class keyword, only the struct type.

In java or C#, structs cannot have member functions. However, structs in Go can have "member functions". Methods can be added to structures, similar to the implementation of a class.

I personally think that the object-oriented of the Go language is actually simpler and easier to understand.

Anyone who has learned java or C# should know the three basic characteristics of object orientation: encapsulation, inheritance, and polymorphism. I will not elaborate on their definition here. Let ’s take a look at how object-oriented is implemented in the Go language.

1. Encapsulation Features

Golang's mechanism to distinguish between public and private properties is whether the method or property has a capital letter. If the method with a capital letter is public, if it has a lowercase letter, it is private.

package main

import "fmt"

type Person struct {
    name string
}

func (person *Person) setName(name string) {
    person.name = name
}

func (person *Person) GetInfo() {
    fmt.Println(person.name)
}

func main() {
    p := Person{"zhangsan"}
    p.setName("lisi")
    p.GetInfo()
}

2. Inheritance

The inheritance method of the GO language uses an anonymous combination: The Woman structure contains the anonymous field Person, so the attributes in Person also belong to the Woman object.

package main

import "fmt"

type Person struct {
    name string
}

type Woman struct {
    Person
    sex string
}

func main() {
    woman := Woman{Person{"wangwu"}, "woman"}
    fmt.Println(woman.name)
    fmt.Println(woman.sex)
}

  

3. Polymorphic feature

package main

import "fmt"

type Eater interface {
    Eat()
}

type Man struct {
}

type Woman struct {
}

func (man *Man) Eat() {
    fmt.Println("Man Eat")
}

func (woman *Woman) Eat() {
    fmt.Println("Woman Eat")
}

func main() {
    var e Eater

    woman := Woman{}
    man := Man{}

    e = &woman
    e.Eat()

    e = &man
    e.Eat()
}

Finally

In the above, I briefly introduced how to implement object orientation in Go language. In fact, it is similar to java and C#. You can compare them. In summary: Go has no classes, but loosely coupled types and methods to implement the interface.

Posted in development, golang | Tagged , , | 1 Comment