Author Archives: Robins

Storing JSON data in session storage

Storage data:

sessionStorage.setItem("loginInfo",JSON.stringify(bdata));

Get data

var loginObj=JSON.parse(sessionStorage.getItem('loginInfo'));

In web development, session storage is often used to store data, so it is not difficult to store a single string data variable

var str = 'This is a string';
sessionStorage.setItem('param',str);

Get sessionstorage

var item = sessionStorage.getItem('param');
console.log(item);

However, sessionstorage can only store string type data, and can’t directly store array types and JSON objects. If there is a need, what should I do?It’s very simple.

First, the JSON object is passed through JSON.stringify () method is converted to a string and stored in sessionstorage

var obj = {
  "name": "Tom",
  "age": 12,
  "gender": "man"
};
sessionStorage.setItem('jsonParams',JSON.stringify(obj));

And then through JSON.parse () method to convert the string to JSON format

var data = JSON.parse(sessionStorage.getItem('jsonParams'));
console.log(data);

ioctl,unlocked_ ioctl,compat_ The difference between IOCTL

Personal blog guide home page – click here

Original text:

Follows an explanation of the patch that introduced unlocked_ioctl and compat_ioctl into 2.6.11.
The removal of the ioctl field happened a lot later, in 2.6.36.

Explanation: When ioctl was executed, it took the Big Kernel Lock (BKL), so nothing else could
execute at the same time. This is very bad on a multiprocessor machine, so there was a big effort
to get rid of the BKL. First, unlocked_ioctl was introduced. It lets each driver writer choose
what lock to use instead. This can be difficult, so there was a period of transition during which
old drivers still worked (using ioctl) but new drivers could use the improved interface (unlocked_ioctl).
Eventually all drivers were converted and ioctl could be removed.

compat_ioctl is actually unrelated, even though it was added at the same time.
Its purpose is to allow 32-bit userland programs to make ioctl calls on a 64-bit kernel.
The meaning of the last argument to ioctl depends on the driver, so there is no way to
do a driver-independent conversion

Explanation:

IOCTL: (after 2.6.36, the field is removed). The application enters the kernel and holds a giant lock/big lock/kernel lock. At the same time, only one application enters the kernel spaceunlocked_ IOCTL: 64 is a non giant lock called by the application_ IOCTL: 32 is a non giant lock called by the application

Reference:
giant lock: giant lock – big kernel lock (BKL)
fine graded locking: non giant lock – fine graded locking
what is the difference between IOCTL unlocked IOCTL and compat IOCTL

Visual studio 2017 can’t open, prompt this app can’t run on your PC

Visual studio suddenly can’t open, prompt this app can’t run on your PC

After studying for a while, we found out the reason. It’s vs2017 devenv.exe It’s broken. The size is 0 KB.

The solution is to copy one from a colleague’s computer devenv.exe Problem solving.

 

Vs2017’s devenv.exe Download: https://download.csdn.net/download/zhouyingge1104/16075855

 

Using elementui El-dialog as a subcomponent to close an error

1. Pop up window as a sub component

The parent component opens the pop-up window by clicking the event. However, when clicking the blank area outside the window or the upper right corner fork in the pop-up window, it always reports an error:

Translation: avoid changing a prop directly, because when the parent component re renders, this value will be covered. Instead, use data or calculate properties based on the prop value. “Visible” is happening

2. Cause analysis

From the perspective of translation, the data passed by the parent component cannot be changed directly in the child component, and then the data passed by the parent component will be copied again in both data and computed according to the prompt, and the same error will still be reported.

3. Solutions

Finally, through a line of code successfully solved, in the pop-up window with: before close method successfully solved!
Analyze the reason again:
when closing the pop-up window by this method, you can change the closing directly through the parent component. This method is a callback function before closing the pop-up window. If you do not change the pop-up window status in the child component, you will not report an error!

// Parent Component
<editDialog :edit-visible.sync="editVisible">
</editDialog>

