Skip to content

Instantly share code, notes, and snippets.

View ru-rocker's full-sized avatar

ru rocker ru-rocker

View GitHub Profile
@ru-rocker
ru-rocker / Service.java
Last active April 8, 2024 17:19
SpringWebFlux Unit Test with MockWebServer from OkHttp
@Service
public class TokenValidatorServiceImpl implements TokenValidatorService {
private String fileAttUrlPath;
private String fileAttRoute;
@Autowired
private ClientProperties clientProperties;
private final WebClient.Builder webClientBuilder;
# sample for lifecycle config
variable "bucket_lifecycle_config" {
type = list(any)
description = "Bucket lifecycle. Set empty list if you want to ignore the lifecycle configuration."
default = []
}
bucket_lifecycle_config = [{
"id" = "DisposePLIST"
"prefix" = "disposable"
vim ~/.aws/config
[ansible-dynamic-inventory]
region = ap-southeast-1
vim ~/.aws/credentials
[ansible-dynamic-inventory]
aws_access_key_id = XXXXXXXX
aws_secret_access_key = YYYYYYYYYYYYYYYY
@ru-rocker
ru-rocker / StreamMatchSample.java
Created December 17, 2016 04:14
Java 8 Stream Match sample. Using anyMatch, allMatch and noneMatch
//there is at least one negative number
public void anyMatch(){
boolean anyMatch;
anyMatch = IntStream.of(-1,2,3,5,7,9)
.anyMatch(i -> i < 0);
System.out.format("It is [%b] that at least one negative number \n",
anyMatch);
//Output: It is [true] that at least one negative number
@ru-rocker
ru-rocker / instrument.go
Created April 1, 2017 14:53
metrics middleware
package lorem_metrics
import (
"github.com/go-kit/kit/metrics"
"time"
)
func Metrics(requestCount metrics.Counter,
requestLatency metrics.Histogram) ServiceMiddleware {
return func(next Service) Service {
apiVersion: apps/v1
kind: Deployment
metadata:
name: mock-endpoint
namespace: ns1
spec:
selector:
matchLabels:
name: mock-endpoint
template:
import org.apache.commons.lang.StringUtils;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
packer {
required_plugins {
amazon = {
version = ">= 0.0.2"
source = "github.com/hashicorp/amazon"
}
}
}
source "amazon-ebs" "centos7" {
@ru-rocker
ru-rocker / Async.java
Last active April 26, 2021 13:33
CDK CloudWatch Lambda Java
// RandomMessageProcessor.java
// snippet code
@Async("asyncExecutor")
public void process(RequestDto requestDto) {
if(reentrantLock.isLocked()) {
logger.info("Another thread is processing the processor!");
return;
}
reentrantLock.lock();
@hopping
Scenario Outline: Accumulative transaction during 5 minutes interval: amount above $1500 then notify
Given Customer has a credit card with account number "<cc>"
When Customer transacts $<amount1> at "<event1>"
And Customer transacts $<amount2> at "<event2>"
And Customer transacts $<amount3> at "<event3>"
Then Fraud flag is "<flag>"
And total suspicious amount is $<total>
Examples:
|cc|amount1|amount2|amount3|event1|event2|event3|flag|total|