01 2021 档案
摘要:Docker containers that are running on your local machine can't communicate with each other. In this mini post explains why and shows a demonstration o
阅读全文
摘要:Starting up our server and running the curl command curl localhost:3000/health, we find that we get an error. Our server is complaining about us not h
阅读全文
摘要:Running MySQL in a Docker Container is great for being able to emulate various environments. The more advanced containers will include a bunch of exec
阅读全文
摘要:Containers can be very useful to emulate various environments. You can also use much more complex containers. In this case, we had a container with a
阅读全文
摘要:Netlify serverless Set up a Local Development Environment for Serverless Functions Using Netlify Netlify makes developing serverless functions easy wi
阅读全文
摘要:function useState<S>( initialState: S | (() => S), ): [S, Dispatch<SetStateAction<S>>] Example: function useDarkMode() { // ... const returnValue: [st
阅读全文
摘要:Stream<Employee> emps = ... TreeSet<Employee> tree = emps.collect( Collectors.toCollection( () -> new TreeSet<Employee>( Comparator.comparingInt(Emplo
阅读全文
摘要:Nx Create a new empty Nx workspace npx create-nx-workspace <workspace name> Choose Empty workspace Nx Cloud Nx CLI Useful Commands yarn nx list Shows
阅读全文
摘要:To void: forEach, forEachOrdered, peek stream.peek(System.out::println) // print without termination .filter(n -> n > 0) .distinct() .limit(10) .forEa
阅读全文
摘要:Saying that we have some icons and a target sum, for example 16. How to choose which and how many icons to include to reach the target but minize the
阅读全文
摘要:Sream<Employee> emps = ...; emps.sorted( Comparator.comparingInt(Employee::getSalary) .reversed() ).limit(10) .map(Employee::getName) .forEachOrdered(
阅读全文
摘要:A serial of number, you cannot add siblings number together. To calcaulate what is the max sum value. Thinking: 1. Weather I should add current number
阅读全文
摘要:<!-- HTML --> <div class="wrap"> <div class="headers"> <div class="scroller"> <div class="track"> <div class="heading">Heading 1</div> </div> ... </di
阅读全文
摘要:Fibonacci sequence: The most well-known approach is memoization. Advantage is fast, but space complexity is big. O(N). Bottom-up: 1 : Bottom-up dynami
阅读全文
摘要:Why need to use @ResponseEntity, first let's see what problem we might have when we don't use it. @RestController public class ProductsRestController
阅读全文
摘要:Interceptor jump in before controller. So request may not reach controller if Pre-process is not ok. Demo: package com.test.hplus.interceptors; import
阅读全文
摘要:In this lesson, you will learn how to extend a class's functionality through typescript decorators. Decorators provide a way to add both annotations a
阅读全文
摘要:@ControllerAdvice public class DefaultAttributeController { // apply default value @ModelAttribute("newuser") public User getDefaultUser() { return ne
阅读全文
摘要:Create file: // this apply to all the controllers @ControllerAdvice public class ApplicationExceptionHandler { @ExceptionHandler(ApplicationException.
阅读全文
摘要:Controller: @Controller public class LoginController { private UserRepository userRepository; @PostMapping("/login") public String login(@ModelAttribu
阅读全文
摘要:If you need to convert a deep nested object struture, you cannot just use @InitBinder, you need to build a custom convertor: Exp: conver city prop in
阅读全文
摘要:For example, from the client, it send date as string to BE. But BE requires date to be a Date instead of String. Controller: .. @Autowired private Use
阅读全文
摘要:User entity: import javax.validation.constraints.*; @Entity public class User { @Id private int id; @Size(min = 6, message = "Username cannot be less
阅读全文
摘要:@Repository public interface ProductRepository extends CrudRepository<Product, Integer> { @Query("select p from Product p where p.name like %:name%")
阅读全文
摘要:Set<Book> lib = ... lib.stream() .flatMap(book -> book.getWords().stream()) .distinct() .forEach(System.out::println);
阅读全文
摘要:Entity: package com.frankmoley.security.app.auth; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Generated
阅读全文
摘要:Code to improve: final Collection<DiscussionTopics> topics = s.getTopics(); final boolean anyTopics = topics != null && !topics.isEmpty(); Change to:
阅读全文
摘要:Module defined what can be used inside the module package and what outside world can use inside our module. module-info.java /* * To change this licen
阅读全文
摘要:Highlights: Solve the complexities of write Redux (actions, reducers, selector...middleware...) Solve the immutable pattern with nested spread operato
阅读全文