// Sub-components
<el-dialog
      title="My Clue"
      :visible.sync="editVisible"
      :before-close="handleClose"
      top="5vh"
      width="80%">
</el-dialog>

props: {
    editVisible: {
      type: Boolean,
      default: false
    },
};

 handleClose() {
    this.$emit("update:editVisible",!this.editVisible);
 },

Such a simple problem, the road to solve twists and turns, I hope to help you, there are problems can be message exchange!

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to crrent location: “/home“

In Vue project, when repeatedly clicking route, the console will report an error:

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to crrent location: “/home”

The online solution is to add the following code in the router folder:

// src/router/index.js

const VueRouterPush = Router.prototype.push
Router.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

However, errors are still reported in the compilation process.

Finally, a solution is found

itemClick() {
  // Original code: this.$router.replace(this.path)
  // Add .catch(err=>err) after the code for route jumping
  // either the replace or push method will work
  this.$router.replace(this.path).catch(err=>err)
}

When feign is called, the solution of request method ‘post’ not supported appears

background

When using springboot feign call, the following error will appear

org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
        at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:201)
        at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:420)
        at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:366)
        at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:66)
        at org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:404)
        at org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1233)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1016)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at com.github.xiaoymin.knife4j.spring.filter.ProductionSecurityFilter.doFilter(ProductionSecurityFilter.java:53)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at com.github.xiaoymin.knife4j.spring.filter.SecurityBasicAuthFilter.doFilter(SecurityBasicAuthFilter.java:90)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1598)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)

Why

It may be because there is a problem with the parameters during the query, and you need to use the specified annotation to complete the parameter transfer

Common query Bo

    public class CodeBo {
        private long start;
        private long end;

        public long getStart() {
            return start;
        }

        public void setStart(long start) {
            this.start = start;
        }

        public long getEnd() {
            return end;
        }

        public void setEnd(long end) {
            this.end = end;
        }
    }

Service provider in controller

@RestController()
@Api(tags = "Report has been Created")
@RequestMapping(value = "report", produces = MediaType.APPLICATION_JSON_VALUE)
public class ReportController {

    @GetMapping("test/test")
    List<String> listCode(@SpringQueryMap CodeBo bo){
        return new ArrayList<String>() {{
            add("AA");
            add("BB");
            add("CC");
        }};
    }
}

Feign service caller

PS: spring querymap annotation is mainly used to solve this problem

@Component
@FeignClient(value = "service")
public interface ServiceFeignClient {

    @GetMapping("test/test")
    List<String> listCode(@SpringQueryMap CodeBo bo);
}

[How to Solve] Internal: blas sgemm launch failed

1. Error report

Internal: Blas SGEMM launch failed

2. Ideas & Solutions

Thinking:
I checked all kinds of blogs for GPU and cudnn problems
most of the solutions are to restart the kernel, re install cudnn, install cudnn patches and so on
but for me, they are useless

The final solution:
add this paragraph to the running file

#Prevent cuDNN from reporting errors: Option 2
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
    try:
        # Currently, memory growth needs to be the same across GPUs
        for gpu in gpus:
            tf.config.experimental.set_memory_growth(gpu, True)
        logical_gpus = tf.config.experimental.list_logical_devices('GPU')
        print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
    except RuntimeError as e:
        # Memory growth must be set before GPUs have been initialized
        print(e)

Getoutputstream() has already been called for this response

java.lang.IllegalStateException: getOutputStream() has already been called for this response
        at org.apache.catalina.connector.Response.getWriter(Response.java:581)
        at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:227)
        at com.alibaba.fastjson.serializer.ASMSerializer_10_ResponseFacade.write(Unknown Source)
        at com.alibaba.fastjson.serializer.JSONSerializer.writeWithFieldName(JSONSerializer.java:333)
        at com.alibaba.fastjson.serializer.JSONSerializer.writeWithFieldName(JSONSerializer.java:311)
        at com.alibaba.fastjson.serializer.ObjectArrayCodec.write(ObjectArrayCodec.java:118)
        at com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:285)
        at com.alibaba.fastjson.JSON.toJSONString(JSON.java:740)
        at com.alibaba.fastjson.JSON.toJSONString(JSON.java:678)
        at com.alibaba.fastjson.JSON.toJSONString(JSON.java:643)

