Jetty’s start.jar forks a new JVM to run the app if logback module is enabled

Jetty is too smart. If there is any JVM option provided, Jetty will spawn a new JVM instance to do the real work, even if you don’t use “–exec” option in start.ini And jetty’s logback module introduces a JVM option. See here You will see: -Dorg.eclipse.jetty.util.log.class?=org.eclipse.jetty.util.log.Slf4jLog So does it matter? It matters a lot because […]

Miscellaneous tips while developing in WSL (Windows Subsystem for Linux)

File change monitoring doesn’t work, such as the auto-refresh of create-react-app Use the following before your "npm start" or put it on env file: CHOKIDAR_USEPOLLING=true And if you are using Intellij, you need to explicitly "ctrl + s" to save the changes on your code files Integrate beyond compare with git diff export TMPDIR=’/mnt/c/Users/yourName/AppData/Local/Temp’ alias […]

Change the font family globally in Material-UI 3.x

Some say you should use the jsx-global-plugin like “@global body{fontFamily:’someFont’}” , but it doesn’t work in my project. The global CSS still has the lower CSS speciality than MUI components’ CSS because this global CSS is using a type selector. You should use a theme instead //create a theme const myTheme = createMuiTheme({ typography: { […]

Code snippet: Swagger + Spring Boot

compile ‘io.springfox:springfox-swagger2:2.9.2’ compile ‘io.springfox:springfox-swagger-ui:2.9.2’ /** See */ @Configuration @EnableSwagger2 public class SwaggerConfig { @Value(“${enable.swagger}”) //You may want to disabled it in PROD boolean enableSwagger; @Bean public Docket api() { Docket api = new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage(“your.package”)) .paths(PathSelectors.any()) .build(); ApiInfo apiInfo = new ApiInfoBuilder() .version(“xxx”) .description(“xxx”) .termsOfServiceUrl(“xxx”) .title(“Xxx Doc”) .build(); api.useDefaultResponseMessages(false).apiInfo(apiInfo); api.enable(enableSwagger); return api; } […]

Generate PDF from server side using Java

You can use OpenPDF to draw a PDF (the open source fork of iText). However, the learning curve of creating PDF with layouts and stuff is very high. A more cost-effective solution is create an HTML version of it and convert it using Flying Saucer with its OpenPDF component . As a Java developer you […]

Redux + Typescript: The type of the root state

You can get the type of the state from the root reducer // the reducer const appReducer = combineReducers({ global: globalStateReducer, example: exampleReducer }); type AppState = ReturnType<typeof appReducer> However the redux state can be cleared in some scenarios, so it should be undefinable //See for “undefined redux state” type RootState = AppState | […]

Redux + Typescript: Use class to define Actions

You want the actions to be typed. You should use interface or class. Class is better than interface because in interfaces you cannot define the action "type" as a constant, but in classes you can: class LoadingStartedAction implements Action{ readonly type = LOADING_STARTED } However a class instance is not a plain object, but Redux […]

Read process output in Java without hanging the main thread

/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * “License”); you may not use this […]