Categories
Uncategorized

Work in Depth: Use every piece of brain power

Impressiveness has become a widespread social phenomenon. It is very easy to judge whether a person is impetuous and to see how many times a day he actively picks up the phone. According to TED speakers, this value is 50 times, and in addition to eight hours of sleep, basically go through the phone every 20 minutes.

What would you do with your phone? Watch WeChat, ticket circle, weibo, know, Taobao, or just brush home. We are not celebrities, nobody cares about your actions on social networks. However, in just a few minutes, destroying the brain-built scenario, putting down the phone is likely to forget what you were doing before, and then it’s hard to get into the state for a long time. Fragmented reading is prevalent, but when you drop your phone, what else can you remember?

We also found that almost at the same time graduates, after a few years of work will create a huge gap, some people have been able to manage a large team of hundreds of people, while others can not even manage, only by virtue, no initiative. As everyone seems to be working, why are there huge differences in career development, professionalism and impact after a few years?

Deep learning is an important concept in artificial intelligence (AI), meaning that models with deep structure and capacity are large enough to accomplish complex tasks. Drawing on this concept, for people, deep work is high quality, deep breadth of work and thinking. Although we have such a powerful brain, not everyone is good at having a deep job.

(The depth of the machine model has progressed dramatically in recent years)

impetuous and anxious

impetuous people, often unable to stick to reading long and difficult text, sitting in a solitude environment, constantly turning over mobile phones, often pursuing short-term value rather than long-term benefits. The brain has to switch the situation over and over again, becoming more and more impetuous, leading to a vicious circle, and is prone to fatigue: for example, trying to chat with 10 people at the same time, you get tired in half an hour.

Many classmates have a bad habit of debugging code, desert Jun also, give a chestnut: write code is likely to write wrong at once, modify after error, then run, then modify. It takes a minute or two for each run, then you’ll get the phone habitually and then look down and see how it goes wrong. After a few toss, a morning brush a lot of know, but did not do many positive things. How does the Great God write code? They will focus on running the simulations in their brains, change the errors they find in advance, and be very focused on debugging. But the efficiency difference between the two is staggering.

We find it difficult for lazy people to survive. But not lazy but impetuous is not always good where. I used to make a list of things to do, clean the list to complete the task. After depressed to discover, getting addicted to the feeling of completing the list, set goals becoming more and more trivial, without delve into the details and heights of the task. Although impetuous is not lazy, seemingly busy, the quality is low. Tactical business does not change strategic laziness. Without thinking about the problem, rush to the road, work blind.

Quality is much more important than quantity, success never depends on enough things, change depends on several key elements. “The fate of a person, ah, of course, depends on his own, but also on taking into account the process of history. “The three small things that elderly people have done are famous enough. For most people, one important thing is enough.

The state of deep work

When working in depth, the brain is very focused and efficient, capable of dealing with complex problems. Imagine a state: without interruption for a long time, the brain creates a sophisticated stereo network of information, ideas and ideas will emerge, and it will be very efficient to absorb information when problems are discovered.

A seemingly simple question, there is a rich connotation behind it, whether you can think of enough depth. An example of mathematics: the Bayesian formula is simple and well known to many students in science and technology. What problems it was originally used to solve, what conditions, what background knowledge is needed, further, what is its essence, what inference and extension, in which areas it is successfully applied. It’s enough to apply for top algorithm engineers to make these questions clear.

Focusing is a habit, and when you can stay focused on boring or incomprehensible issues, such as reading this article, the brain naturally learns that skill and adapts gradually. Focus on the work is very efficient, although wealth is huge, but everyone time is equal, save working time will have more free to wave.

In addition to high-quality work, deep thinking can be extended to the usual free time, of course not encouraging to become workaholic. A lot of good ideas, not from the front of the desk, but from the inadvertently thought spark in life. When you are interested in a question, you think about it unconsciously in the subconscious. Unintentional state can instead push them to float into real consciousness.

Thinking during a walk is very effective, of course to be safe. In the long commute, let yourself try not to play mobile phone, think about what problems have not been solved, originally crazy boring wait instead entered the calm. Imagine Saturday evening, a person sitting quietly on a bench by the West Lake, surrounded by empty people, only a few kittens playing around. Looking at the calm lake in contemplation: the tasks to be completed recently, there are several options, how good or bad, whether resources are in place, problems encountered and solutions, which girl is better (again in trouble), further, develop key nodes, mission output and impact. In half an hour, without the help of pens and paper, let the brain do a complete simulation of the path to solving the problem. It may be possible to figure out a problem that has been plagued for a long time at once.

The city was otherwise uninteresting, it was interesting to live, communicate and compete between people. You can be friends with the brain, it will construct beautiful scenes for you, create memory palaces and remember surprisingly huge amounts of information. The brain can also imitate a few friends to help you out, but don’t get into the trap of multiple personality (this is so cool).

