This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<MyObject> largeList = /* your large list */; | |
| List<MyObject> smallList = /* your small list */; | |
| Collections.sort(largeList, Comparator.comparing(MyObject::getTicker)); | |
| List<MyObject> matchingObjects = smallList.stream() | |
| .filter(item -> Collections.binarySearch(largeList, item, Comparator.comparing(MyObject::getTicker)) >= 0) | |
| .collect(Collectors.toList()); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static String getURL(HttpServletRequest curRequest) { | |
| if(curRequest ==null) { | |
| return "https://treespond.com/"; | |
| } | |
| String scheme = curRequest.getScheme(); // http | |
| String serverName = curRequest .getServerName(); // hostname.com | |
| int serverPort = curRequest .getServerPort(); // 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Bean(name = "piTaskExecutor") | |
| @Primary | |
| public Executor piTaskExecutor() { | |
| log.debug("Creating Async Task Executor"); | |
| final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | |
| executor.setCorePoolSize(4); | |
| executor.setMaxPoolSize(10); | |
| executor.setQueueCapacity(5); | |
| executor.setAllowCoreThreadTimeOut(false); | |
| executor.setThreadNamePrefix("PiExecutor-"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| @EnableSwagger2 | |
| public class SpringFoxConfig { | |
| public static final String AUTHORIZATION_HEADER = "Authorization"; | |
| @Bean | |
| public Docket api() { | |
| return new Docket(DocumentationType.SWAGGER_2) | |
| .ignoredParameterTypes(AuthenticationPrincipal.class, DespaniPrincipal.class) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <plugin> | |
| <groupId>org.apache.maven.plugins</groupId> | |
| <artifactId>maven-resources-plugin</artifactId> | |
| <version>3.2.0</version> | |
| <configuration> | |
| <outputDirectory>${project.build.directory}/modified</outputDirectory> | |
| <resources> | |
| <resource> | |
| <directory>src/main/resources</directory> | |
| <filtering>true</filtering> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static byte[] passwordProtectExcel(byte[] inputExcel) throws IOException, GeneralSecurityException { | |
| // Convert the input byte array to a Workbook | |
| XSSFWorkbook workbook = new XSSFWorkbook(new ByteArrayInputStream(inputExcel)); | |
| // Prepare to encrypt the workbook | |
| POIFSFileSystem fs = new POIFSFileSystem(); | |
| EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile); | |
| Encryptor enc = info.getEncryptor(); | |
| enc.confirmPassword("password"); // Set the password here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| try (OutputStream os = enc.getDataStream(fs)) { | |
| os.write(inputExcel); | |
| } | |
| // Convert the POIFSFileSystem to a byte array | |
| try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { | |
| fs.writeFilesystem(baos); | |
| return baos.toByteArray(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| POST http://yourserver.com/your-endpoint | |
| Content-Type: multipart/form-data; boundary=boundarystring | |
| --boundarystring | |
| Content-Disposition: form-data; name="file"; filename="sample.txt" | |
| Content-Type: text/plain | |
| < ./path-to-your-file/sample.txt | |
| --boundarystring-- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PublicClientApplication app = PublicClientApplication.builder("YOUR_CLIENT_ID") | |
| .authority("https://login.microsoftonline.com/YOUR_TENANT_ID") | |
| .build(); | |
| RefreshTokenParameters parameters = RefreshTokenParameters.builder( | |
| Collections.singleton("YOUR_SCOPE"), | |
| "YOUR_REFRESH_TOKEN") | |
| .build(); | |
| Future<IAuthenticationResult> future = app.acquireToken(parameters); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Select({"<script>", | |
| SELECT_PRODUCTS, | |
| "WHERE desp_product.oid IN", | |
| "<foreach item='oidItem' index='index' collection='oids'", | |
| "open='(' separator=',' close=')'>", | |
| "#{oidItem}", | |
| "</foreach>", | |
| "</script>"}) | |
| @ResultMap("noParrent") | |
| public List<DespProduct> getAllProductsIn(@Param("oids") List<Integer> oids) ; |