This file contains 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
import org.apache.poi.ss.usermodel.*; | |
import org.apache.poi.xssf.usermodel.XSSFWorkbook; | |
import org.apache.poi.ss.util.CellRangeAddressList; | |
import org.apache.poi.ss.usermodel.DataValidation; | |
import org.apache.poi.ss.usermodel.DataValidationConstraint; | |
import org.apache.poi.ss.usermodel.DataValidationHelper; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
public class ExcelTemplateGenerator { |
This file contains 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
import java.security.SecureRandom; | |
public class RandomStringGenerator { | |
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
private static final int STRING_LENGTH = 8; | |
private static final SecureRandom RANDOM = new SecureRandom(); | |
public static String generateRandomString() { | |
StringBuilder sb = new StringBuilder(STRING_LENGTH); |
This file contains 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
@Pointcut("execution(* com.yourpackage..*(..)) && !within(org.springframework.security..*)") | |
public void applicationPackagePointcut() { | |
// Pointcut to intercept application methods but exclude Spring Security | |
} |
This file contains 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
import org.aspectj.lang.annotation.Aspect; | |
import org.aspectj.lang.annotation.AfterThrowing; | |
import org.aspectj.lang.annotation.Pointcut; | |
import org.springframework.stereotype.Component; | |
@Aspect | |
@Component | |
public class GlobalExceptionInterceptor { | |
// Define a pointcut to intercept all methods in your application's packages |
This file contains 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
import { Injectable } from '@angular/core'; | |
@Injectable({ | |
providedIn: 'root', | |
}) | |
export class ConsoleInterceptorService { | |
private isHandlingError = false; | |
constructor() { | |
this.overrideConsoleError(); |
This file contains 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
import { Injectable } from '@angular/core'; | |
@Injectable({ | |
providedIn: 'root', | |
}) | |
export class ConsoleInterceptorService { | |
private isHandlingError = false; | |
constructor() { | |
this.overrideConsoleError(); |
This file contains 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
function stringifyWithLimit(obj, maxSizeMB = 5) { | |
const maxSizeBytes = maxSizeMB * 1024 * 1024; // Convert MB to bytes | |
let jsonString = JSON.stringify(obj); | |
// Check if the JSON string exceeds the maximum size | |
if (jsonString.length > maxSizeBytes) { | |
console.warn(`The JSON string exceeds the ${maxSizeMB} MB limit. Truncating output.`); | |
// Truncate the JSON string to the max size limit | |
jsonString = jsonString.substring(0, maxSizeBytes); |
This file contains 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
import java.util.List; | |
import java.util.concurrent.CompletableFuture; | |
import java.util.concurrent.ExecutionException; | |
import java.util.stream.Collectors; | |
public class ParallelProcessingExample { | |
public static void main(String[] args) throws InterruptedException, ExecutionException { | |
List<Integer> list1 = List.of(1, 2, 3); | |
List<Integer> list2 = List.of(4, 5, 6); |
This file contains 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 void main(String[] args) throws InterruptedException, ExecutionException { | |
List<Integer> list1 = List.of(1, 2, 3); | |
List<Integer> list2 = List.of(4, 5, 6); | |
List<Integer> list3 = List.of(7, 8, 9); | |
CompletableFuture<Void> future1 = CompletableFuture.runAsync(() -> processList1(list1)); | |
CompletableFuture<Void> future2 = CompletableFuture.runAsync(() -> processList2(list2)); | |
CompletableFuture<Void> future3 = CompletableFuture.runAsync(() -> processList3(list3)); | |
// Wait for all futures to complete |
This file contains 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
import org.apache.http.client.HttpClient; | |
import org.apache.http.conn.ssl.NoopHostnameVerifier; | |
import org.apache.http.impl.client.HttpClients; | |
import org.apache.http.ssl.SSLContextBuilder; | |
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; | |
import org.springframework.security.oauth2.client.OAuth2RestTemplate; | |
import javax.net.ssl.SSLContext; | |
import java.security.cert.CertificateException; | |
import java.security.cert.X509Certificate; |