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.concurrent.CountDownLatch; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
/** | |
* Run in multiple threads. | |
*/ | |
public class RunInThreads { |
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
@Entity | |
@Table(name = "category_detail") | |
@Data | |
@NoArgsConstructor | |
@AllArgsConstructor | |
@EqualsAndHashCode(of = "id") | |
public class CategoryDetailEntity { | |
@Id | |
@Column(name = "category_id") |
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.ArrayList; | |
import java.util.List; | |
public class PowersetCombination { | |
// Method to generate all k-combinations of a given set | |
public static <T> List<List<T>> generateCombinations(List<T> set, int k) { | |
List<List<T>> combinations = new ArrayList<>(); | |
generateCombinations(set, k, 0, new ArrayList<>(), combinations); | |
return combinations; |
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){ | |
int i = ((ThenResult<String>) ()-> "1") | |
.then(s->Integer.parseInt(s)) | |
.result() | |
} | |
public interface ThenResult<T> { | |
T result(); |
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 io.github.resilience4j.ratelimiter.RateLimiter; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import java.time.Duration; | |
@Configuration | |
public class RateLimiterConfig { | |
@Bean |
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
## Postgresql configuration | |
set Postgresql max_connections to 250 | |
## HikariCP configuration | |
spring.datasource.hikari.minimumIdle=0 | |
spring.datasource.hikari.maximum-pool-size=90 | |
spring.datasource.hikari.maxLifetime=900000 | |
spring.datasource.hikari.data-source-properties.useServerPrepStmts=false |
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 byte[] getByte(UUID uuid) { | |
ByteBuffer bb = ByteBuffer.wrap(new byte[16]); | |
bb.putLong(uuid.getMostSignificantBits()); | |
bb.putLong(uuid.getLeastSignificantBits()); | |
return bb.array(); | |
} |
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
find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull \; |
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.*; | |
import java.util.concurrent.locks.*; | |
/** | |
* A bank with a number of bank accounts that uses locks for serializing access. | |
*/ | |
public class Bank | |
{ | |
private final double[] accounts; |
NewerOlder