This article is a summary of work and life in February 2023.
R & D code
Linux
Go
A certain project uses some data statistics. For convenience, the map is used to store the quantity. Since it is unordered, the order of the output list is not fixed. It is inconvenient to compare it with the historical version, so the key s need to be sorted and then output.
Test code:
func TestSortCh(t *testing.T) { fmt.Println("sort test...") mapInfo := make(map[string]int) var keys []string mapInfo["Li Dachui"] = 101 mapInfo["Big Hammer"] = 102 mapInfo["Brother Hammer"] = 103 mapInfo["Brother Hammer"] = 104 fmt.Println("keys--------") for key, _ := range mapInfo { fmt.Println(" ", key) keys = append(keys, key) } fmt.Println("-------------\nafter") // sort the array sort.Strings(keys) for _, k := range keys { fmt.Printf("| %v | %v |\n", k, mapInfo[k]) } }
Test Results:
$ go test -run TestSortCh sort test... keys-------- Li Dachui Big Hammer Brother Hammer Brother Hammer ------------- after | Big Hammer | 102 | | Brother Hammer | 103 | | Li Dachui | 101 | | Brother Hammer | 104 | PASS ok go_test/sort_test 0.021s
In golang, Chinese characters are sorted by unicode value. After checking, the unicode value of the keyword is as follows, which is in line with expectations.
big hammer U+5927 Little Hammer U+5C0F Lee Sledgehammer U+674E Hammer brother U+9524
Infinite loop delay
There are 2 ways to loop:
1. Use sleep delay
2. Use timestamp processing.
For the former, if the processing operation itself is time-consuming, the specified time will still be delayed before continuing to the next cycle. In this case, the cycle interval becomes longer than expected.
For the latter, in the above case, a loop is performed directly.
SQL
A certain field of Mysql is datetime, querying this field needs to be converted, the records are as follows:
## Need to add as Logtime, otherwise the query field name is date_formatxxxx select date_format(v.Logtime,"%Y-%m-%d %H:%i:%s") as Logtime from loginInfo v search result: OpTime 2023-02-01 01:01:48 2023-02-01 02:49:37
Format example:
"%Y-%m-%d %H:%i:%s" 2023-02-01 01:01:48 "%Y-%m-%dT%H:%i:%s" 2023-02-01T01:01:48
Format instructions excerpted from the web
date_format()List of function formatters: Specifier Description %a The abbreviated name of the weekday ( Sun~Sat) %b The abbreviated name of the month ( Jan...Dec) %c month, as a number (0~12) %D day of the month with english suffix(0th, 2st, 3nd,...) %d The day of the month, in numeric form (00~31) %e The day of the month as a number ((0~31) %f Microseconds (000000 ... 999999) %H 24 hours as 2 digits (00~23) %h, %I 12 hours in 2 digits (01~12) %i minutes, numeric(00~59) %j —Day of the year (001~366) %k In 24 hours (0~23)express %l Take 12 hours (1~12)express %M month name ( January~December) %m Month, as a number (00~12) %p morning( AM) or PM ( PM) %r Time, 12-hour clock (hour (hh): minute (mm) : seconds (ss) After adding AM or PM) %S, %s Seconds as 2 digits (00~59) %T Time, 24-hour clock (hour (hh): minute (mm): seconds (ss)) %U Week (00~53),Where Sunday is the first day of the week %u Week (00~53),Where Monday is the first day of the week %V Week (01~53),where Sunday is the first day of the week, and%X use simultaneously %v Week (01~53),where Monday is the first day of the week, and%x use simultaneously %W Day of the week (Sunday, Monday, Tuesday...Saturday) %w —day of the week (0= Sunday…6= Saturday) %X the year of the week, where Sunday is the first day of the week, as a number, 4 digits, and%V use simultaneously %x the year of the week, where Monday is the first day of the week, as a number, 4 digits, and%v use simultaneously %Y 4 year in digit form %y 2 year in digit form %% %a literal character
Cloud Native Development
I plan to add some monitoring interfaces to the application services I am in charge of, and support get and post, so that you can view them with the curl command without logging in to the target server. Of course, if you want to view detailed information, you also need to look at the log.
work record
Participated in a meeting due to department adjustment. There are about 30 people in the reorganized department, and I don’t know many people. After introducing myself, I found that I am a newcomer with rich work experience. After analyzing the number of official and outsourced personnel, and considering the views of other colleagues, I still have no hope of becoming a full-time employee at present. I mentioned it to the leader twice, but I didn't dare to mention it again. I don't know how many employees of this company work alone to support the whole family, have children at home, and have loans. One of my strengths is that I can imagine the future, because I also have dreams, but I can also accept the reality and work hard.
A colleague asked me to interview others together. Based on the principle of developing slowly, some abilities should also be displayed.
life record
Basically, there will be a quarrel every month. I don't participate much in this "argument". Now that the children have grown up, they are the audience, and I hide. Added 2 quarrels this month. One is about buying a house. Because there is only one toilet, I complain about the house. By the way, I said that the reason for being close to the subway is to pick someone up to Nanning. The other is the matter of naming the child, which means that she was not discussed with her. For the former, some people may not have noticed that the kindergarten is in the community, and there are primary and junior high schools within 300 meters of the entrance, or some people may not know that the house they live in costs millions. For the latter, some people may have a wrong memory and don't remember the big fight over the child's last name. Of course, my memory may also be wrong. Some people are aimed at people rather than things, so many times I can't justify, I can only make a note, and I have the right to vent.
This month, Sledgehammer took a large class. Looking at the class group information, the volume is very strong. For example, the teacher issued a delayed service announcement. There are more than 40 people in the class, and more than 30 people have signed up. It means.
The big class started to have homework, and there was an extra homework in the evenings and weekends: Supervising the sledgehammer to write homework. I used to watch the news about parents accompanying their children to do their homework. I always couldn't understand why they had to yell. Only when it was my turn did I realize that this matter is related. I can't help scolding the sledgehammer, but try to make him not resist doing homework. Last year, due to well-known reasons, the holiday was early, so this semester has to make up the semester's class. After the class, the teacher said which textbooks to buy, so I hurriedly bought them. Sledgehammer also "learned" his class for a semester in more than two weeks. Of course, I didn't force him, and I didn't ask him to learn any degree. It's just that a few times I didn't finish my homework within the stipulated time and took pictures and uploaded it. The teacher called my name, and I was inevitably scolded.
I went to the city center with Sledgehammer a few times, and bought food and entertainment as he wanted. Accompany him to watch the sunset once. He grew up in a blink of an eye, and there are still a few months to go to school. I still remember the situation when I was in elementary school. No matter how you compare it, it is better than then. I try my best to satisfy the child, but not too much, Sledgehammer I haven't suffered much so far, so I don't know if it counts as pampering him.
For some reason, I couldn't accompany Da Niu, and I brought a sledgehammer alone when I went outside to play. I feel a little distance from her.
Thought
amateur reading
From the second half of last year to this month, I have listened to "Historical Records" with a lot of emotion. The attitude and actions of the ancients towards "righteousness" and "death" are very admirable. Of course, I am not a dead book, thinking that everything in ancient times was right. Knowing about the past only enriches one's spirit.
One Sunday, I accompanied Sledgehammer to a second-hand bookstore. Besides buying picture books, I also bought a set of "Three-Body Problem", but I really couldn't sit down and read it. For daily reading, one is to tell stories to the sledgehammer. For a relatively long period of time, only "Journey to the West" is told. The second is to look up the dictionary with the sledgehammer.
amateur research
Study the AT command.