Skip to content

Instantly share code, notes, and snippets.

View Romain-P's full-sized avatar
🈴
/home

- Romain-P

🈴
/home
View GitHub Profile
@Romain-P
Romain-P / Demo.kt
Last active May 26, 2024 01:44
Generic Spring boot with caching webClients service - Simplified but powerful exception-free webclient for external http calls. Made blocking on purpose, but feel free to remove block calls for reactive programming.
data class Response(val some: String, val data: Int)
data class ErrorResponse(val error: String, val some: String, val random: Int)
data class Request(val etc: String)
val url = "https://my-service.com/some/endpoint"
fun simple() {
val (dto, status) = service.post<Response>(url) {
it.bodyValue(Request("test"))
}
@Romain-P
Romain-P / ChaCha20-Poly1305.kt
Last active January 6, 2024 14:39
ChaCha20-Poly1305 Java/Kotlin Implementation
import java.io.File
import java.io.RandomAccessFile
import java.nio.ByteBuffer
import java.security.KeyFactory
import java.security.KeyPairGenerator
import java.security.SecureRandom
import java.security.spec.PKCS8EncodedKeySpec
import java.security.spec.X509EncodedKeySpec
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
@Romain-P
Romain-P / Main.kt
Created August 29, 2023 13:30
Create zip in memory.
import java.io.*
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
fun main() {
val sourcePath = "toZip"
val outputStream = ByteArrayOutputStream()
try {
@Romain-P
Romain-P / ArenaReplay.cpp
Last active August 29, 2024 16:54
Arena Replay Module for AzerothCore - Wow wotlk 3.3.5a
//
// Created by romain-p on 17/10/2021.
//
#include "Player.h"
#include "Opcodes.h"
#include "Battleground.h"
#include "BattlegroundMgr.h"
#include "ScriptMgr.h"
#include <unordered_map>
<loadData
file="t_famille.csv" relativeToChangelogFile="true"
quotChar="&quot;"
seperator=","
tableName = "T_FAMILLE" >
<column header="FAM_IDENT" type="numeric"/>
<column header="FAM_INTLOTEXP" type="string"/>
<column header="FAM_INTLOTIMP" type="string"/>
<column header="FAM_REFEXTERNE" type="string"/>
<column header="FAM_CODE" type="string"/>
<profile>
<id>skipInstall</id>
<activation>
<property>
<name>maven.install.skip</name>
<value>true</value>
</property>
</activation>
<build>
<pluginManagement>
package fr.idfm.sb.payment.client.vault.http;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import fr.idfm.sb.payment.client.VaultConfig;
import fr.idfm.sb.payment.client.dto.vault.AuthDto;
import fr.idfm.sb.payment.client.dto.vault.VaultLoginRequestDto;
import fr.idfm.sb.payment.client.dto.vault.VaultLoginResponseDto;
import fr.idfm.sb.payment.client.dto.vault.VaultTokenLookupSelfResponseDto;
import fr.idfm.sb.payment.common.constant.CustomHttpHeaders;
@Romain-P
Romain-P / Main.kt
Last active February 3, 2022 17:57
Maven POM - Dependency versions hard values to properties using a script
import java.io.File
import java.util.regex.Pattern
object Main {
val propertyPattern = Pattern.compile("<dependency>\\r\\n\\s+<groupId>.+<\\/groupId>\\r\\n\\s+<artifactId>(.+)<\\/artifactId>\\r\\n\\s+<version>([0-9].+)<\\/version>", Pattern.MULTILINE).toRegex()
val duplicatePattern = Regex("<([^>]+)>([0-9.A-Za-z]+)<\\/[^>]+>")
@JvmStatic
fun main(args: Array<String>) {
mergeDuplicates()
@Romain-P
Romain-P / async_socket.h
Last active June 7, 2020 12:55
non-blocking sockets
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <vector>
#include <string>
#include <iostream>
namespace AsyncSocket {
inline std::vector<WSAPOLLFD> watchList;
package fr.romain.ass3.persist;
import android.content.Context;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import fr.romain.ass3.MainActivity;
public final class LocalStorage {