Just one thing at a time.

Knowledge and skills are difficult to migrate across different areas, but focus and depth are essential qualities in any field. Developing such a capacity at the bottom can have a profound impact on every aspect of itself. The question is, how can I stay focused?

Some believe that concentration requires deliberate exercise. In fact, as long as cultivate the habit of leaving the phone and not easy to walk, you can take a valuable step: want to pick up the phone, hold back; the puzzle can not figure out, calm, draw a picture for yourself again. This ensures at least half an hour of concentration. Most brains aren’t good at parallelising, so it’s more productive to focus on serial completion. To quote a regular sentence from the chief of the sergeant in the XBOX game Halo: “Do only one thing at a time.”

Of course, to make great results, it takes days or even months of hard work, such as proving delicate mathematical proposition, which requires talent and interest, as well as hard work on concentration. Bill Gates abandoned everything and designed the BASIC language in eight weeks, laying the foundation of the Microsoft Empire. He worked so hard in these two months and slept for an hour or two when he was extremely tired, and was praised by Paul Allen as “an amazing act of concentration.” What can we do in two months?

You can actively create a sense of ritual and environment, forcing yourself into a state of concentration. If possible, turn off WeChat and nail nails; please fitness coach, because of the price of meat and train extra energy; often go to the favorite cafe reading and writing, much better than at home. An enterprise’s office environment also largely determines the employee’s style of doing things, the Internet company’s huge open greatly promotes the exchange of information, but also to some extent leads employees to difficult to sit down to think about problems, such as our company. While the cage filled with small compartments is beneficial for individual research, it also reduces the efficiency of information flow. Microsoft’s workspace design is worth learning from its spacious public space for open discussion and a separate office for each person to work in depth.

If you are still unable to keep yourself quiet and focused, then it may be the cause of the body. The writer recently studied the “Huang Di Inner Sons” in the evening (the opportunity to write a post sense, do big data fortune teller), in which 16 words in ancient naive theory cause deep thought: “thecalm, the truth from it, the spirit of the inner guard, and the sick have neverbeen.” The city produced too much desire and impetuous: many people do not adapt to the atmosphere of heaven and earth, mobile phone computers hang in front of the eyes, all kinds of radiation flood around, summer air conditioning cold winter is very hot, weekdays do not exercise eat and greasy, lead to virtual fire, can not be quiet, let alone focus and depth. But in the idyllic farmhouse, listening to the sound of the night, it is easy to calm down, and then sleepy to sleep…

Maybe you don’t believe in TCM, it’s okay, but it’s necessary to develop good habits. I have to say that deep work is very brain intensive, and a couple of hours of thinking is enough to make the brain feel burning. After all, the body is the capital of the revolution.

The meaning of deep work

Deep work is not a success story, much less a panacea to the pinnacle of life. It is an attitude that takes life seriously and makes effective use of time. It does not mean to be isolated from the world and not to communicate with the outside world. You can configure the closing and the rhythm of communication according to your own habits, communication is more efficient. The other person will be pleasantly surprised by the depth of your previous thinking, and no one will like blurted out of meaningless views.

Depth and focus can make a huge difference: in general, if you work hard, it’s enough to be a leader. However, in the competitive environment of strong players, it is necessary to have a systematic understanding of business, products and algorithms, as well as deep work and proactive action. Although large companies have talent, it’s easy to find that people are sometimes overbusy and that the most fundamental details are overlooked everywhere. Answer the previous question, because strong people can think and plan for the future, focus leads to active, active feeding focus. So people from the same starting point will have a huge gap in a few years.

Moreover, due to the increasingly high labor cost, AI development is rapidly evolving, fast cost is low, and almost no errors are made. In the future, a lot of undemanding work will be replaced by AI, especially entry-level accountants, programmers, and workers offices white-collar workers, but on the contrary, the impact of the service industry that requires complex interaction with the environment. Small. To gain an advantage in the new form of competition requires not only competition with people but also in-depth thinking about fuzzy decisions that AI does not have.

Of course, everyone knows the truth, it is another thing to be able to do it yourself. This is the watershed of competition. For example, after sending this article, I can take the initiative to pick up my phone 50 times in an hour, ah.

   
   
 

class=”postBody”>
 
 
 
 
  src=”https://images2017.cnblogs.com/blog/287060/201712/287060-20171218185615912-801785843.png” />
 
 
 
 
 
 
 
 
 
 
 
 
 
  src=”https://images2017.cnblogs.com/blog/287060/201712/287060-20171218185654131-1379740777.png” />

 
 
 
 
 
 
 
 
 
 
 
 
 

