Skip to content

Instantly share code, notes, and snippets.

@andreevmipt
andreevmipt / Dockerfile
Last active December 7, 2022 20:11
Dockerfile_gentoo_from_scratch
# syntax = docker/dockerfile:1.2
# Use the empty image with the portage tree as the first stage
FROM gentoo/portage:latest as portage
# Gentoo stage3 is the second stage, basically an unpacked Gentoo Linux
FROM gentoo/stage3:amd64-systemd as base
# FROM ksmanis/stage3:latest as base
LABEL org.opencontainers.image.authors="andreev.mipt@gmail.ru"
{
"data": [
{
"measure": [
"relative",
"relative",
"relative",
"relative",
"relative",
"relative",
@Configuration
class RestTemplateCustomConfig {
@Autowired
lateinit var restTemplate: RestTemplate
@PostConstruct
fun restOperations() {
restTemplate.messageConverters.add(0, mappingJacksonHttpMessageConverter())
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
import java.lang.reflect.Field;
import java.time.temporal.Temporal;
import java.util.ArrayDeque;
import java.util.ArrayList;
private final static ExecutorService EXECUTOR_2019V2 = createExecutorService(8, 64);
public static ExecutorService createExecutorService(int threadsCount, int queueCapacity) {
BlockingQueue queue = new ArrayBlockingQueue(queueCapacity);
AtomicInteger thrIdx = new AtomicInteger(0);
ThreadPoolExecutor executor = new ThreadPoolExecutor(threadsCount, threadsCount, 0, TimeUnit.MILLISECONDS,
queue, r -> new Thread(r, "2019v2_" + thrIdx.incrementAndGet()));
executor.setRejectedExecutionHandler((r, ex) -> {
log.warn("Task {} rejected for 2019_v2", r.toString());
});
@andreevmipt
andreevmipt / SSLPoke.java
Created July 8, 2019 15:50 — forked from 4ndrej/SSLPoke.java
Test of java SSL / keystore / cert setup. Check the commet #1 for howto.
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
public static void main(String[] args) {
~/.m2/settings.xml
<proxies>
<proxy>
<id>[org]</id>
<active>true</active>
<protocol>http</protocol>
<username>{USERNAME}</username>
<password>{PASSWORD}</password>
<host>127.0.0.1</host>
https://habr.com/ru/post/435594/
https://habr.com/ru/post/358724/
https://gist.github.com/ptarjan/e38f45f2dfe601419ca3af937fff574d#request-rate-limiter
https://stripe.com/en-US/blog/rate-limiters
https://redislabs.com/redis-best-practices/basic-rate-limiting/
https://medium.com/figma-design/an-alternative-approach-to-rate-limiting-f8a06cf7c94c
https://www.dr-josiah.com/2014/11/introduction-to-rate-limiting-with_26.html
https://www.dr-josiah.com/2014/11/introduction-to-rate-limiting-with.html
https://github.com/wangzheng0822/ratelimiter4j
https://github.com/chriso/redback/blob/master/lib/advanced_structures/RateLimit.js
https://github.com/hamsterready/redis-ratelimit
https://github.com/marcosbarbero/spring-cloud-zuul-ratelimit
https://www.redisgreen.net/blog/intro-to-lua-for-redis-programmers/
https://www.compose.com/articles/a-quick-guide-to-redis-lua-scripting/