Skip to content

Instantly share code, notes, and snippets.

View unclebean's full-sized avatar
🏠
Working from home

unclebean

🏠
Working from home
View GitHub Profile
import com.azure.core.credential.AzureKeyCredential;
import com.azure.search.documents.SearchClient;
import com.azure.search.documents.SearchClientBuilder;
import com.azure.search.documents.models.IndexDocumentsBatch;
import com.azure.search.documents.models.IndexDocumentsResult;
import com.azure.search.documents.models.IndexDocumentsAction;
import com.azure.search.documents.models.IndexActionType;
import org.springframework.stereotype.Service;
import java.util.Arrays;
package com.example.service;
import com.azure.search.documents.SearchClient;
import com.azure.search.documents.models.SearchOptions;
import com.azure.search.documents.models.SearchResult;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@unclebean
unclebean / TestVirtualThread.java
Last active February 4, 2025 01:28
tomcat enable virtual thread
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/test")
public class TestController {
@GetMapping("/thread")
public String checkThread() {
@unclebean
unclebean / update helm
Last active January 9, 2025 08:35
helm
# get release name from k8s
kubectl get secrets -n <namespace> | grep sh.helm.release
deploy:
stage: deploy
script:
- export IMAGE_TAG=${CI_COMMIT_TAG:-latest} # Fallback to 'latest' if not set
- sed -i "s/tag:.*/tag: ${IMAGE_TAG}/" values.yaml
- helm upgrade --install my-release my-chart -f values.yaml
@unclebean
unclebean / CustomClaimConverter
Last active December 13, 2024 08:27
EntraId+Graph
import org.springframework.core.convert.converter.Converter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@unclebean
unclebean / crate keystore
Last active December 12, 2024 07:52
certificate
import java.io.FileOutputStream;
import java.io.InputStream;
import java.security.KeyFactory;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
@unclebean
unclebean / CI
Last active November 14, 2024 07:59
pre-install - unzip files
test:
script:
# Find the initdb binary in any subdirectory of /tmp/embedded-pg/ and give it execute permissions
- find /tmp/embedded-pg/ -type f -name "initdb" -exec chmod +x {} \;
- find /tmp/embedded-pg/ -type f -name "initdb" -exec chmod +x {} \;
- ls -l $(find /tmp/embedded-pg/ -type f -name "initdb")
- apt-get update && apt-get install -y sudo
- sudo -u testuser mvn test -Djavax.net.debug=ssl,handshake
@unclebean
unclebean / test
Last active November 6, 2024 10:12
flyway embedded postgres
<dependencies>
<!-- JUnit 5 Dependency for Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.3</version> <!-- Use the latest stable version -->
<scope>test</scope>
</dependency>
<!-- Flyway Dependency -->
@unclebean
unclebean / FileUtils.kt
Last active November 5, 2024 09:46
tiff2pdf_kotlin
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardCopyOption
import java.util.zip.ZipEntry
import java.util.zip.ZipInputStream
import java.util.zip.ZipOutputStream
@unclebean
unclebean / App.js
Last active November 1, 2024 05:49
entra id integration
// App.js
import React from "react";
import { MsalProvider } from "@azure/msal-react";
import msalInstance from "./msalConfig";
import MainContent from "./MainContent";
function App() {
return (
<MsalProvider instance={msalInstance}>
<MainContent />