id=”MySignature”>

 

class=”clear”>

 

id=”blog_post_info_block”>
 

id=”BlogPostCategory”>

 

id=”EntryTag”>

 

id=”blog_post_info”>
 

 

class=”clear”>

 

id=”post_next_prev”>

 

   
   
 

Categories
Uncategorized

Using Automapper in ASP.NET Core to map between Entity and Resource

directory

      Install Automapper from NuGet

      Add Entity Class and Resource Class

      Add a Profile file to configure mapping relationships

      Register Automapper in Startup

      Mapping with Automapper in your project

Install Automapper from NuGet

When using Automapper, the core packages are Automapper.extensions.microsoft.dependencyInjection.

PM> Install-Package AutoMapper
PM> Install-Package AutoMapper.Extensions.Microsoft.DependencyInjection

Add Entity Class and Resource Class

Add the Post class and Resource class to the project.

	

// Entity class

public class Post { public int PostId { get; set; } public string Title { get; set; } public string Content { get; set; } public DateTime LastModified { get; set; } }

// Resource class

public class PostResource { public int PostId { get; set; } public string Title { get; set; } public string Content { get; set; } public DateTime UpdateTime { get; set; } }

Add a Profile file to configure mapping relationships

Then we need to inherit the Profile class to configure the mapping relationship

	public class MappingProfile: Profile
	{
		

//mapping from Post to PostResourcee

CreateMap<Post, PostResource>()

// configure mapping for fields with different names

.ForMember(dest => dest.UpdateTime, opt => opt.MapFrom(src => src.LastModified));;

//mapping from PostResourcee to PostPostPostPost—there is no mapping of fields with different names

CreateMap<PostResource, Post>(); }

Register Automapper in Startup

Register in the ConfiguReservoices method of the Startup class

	services.AddAutoMapper();

The MAppingProfile class will be automatically found after registration.

Mapping with Automapper in your project

Examples are as follows:

    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        private readonly MyContext _myContext;
        private readonly IMapper _mapper;

        public ValuesController(MyContext myContext, IMapper mapper)
        {
            _myContext = myContext;
            _mapper = mapper;
        }

        [HttpGet]
        public ActionResult<IEnumerable<string>> Get(int id)
        {
            Post post = _myContext.Posts.Find(id);
            PostResource postResource = _mapper.Map<Post, PostResource>(post);

            List<Post> posts = _myContext.Posts.ToList();
            IEnumerable<PostResource> postResources = _mapper
            	.Map<IEnumerable<Post>, IEnumerable<PostResource>>(posts);
            return new string[] { "value1", "value2" };
        }
    }

参考文档 :

    Automapper official website

    Official Documentation of Automapper

Categories
Uncategorized

A trip to Shanghai

 上海之行(一)
Yesterday it was drizzled rain, one afternoon in order to rush to finish the software as soon as possible, set off to Shanghai, until about 5:40 finish, 7:05 train. After the change, go downstairs to prepare for the train station. Before I don’t know how many people went to Shanghai, until now it is clear, a total of four people, the poor thing is that we only got two hard sleeping tickets, what to do with this, only two people entered with the platform ticket. At the end of the evening, 6:30 came to the station, but the unlucky thing was that the train station was under construction and no platform tickets were sold. We were only able to go in, and I was hurried on the K154 train to Shanghai with another colleague carrying the projector.

When I got on the train, I knew that I went too quickly, and my mobile phone had no electricity, forgot to charge. In order to be able to connect with Shanghai, I had to turn off the phone first; I didn’t buy anything to eat. There is no way, just mix it… When the train left, it was dark. So we sat down at the bed and took a break. I lay on the bunk, and one of my colleagues he lay on the upper bunk. My upper bunk is a ready to go to Germany. The sleeper on the left was a go to Wuxi (one for women), her middle shop was a girl, slept early, both were off with medicine. So there is not much common language, but to talk to colleagues.

Talk to colleagues about 10 o’clock, it seems to go to Shangqiu station, we bought two bowls of noodles, after eating, fell asleep. Listen to the clickers of the train Mercedes. Slowly entered the dream incense, which woke up once, and then it came to dawn. The train has reached the territory of Jiangsu…

上海之行(二)
I woke up early in the morning and was almost at Wuxi Station. There was still light rain outside. Train Broadcast begins a new day of broadcasting, informing the train about 20 minutes late to Wuxi Station. It was more than two hours away from Shanghai. We sat by the window and looked at the endless fields and rapidly moving trees and buildings.

Just like that, while enjoying the scenery, chatting. My colleague asked me: “Look! What is the one who can’t see at a glance?”. “Rice bar,” replied. I’m sorry I haven’t been in close contact with rice yet? (^_^)

