Skip to content

Instantly share code, notes, and snippets.

View AlexRogalskiy's full-sized avatar
🛰️
Work on stuff that matters

Alexander AlexRogalskiy

🛰️
Work on stuff that matters
View GitHub Profile
@AlexRogalskiy
AlexRogalskiy / addons.sql
Last active April 2, 2025 08:26
db-refcard
--==========================================================================================
SELECT * FROM customers AS c
WHERE EXISTS (
SELECT * FROM orders AS o
WHERE o.id = c.id
AND o.date = (CURRENT_DATE - '3 MONTH'::INTERVAL) --DATE_SUB(curdate(), INTERVAL 3 MONTH)
GROUP BY MONTH(o.date)
HAVING COUNT(DISTINCT MONTH(o.date)) = 3;
);
--==========================================================================================
@bradtraversy
bradtraversy / terminal-commands.md
Last active May 15, 2025 15:46
Common Terminal Commands

Common Terminal Commands

Key Commands & Navigation

Before we look at some common commands, I just want to note a few keyboard commands that are very helpful:

  • Up Arrow: Will show your last command
  • Down Arrow: Will show your next command
  • Tab: Will auto-complete your command
  • Ctrl + L: Will clear the screen
@dhet
dhet / LenientFutureCollector.java
Last active January 15, 2024 17:34
Wait for the completion of multiple Java Futures or time out
import java.time.Duration;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.*;
import java.util.stream.Collector;
@AlexRogalskiy
AlexRogalskiy / links.txt
Last active October 16, 2024 20:39
Data links
public Mono<String> deleteCustomer(@PathVariable String customerId){
return webClient.delete()
.uri("/customers/" + customerId)
.retrieve()
.bodyToMono(String.class)
.transform(it -> {
ReactiveCircuitBreaker rcb = reactiveCircuitBreakerFactory.create("customer-service");
return rcb.run(it, throwable -> Mono.just(customerId));
});
}
@RestController
@Slf4j
@RequiredArgsConstructor
public class CustomerClientController {
private final WebClient webClient;
private final ReactiveCircuitBreakerFactory reactiveCircuitBreakerFactory;
@PostMapping("/customers")
public Mono<CustomerVO> createCustomer(CustomerVO customerVO){
resilience4j.circuitbreaker:
instances:
customer-service:
failureRateThreshold: 50
minimumNumberOfCalls: 10
slidingWindowType: TIME_BASED
slidingWindowSize: 10
waitDurationInOpenState: 50s
permittedNumberOfCallsInHalfOpenState: 3
@Bean
public Customizer<ReactiveResilience4JCircuitBreakerFactory> customerServiceCusomtizer() {
return factory -> {
factory.configure(builder -> builder
.timeLimiterConfig(TimeLimiterConfig.custom().timeoutDuration(Duration.ofSeconds(2)).build())
.circuitBreakerConfig(CircuitBreakerConfig.ofDefaults()), "customer-service");
};
}
AmazonEventBridge client = AmazonEventBridgeClient.builder()
.withRegion(Regions.US_EAST_1)
.withCredentials(new DefaultAWSCredentialsProviderChain())
.build();
PutEventsRequestEntry requestEntry = new PutEventsRequestEntry();
requestEntry.withSource("customer-service") //this needs to match the event pattern defined in step 4 below
.withDetailType("customer-created-detail-type") //this needs to match the event pattern defined in step 4 below
.withDetail(toJson(customerWasCreated)) //this converts the event object into JSON string
.withEventBusName("test-event-bus"); //this needs to match the custom event bus name created in step 4 below
---
name: "tagged-release"
on:
push:
tags:
- "v*"
jobs:
gh_tagged_release: