Skip to content

Instantly share code, notes, and snippets.

View marttp's full-sized avatar
🙇‍♂️
Let's improve equality of developer and make the world better together

Thanaphoom Babparn marttp

🙇‍♂️
Let's improve equality of developer and make the world better together
View GitHub Profile
@wpik
wpik / MongoConvertersConfig.java
Last active September 15, 2023 14:56
OffsetDateTime converters in Mongo in Spring
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.List;
@Configuration
@dyllanwli
dyllanwli / Pdf2JpegConverter.java
Created July 23, 2019 07:39
convert PDF to JPEG/multi-page tiff/image-pdf files
package org.doc2pdf.lambda;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
Short-circuit? Short-circuits on? Fulfilled on? Rejected on?
Promise.all Yes First rejected promise All promise fulfilled First rejected promise
Promise.allSettled No N/A Always N/A
Promise.race Yes First settled First promise fulfilled First rejected promise
Promise.any Yes First fulfilled First promise fulfilled All rejected promises
@Mahedi-61
Mahedi-61 / cuda_11.8_installation_on_Ubuntu_22.04
Last active August 11, 2025 03:47
Instructions for CUDA v11.8 and cuDNN 8.9.7 installation on Ubuntu 22.04 for PyTorch 2.1.2
#!/bin/bash
### steps ####
# Verify the system has a cuda-capable gpu
# Download and install the nvidia cuda toolkit and cudnn
# Setup environmental variables
# Verify the installation
###
### to verify your gpu is cuda enable check
@AntoineCheron
AntoineCheron / mono-defer-fromCallable.java
Last active August 19, 2022 11:33
Mono.defer vs Mono.fromCallable
// Both example give the same result
Integer getAnyInteger() throws Exception {
throw new RuntimeException("An error as occured for no reason.");
}
// Now, comparison between the two methods
void compareMonoCreationMethods() {
Mono<Integer> fromCallable = Mono.fromCallable(this::getAnyInteger);
// result -> Mono.error(RuntimeException("An error as occured for no reason."))
@soulmachine
soulmachine / jwt-expiration.md
Last active June 19, 2025 15:38
How to deal with JWT expiration?

First of all, please note that token expiration and revoking are two different things.

  1. Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
  2. Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.

1. How to hadle JWT expiration

A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.

Quoted from JWT RFC:

@mystygage
mystygage / docker-compose.yml
Created March 6, 2017 21:02
Microsoft SQL Server in Docker with data volume
version: '3'
services:
mssql-server-linux:
image: microsoft/mssql-server-linux:latest
volumes:
- mssql-server-linux-data:/var/opt/mssql/data
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=${SQLSERVER_SA_PASSWORD:-yourStrong(!)Password}

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8

@jsgao0
jsgao0 / CipherUtility.java
Last active July 15, 2024 08:45
Encryption with RSA using Java in Spring Framework.
package com.jsgao.bean;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
@martinheld
martinheld / KongJwt.md
Last active February 21, 2024 14:47
Short example to use JWT with Kong

JWT Kong Example

  • Get and Start Kong and Co
git clone [email protected]:Mashape/docker-kong.git
cd docker-kong/compose
docker-compose up
  • Create Kong API Route