Along the way, there were many ditches and rivers, and some floating wooden boats. It was a bit like getting into the town of fishermen.

Two hours passed quickly, the Shanghai train was about half an hour late, nearly nine in the morning, the sky was covered, a little like rain. Get off the train, walk to the south second exit, and see the senior manager of the branch is waiting.

Step into Shanghai, thinking now is the largest city in China. See the surrounding buildings, nothing else? Why are many looking at it? Let’s not talk about this, let’s talk about a problem later.

Get on the subway and take about a few minutes. After coming down, crossed two streets, haha. I finally arrived at my destination (Shanghai branch).
I tested the program again in the afternoon, found a small bug in data copy and recovery, and modified it.
In the evening, read the news for a while; add a feature to float prices according to the product category.

Sit in the office. Look at the night view outside the window, indeed Zhengzhou is much more beautiful…………

A trip to Shanghai (3)

Since today is Saturday, it is not possible to go to the customer to do training.
Get up in the morning and the outside is bright. The weather is clear, the air is fresh and sunny. In late autumn, I was walking down the street in the morning, and I felt a little cool.

This morning, Zhengzhou was going to come over two people, so I went to the station with a colleague (who came with me to Shanghai yesterday) to pick them up. We went to a small hotel. Just walked in, the boss lady said hello, “two bosses, what to eat?”. “Oh, how did you become a boss? (^_^)”. I asked for two bowls of ravioli, eating while listening to the boss’s mother nagging there, I don’t know what to say.

By midday, there was a change of procedure.

In the afternoon, we turned around the street, in fact there was no feeling, the only thing left is people relatively, the street is a bit narrow. went to a supermarket to buy some necessities of life. Look at the phone and so on.

There’s not much new today, so it’s OK.

A trip to Shanghai (4)

Today think about the software there are many unreasonable places, because tomorrow will go to the customer to do training, so only stay in the branch, do the following work:
First, the main modification of certain unreasonable aspects of the procedure.
Second, mainly the previous system exit when data is easily lost to solve.
Third, slightly improved the user interface.
One day passed. Ha ha! It’s hard to think about being a programmer.

上海之行(五)
Today early in the morning, mainly go to agents and customers there to install software and training, make modifications on-site.
From Hongkou District to Jiading District, that is, from the city center to the big suburbs (where the Chinese people’s electrical appliances are located), the distance is relatively far, so arranged to live there… Poor it, no one else will play.
We arrived at noon, the agent did simple training, in the afternoon went to the Chinese people, arrived later. Since the quoter there does not allow access to the Internet, this is terrible, the software does not support the function of local data, only to download data from our online use, no way, but also the data import program.
Even worse, there is no place for accommodation.So big Chinese people’s electrical appliances actually don’t have their own guest house. The results can be imagined, and we returned home again.

In Shanghai these few days, in the branch almost every day is a box lunch, but the taste is good, much better than Zhengzhou, and provides fruit and milk. Today XX came, finally under a hotel, eat once seafood, Shanghai famous what “hairy crab”, dinner table XX talk about every time customers eat what, how much money spent, how to play. Oh, what they eat once can be worth my salary for a year. Hey! It’s really sad to be a little programmer.
I took a day in the car today, so sleepy!

 上海之行(六)

Yesterday came to the Chinese People’s Appliances, began to communicate with customers, modify the program.
Here, it is “cool”! You can eat together with the workers, and live in a small farm community, sometimes with a few mosquitoes at night, absolutely make you feel not silent.
Yesterday at 4:30pm had dinner, (here 12:30pm to work, 4:30pm to work), 4:30 you went to the migrant workers cafeteria on time, come late can not eat, but we (4:35 to) still go to the evening, almost no meal. “Not bad, a dish (dried fried cabbage) a soup (seaweed) a plate of rice”, make it up, eat after. Well, think about it. What are we going to do next?
We walked south for about half an hour and finally found a restaurant, we got two dishes, and we ate again. At this time, 6:00pm.
The poor thing is that there is not even a street lamp on the street, touching the dark back. When I arrived at the residence, there was nothing, there was no table, no chair, just two beds, it was nice, and there was electricity. It has come to heaven on earth. Bend over, crawling changed the program for a while, “cool” it!

上海之行(七) 
A little busy, two or three days did not log in to the blog.
I went back to Shanghai two days ago and was busy putting forward the demand for Chinese people’s electrical appliances, and changed it a bit on Saturday. After the change took advantage of Sunday afternoon, along Sichuan Road to the Bund in a circle. It was a bit different from the rest of the world, and it was already around 3pm. It is now in the cool autumn weather, around 4:00pm, the fiery sun hangs around the sky, like a hot plate. Shine on the TV tower of the Pearl of the East, and several floors across the building. Reflection of the bright light of gold. Compared to the nature scene, it is a taste.
On both sides of the Huangpu River, architecture is indeed a two-generation style. Facing the modern high-rise buildings, there are older buildings, not too tall, and they are all bank habitats, one after another. There are several ships floating on the river, coming and going.

