Skip to content

Instantly share code, notes, and snippets.

View logbasex's full-sized avatar
🎯
Focusing

logbasex logbasex

🎯
Focusing
View GitHub Profile
@logbasex
logbasex / FindLargestElementInCollection.java
Last active June 5, 2020 18:25
This solution implement by bitwise operator.
package com.algorithm.bitwise;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class FindLargestElementV2 {
//MSB: most significant bit.
public static long countGreaterOrEqualElementWithSameMSB(List<Integer> seq, int valueAtMSBIndex) {

Usage of @AliasFor

In Spring's many annotations, it is often found that many different attributes of different annotations play the same role, such as @RequestMapping's value attribute and path attribute. In order to keep their behavior consistent, such as the value of value and the value of path can not conflict, their values should always be equal. To handle these issues uniformly, Spring created the @AliasFor tag.

The @AliasFor tag has the following usage methods.

1, explicit use within the same annotation

For example, the usage in @RequestMapping:

One liner to stop / remove all of Docker containers:

docker stop $(docker ps -a -q)

docker rm $(docker ps -a -q)

## Regex: https://www.postgresql.org/docs/9.3/functions-matching.html
` select url, thumbnail from media WHERE url !~* '.jpg|.mp4|.mov|.jpeg|.png|.mp3';`
@logbasex
logbasex / README.md
Last active November 3, 2020 07:41 — forked from hofmannsven/README.md
MySQL CLI Cheatsheet
import static java.util.Objects.*;
public static String[] getNullProperties(Object source) {
final BeanWrapper wrappedSource = new BeanWrapperImpl(source);
return Stream.of(wrappedSource.getPropertyDescriptors()).map(FeatureDescriptor::getName)
.filter(propertyName -> isNull(wrappedSource.getPropertyValue(propertyName))).toArray(String[]::new);
}
//copy propreties that ignore null field in the request
BeanUtils.copyProperties(request, object, getNullProperties(request));
//https://www.geeksforgeeks.org/tesseract-ocr-with-java-with-examples/
//https://medium.com/@rahulvaish/simple-tesseract-ocr-java-be261e343c5b
public static void main(String[] args) {
Tesseract tesseract = new Tesseract();
try {
//not working perfectly
tesseract.setDatapath("C:\\Users\\conta\\Downloads\\Tess4J\\tessdata");
String text = tesseract.doOCR(new File("C:\\Users\\conta\\OneDrive\\Desktop\\t.png"));
System.out.print(text);
} catch (TesseractException e) {
/**
* Appends the elements defined by the specified pattern to the builder.
* <p>
* All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters.
* The characters '#', '{' and '}' are reserved for future use.
* The characters '[' and ']' indicate optional patterns.
* The following pattern letters are defined:
* <pre>
* Symbol Meaning Presentation Examples
* ------ ------- ------------ -------
private static final String IS_DATE_MONTH_YEAR_FORMAT_PATTERN = "^(?:(?:31([/\\-.])(?:0?[13578]|1[02]))\\1|" +
"(?:(?:29|30)([/\\-.])(?:0?[13-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|" +
"^(?:29([/\\-.])0?2\\3(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))$|" +
"^(?:0?[1-9]|1\\d|2[0-8])([/\\-.])(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$";
private static final String IS_MONTH_DATE_YEAR_FORMAT_PATTERN = "^(?:(?:(?:0?[13578]|1[02])([/\\-.])31)\\1|" +
"(?:(?:0?[13-9]|1[0-2])([/\\-.])(?:29|30)\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|" +
"^(?:0?2([/\\-.])29\\3(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))$|" +
"^(?:(?:0?[1-9])|(?:1[0-2]))([/\\-.])(?:0?[1-9]|1\\d|2[0-8])\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$";
/**
* Youtube has many different types of URL.
* https://www.youtube.com/watch?v=DFYRQ_zQ-gk&feature=featured
* https://www.youtube.com/watch?v=DFYRQ_zQ-gk
* http://www.youtube.com/watch?v=DFYRQ_zQ-gk
* //www.youtube.com/watch?v=DFYRQ_zQ-gk
* www.youtube.com/watch?v=DFYRQ_zQ-gk
* https://youtube.com/watch?v=DFYRQ_zQ-gk
* http://youtube.com/watch?v=DFYRQ_zQ-gk
* //youtube.com/watch?v=DFYRQ_zQ-gk