Problem scenario: block the print request parameters in the class, and use jsonobject to convert httpservletresponse to a string.

private Object printLog(ProceedingJoinPoint joinPoint) throws Throwable {
   String ipAddress = IpAddressUtil.getIpAddress(request);
   String url = request.getRequestURL().toString();
   String params = JSON.toJSONString(joinPoint.getArgs());
   Object proceed = joinPoint.proceed();
   String result = JSON.toJSONString(proceed);
   log.info("\n-----------------------------------------------------------------------------------------------" +
          "\n<> IP:{} " +
          "\n<> url:{} " +
          "\n<> params:{} " +
          "\n<> result:{}" +
          "\n-----------------------------------------------------------------------------------------------" , ipAddress, url, params, result);
   return proceed;
}

Cause problem: the interface has two parameters, one of which is httpservletresponse

At this time, the interceptor will report an error when printing parameters.
When checking the debug, it is found that there is an error in calling getwriter after getting the object through reflection, which leads to an exception in JSON transformation
Alibaba JSON is getting the object serializer class asmserializer_ 1_ Resposefacade called ResponseFacade.getWriter ()
write javaBean error, fastjson version 1.2.58, class com.sun.proxy .$Proxy128, method : getWriter

Error usage code:

HttpServletResponse response;
JSON.toJSONString (response);
to sum up, jsonobject is unable to serialize httpservletresponse, thus reporting the above exception

Solve the ‘UTF-8’ codec can’t decode byte 0xe9 in position 3114: invalid continuation byte error

Today, when using Python to open a file, the following error was reported:

the code is as follows:

movies = pd.read_table('../../dataset/ml-1m/movies.dat', sep='::', header=None, engine='python', encoding='utf-8').to_numpy()

Solution:
change the code to: iso-8859-1 just

movies = pd.read_table('../../dataset/ml-1m/movies.dat', sep='::', header=None, engine='python', encoding='ISO-8859-1').to_numpy()

Yarn: runtime.ContainerExecutionException : launch container failed

introduction:

After the spark submit submits the task, the code of the dirver side is executed normally, but the program gets stuck in the exciter stage and frequently reports errors until the task fails

 

location:

The log failed location prints a lot of warning:

The initial job did not accept any resources. Please check the cluster UI to make sure that the worker process is registered and has enough resources. The initial analysis is about resources. Then yarn logs pull down the logs to see:

The initial heap size of the JVM exceeds the maximum heap size. Check the task environment to find out the truth

 

solve:

The initial memory of the JVM – XMS (the minimum heap value of heap memory) requires 13g, but Excutor.memory Only 12g is given, so the above problem appears. Modify the script to keep it stable excutor.mermory =The size of – XMS is OK, the problem is solved~

Tips: generally – XMS – Xmx (the maximum heap value of heap memory) can be set the same.

Oracle recommends setting the minimum heap size (-Xms)equal to the maximum heap size (-Xmx) to minimize garbage collections.

 

glCreateProgram error

Troubleshut< opengl>:

Problem Description:

Today, I encountered an OpenGL error. I doubted my life. The error report is as follows:
glcreateprogram() is a function in glew. I thought that the library connection was wrong. Then I connected all kinds of glew32.lib to the computer for a long time. By chance, I found that glew had no init and fainted…

Solution:

Execute before calling:
/* initialize glew. */
glewexperimental = GL_ TRUE;
GLenum err = glewInit();
if (err != GLEW_ OK)
{
std::cout << “Error initializing GLEW: ” << glewGetErrorString(err)
<< std::endl;
std::exit(EXIT_ FAILURE);
}