………………………

Categories
Uncategorized

httpclient get/postrequest

public static String HpPost (String url, JSONObject json) {String RespContent = null; try {HttpPost HttpPost = new HttpPost (url); CloseableHTTPClient Client = HttpClients.CreateDefault (); // json way StringEntity entity = new StringEntity (JSON.ToString (), “utf-8″); // solve Chinese garbled problem entity.SetcontentCoding (“UTF-8″); entity.setContentType (“application/json”); HttpPost.Setentity (entity); System.out.println (); HTTPponse resp = client.execute (HttpPost); if (Resp.getStatusLine () .getStatusCode () == 200) {Http = ResP.Gettentity (); RespContent = entityutils.ToString (he, “UTF-8″);}} catch (Exception ex) {// TODO: handle RespContent= null;} finally {return respContent;}}}

/** * @param url * Address to request* @return Status code* (@throws @throws String url) {String URLNamesTring = url; String status = null; try {// get request by address HttpGet request = new HttpGet (URLNamesTring); // here Send get request request.getParams () .setParameter (HttpMethods.so_Timeout,3000); // Get the current client object HttpClient = new DefaulthTTPClient (); // Get response object HTTPPONSE response by requesting object; response = HttpClient.Execute (request); // Determine if the network connection status code is normal (0—200) if ( Response.getStatusLine () .getStatusCode () == 200) {status = “200″;}} catch (Exception e) {// TODO auto-generated catch block E.printStackTrace (); log.error (e);} finally {return status;}}

Categories
Uncategorized

Usage of Beanutils.CopyProperties ()

I. Introduction: Beanutils provides packaging for Java reflection and introspection APIs. Its main purpose is to use reflection mechanisms to handle JavaBean’s properties. We know that a JavaBean usually contains a lot of properties, and in many cases the processing of JavaBean results in a lot of get/set code stacking, increasing the length of the code and difficulty of reading the code.

II. Usage:

If you have two JavaBeans with a lot of the same properties, a very common case is PO objects (persistent objects) and Dto objects (transfer objects). The traditional way is to assign properties one by one using a statement like the following:

//

Assigns one by one

userDto.setUsername(user.getUsername); userDto.setPassword(user.getPassword); userDto.setAge(user.getAge); ......... .........

After we use Beanutils.CopyProperties () method, the amount of code is greatly reduced, and the overall program looks simple and clear, the code is as follows:

BeanUtils.copyProperties(userDto, user);  //第一个参数是转换后的类,第二个参数是待转换的类

If there are properties with different names between User and UserDTo, BeanUtils does not process these properties and needs to be handled manually. For example:

The User class has a CreateDate creation time field, while UserDTo is a CreateTime field. Beanutils.CopyProperties () does not do anything with this field. It must be handled manually by yourself.

Note: The source and destination parameters of the copy properties of spring and apache are exactly the opposite location, so pay attention to both the guide package and the call. This example uses package org.Apache.commons.Beanutils.Beanutils.Beanutils under Apache.

 

Categories
Uncategorized

Process and Thread differences

1, the first is the definition

 

Process: is a piece of program in execution, i.e. once the program is loaded into memory and ready to execute, it is a process. Processes represent the basic concept of resource allocation, the basic unit of scheduling and running, the unit of concurrent execution in the system.

 

Thread: Each task executed in a single process is a thread. Thread is the smallest unit that performs the operation in the process.

 

2. A thread can only belong to one process, but a process can have multiple threads. Multi-threaded processing allows multiple tasks to be performed in a process at the same time.

 

3. Threading is a lightweight process, compared with the process, the thread brings to the operating system side creation, maintenance, and management burden is lighter, meaning that the cost or cost of the thread is relatively small.

 

4, the thread has no address space, the thread is included in the address space of the process. The thread context contains only a stack, a register, a priority, and the thread text is contained in the text fragment of his process, all resources owned by the process belong to the thread. All threads share the memory and resources of the process. Multiple threads in the same process share code snippets (code and constants), data segments (global and static variables), extended segments (heap storage). But each thread has its own stack segment, the contents of the register, and the stack segment is called the run time period, which is used to hold all local and temporary variables.

 

5. Parent and child processes use inter-process communication mechanism, the thread of the same process communicates by reading and writing data to process variables.

 

6. Any thread within the process is considered to be an isomotor and at the same level. Regardless of which thread created which thread, any thread within the process can destroy, suspend, restore, and change the priority of other threads. The thread also controls the process. Any thread in the process can destroy the main thread by destroying the main thread. Destroying the main thread will cause the process to be destroyed. Modifications to the main thread may affect all threads.

 

7, the child process does not exert control on any other child process, the process thread can exert control on other threads of the same process. The child process cannot exert control over the parent process, and all threads in the process can exert control over the main thread.

 

Same point:

 

Both processes and threads have ID/register groups, status and priority, information blocks, can change their own properties after creation, can all share resources with the parent process, and do not have direct access to resources of other unrelated processes or threads.

Categories
Uncategorized

MyCat Tutorial Six: Global Serial Numbers – Self-growth of Global Primary Keys

We introduced MyCat’s library table operation, then the data in the same table will be stored in different databases, then this involves the maintenance of primary key. At this time, we can definitely not use the self-increment of the id in a single database, then we can use several kinds of growth provided in MyCat way to implement the

Global primary key self-increment

1. Self-growth of local documents

First, let’s look at the first way, which is the local file self-increment.

1. Modify the shard policy

Our original configuration shard policy crc32slot does not support primary key auto-sharding-long, so we need to modify it to auto-sharding-long

2. Modify server.xml file

The sequnceHandlerType in the server.xml file is the

SequnceHandlerType value

Description

Local File Self-increment

Self-increment of the database

Local Time Stamp Self-increment Method

0
1
2

So we need to change the value of SequnceHandlerType to 0

3.sequence_conf.properties Introduction

Configuration information about sequences in sequence_conf.properties in the conf directory

#Wed Oct 16 07:40:44 CST 2019
COMPANY.MAXID=2000
GLOBAL.MAXID=20000
COMPANY.HISIDS=
CUSTOMER.MAXID=2000
HOTNEWS.CURID=1000
ORDER.MINID=1001
CUSTOMER.HISIDS=
HOTNEWS.MINID=1001
GLOBAL.CURID=10002
ORDER.MAXID=2000
COMPANY.CURID=1000
CUSTOMER.CURID=1000
COMPANY.MINID=1001
GLOBAL.MINID=10001
HOTNEWS.MAXID=2000
CUSTOMER.MINID=1001
GLOBAL.HISIDS=
HOTNEWS.HISIDS=
ORDER.HISIDS=
ORDER.CURID=1000

The main thing is GLOBAL.MAXID=20000 GLOBAL.CURID=10002 GLOBAL.MINID=10001 can be set by itself

4. Test the implementation

Primary key fields in insert statements are replaced by next value for MYCATSEQ_GLOBAL

 insert into t_user(id,name,age)values(next value for MYCATSEQ_GLOBAL,'HG-93',23)

Second, the local time stamp self-increment method

Using timestamps, we don’t need to assign a policy or choose another shard strategy.

1. Modify server.xml file

Modify SequnceHandlerType in server.xml file to 2

2. Restart mycat

The configuration file has been modified and the service needs to be restarted for it to take effect.

3. Insert data test

 insert into t_user(id,name,age)values(next value for MYCATSEQ_GLOBAL,'HG-93',23)

The timestamp is too long to modify id to varchar type.

Generate success

III. Self-growth mode of the database

1. Create order lists and related functions

The third way is to create a self-incremented table structure in a database managed by Mycat to maintain the relevant data. The related scripts are officially provided as follows:

DROP TABLE IF EXISTS MYCAT_SEQUENCE;
CREATE TABLE MYCAT_SEQUENCE (
NAME VARCHAR (50) NOT NULL,
current_value INT NOT NULL,
increment INT NOT NULL DEFAULT 100,
PRIMARY KEY (NAME)
) ENGINE = INNODB ;
INSERT INTO MYCAT_SEQUENCE(NAME,current_value,increment) VALUES ('GLOBAL', 100000, 100);
DROP FUNCTION IF EXISTS `mycat_seq_currval`;
DELIMITER ;;
CREATE FUNCTION `mycat_seq_currval`(seq_name VARCHAR(50)) 
RETURNS VARCHAR(64) CHARSET utf8
    DETERMINISTIC
BEGIN DECLARE retval VARCHAR(64);
        SET retval="-999999999,null";  
        SELECT CONCAT(CAST(current_value AS CHAR),",",CAST(increment AS CHAR) ) INTO retval 
          FROM MYCAT_SEQUENCE WHERE NAME = seq_name;  
        RETURN retval ; 
END
;;
DELIMITER ;
DROP FUNCTION IF EXISTS `mycat_seq_nextval`;
DELIMITER ;;
CREATE FUNCTION `mycat_seq_nextval`(seq_name VARCHAR(50)) RETURNS VARCHAR(64)
 CHARSET utf8
    DETERMINISTIC
BEGIN UPDATE MYCAT_SEQUENCE  
                 SET current_value = current_value + increment 
                  WHERE NAME = seq_name;  
         RETURN mycat_seq_currval(seq_name);  
END
;;
DELIMITER ;
DROP FUNCTION IF EXISTS `mycat_seq_setval`;
DELIMITER ;;
CREATE FUNCTION `mycat_seq_setval`(seq_name VARCHAR(50), VALUE INTEGER) 
RETURNS VARCHAR(64) CHARSET utf8
    DETERMINISTIC
BEGIN UPDATE MYCAT_SEQUENCE  
                   SET current_value = VALUE  
                   WHERE NAME = seq_name;  
         RETURN mycat_seq_currval(seq_name);  
END
;;
DELIMITER ;

We execute these scripts on demo2

2. Modify server.xml

3. Modify sequence_db_conf.properties file

Because demo2’s logical library is dn2, we need to modify the

4. Testing

Restart the service and insert the data test

 insert into t_user(id,name,age)values(next value for MYCATSEQ_GLOBAL,'hg-93',23)

The primary key is generated successfully. In addition to these three ways, you can also maintain the self-incremented primary key by `zookeeper`.

Categories
Uncategorized

Python3 Simple Crawler Crawl Web Pictures

Now there are a lot of instances of crawler crawling web images written by python2, but not for newcomers (newcomers all use python3 environments, not compatible with python2), so I wrote an instance of simple grabbing web images in Python3 syntax, hoping to help everyone, and hope everyone's criticism is correct. 1

import urllib.request 2 import re 3 import os 4 import urllib 5 #

to get the details of the page according to the given URL, the resulting html is the source code of the page

6 def getHtml(url): 7 page = urllib.request.urlopen(url) 8 html = page.read() 9 return html.decode('UTF-8') 10 11 def getImg(html): 12 reg = r'src="(.+?\.jpg)" pic_ext' 13 imgre = re.compile(reg) 14 imglist = imgre.findall(html)#

Indicates the address of all images filtered out throughout the web page, placed in imglist

15 x = 0 16 path = 'D:\\test' 17 #

Save the image to the D:test folder or create a test folder if there is no

18 if not os.path.isdir(path): 19 os.makedirs(path) 20 paths = path+'\\' #

Save in test path

21 22 for imgurl in imglist: 23 urllib.request.urlretrieve(imgurl,'{}{}.jpg'.format(paths,x)) #

Open the image URL saved in imglist and download the image saved locally, format format format string

24 x = x + 1 25 return imglist 26 html = getHtml("http://tieba.baidu.com/p/2460150866")#

Get the URL page details, the html is the source code of the web page

27 print (getImg(html)) #

Analyze and download saved images from web source code

 

Categories
Uncategorized

grub windows boot

BEGIN /etc/grub.d/30_os-prober

menuentry ‘Windows Boot Manager (on /dev/sdb1)’ –class windows –class os $menuentry_id_option ‘osprober-efi-E7AB-605C’ {
insmod part_gpt
insmod fat
set root=’hd1,gpt1′
if [ x$feature_platform_search_hint = xy ]; then
search –no-floppy –fs-uuid –set=root –hint-bios=hd1,gpt1 –hint-efi=hd1,gpt1 –hint-baremetal=ahci1,gpt1 E7AB-605C
else
search –no-floppy –fs-uuid –set=root E7AB-605C
fi
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
set timeout_style=menu
if [ “${timeout}” = 0 ]; then
set timeout=10
fi

END /etc/grub.d/30_os-prober

Categories
Uncategorized

Model Training Competitive Collections – Ali

Alibaba PAI 1. Introduction Alibaba Cloud Machine Learning Platform (Platform of Artificial Intelligence) provides a one-stop service for traditional machine learning and deep learning from data processing, model training, service deployment to prediction. PAI DSW (Data Science Workshop) is a cloud-based deep learning development environment for algorithmic developers. It includes visual modeling of Notebook and deep learning networks, supports the installation of open source frameworks, and provides Alibaba’s deep optimized Tensorflow framework to improve training performance through compilation optimization. Pai-Studio provides a visual machine learning test development environment for developers, helping users implement 0 code development AI related services. Built in hundreds of proven machine learning algorithms, covering scenarios such as commodity recommendations, financial risk control, advertising forecasting and more. EAS (Elastic Algorithm Service) is an online model prediction service for PAI platform, supporting heterogeneous hardware (CPU/GPU) model loading, high throughput, low latency, one-click deployment of large-scale complex models, real-time elastic scaling, and a complete O&M monitoring system. PAI AutoLearning (PAI AL) auto-learning supports online annotation, automatic model training, hyperparameter optimization, and model evaluation. You need to prepare a small amount of data on the platform, set the training time to get a deeply optimized model, and support one-click model deployment.

2. Application Scenario 1.AI deep learning solution provides deep learning solutions through PAI DSW, supporting actual business scenarios. Deep learning training models can be directly deployed as services for service calls. 2.Deep learning algorithm enthusiasts through PAI DSW, deep learning algorithm development enthusiasts, write algorithm code anytime and anywhere. 3. Education and scientific research through PAI DSW, without the need for cumbersome environment configuration, to facilitate the rapid realization of online teaching demonstration and scientific research project development. 4. News text classification cases Through PAI Studio, text components build automatic text classification cases, you can quickly dig into the topic of articles; by clustering theme weights, realize automatic news classification. The process includes word splitting, word conversion, stop word filtering, topic mining, clustering, etc. 5. Cardiac prediction case through PAI Studio, the automatic diagnosis of heart disease can prevent the occurrence of heart disease. By extracting body measurements related to human body, data mining method to analyze the effect of different features on heart disease, will play a crucial role in preventing heart disease. 6. Financial risk control case through PAI Studio, chart algorithm component build financial risk control case, can quickly locate the mutual credit relationship among the crowd; through graph algorithm, calculate other people’s credit index, that is, get the probability of each person is fraud user, this data can facilitate the relevant institutions do risk control. 7. Product recommendation case through PAI Studio, collaborative filtering algorithm to build product recommendation business case, can greatly improve product sales. Through human shopping behavior, the common algorithm in data mining – collaborative filtering, mining people and the relationship between goods and goods, promote product sales increase. 8. Ali Xiaomi based on PAI EAS, support elastic expansion capacity, comprehensive improvement of resource utilization, double eleven day single model peak of 40W QPS, smooth silky, stable support. 9. Ali Mama advertising based on PAI EAS, accurate advertising, millisecond data response, high performance to guarantee core business income. 10. Ali security based on PAI EAS, large-scale image security scanning, optimized network protocol for deep learning, and accelerated online inference processing efficiency based on GPU. 11. Alibaba Cloud printing text recognition based on PAI EAS high availability engine, providing high SLA service to tens of thousands of OCR users.

Third, product features 1. Simple to use, through visual drag to achieve model training, interactive notebook visualization, one-click deployment of online prediction service, open the whole link of machine learning.

2.Built-in rich machine learning algorithms, encapsulate hundreds of machine learning algorithms, not only provide basic clustering, regression and other machine learning algorithms, but also provide more complex algorithms such as text analysis and feature processing.

3.High performance, support high-dimensional sparse data scene, super large-scale deep model training; efficient structured compression training, accelerated training; inference model compression and quantification, improve online prediction single machine QPS. 4.Low cost, support CPU/GPU hybrid scheduling, efficient resource reuse; a variety of billing methods applicable to customer scenarios, real cloud cost reduction for AI customers. 5.Rich solutions, accumulated a variety of industry algorithm solutions, including general recommendation, financial risk control, advertising prediction, image classification and other solutions, to help enterprises quickly apply.

Fourth, the product use 1.PAI main process

(1). Data preparation, table creation, upload data in txt or csv format; or upload data via OSS;

(2). Data preprocessing, data preprocessing through SQL script, type conversion, normalization components

 

 

 

(3). Data visualization, through the full table statistical component, to view the data;

 

 

 

(4). Algorithmic modeling, setting target fields, algorithm model training;

(5). Model evaluation, through prediction components, evaluation and viewing;

 

 

 

 

2.PAI-DWS (1). Create instances, select GPU resources, select Notebook modeling service, select configuration bandwidth, network, storage, third-party libraries, built-in cases, etc.

(2) Upload data, develop and debug online; upload, download, and mount ECS and NAS storage files;

(3). Run code, generate training model; develop deep learning network visualization function;

(4). Model deployment, service online deployment call;

3.Pai-Studio selects visual modeling services, by configuring machine learning components, visualizing drag and drop nodes, building training pipelines, one-click model training; support Auto ML auto parameter; PAI supports custom algorithm upload function, support users use SQL, SPARK2.0, PASPARK2.0 framework to open their own sends the algorithm, and the algorithm encapsulated as a component uploaded to PAI-STUDIO for use;

 

 

4.PAI-EAS manages the model service, supports model call information viewing; online debugging; view log, monitoring, deployment information; service expansion, stop, delete, etc.; support console upload model, PAI Studio one-click deployment, PAI DSW deployment, and local client deployment four deployment modes. deployment to the Restful API;

 

 

 

5.PAI-AL (1). Data annotation, support online annotation of OSS data source or import tagged images;

(2). Model training evaluation, marking completion, setting training parameters, model training; and training effect, log and other data; built-in image classification model;

(3). Model release and deployment, evaluation of the trained model can, release and deploy;