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
# Source: https://gist.github.com/6039be2497217a555fba5eafea076ba3
#########################################################################
# Werf: Glue Together Git, Docker, Helm, Kubernetes For CI/CD Pipelines #
# https://youtu.be/WM06S_ltcVs #
#########################################################################
# Additional Info:
# - werf: https://werf.io
# - GitHub CLI - How to manage repositories more efficiently: https://youtu.be/BII6ZY2Rnlc
serverless create \
--template google-nodejs \
--path gcp-function
cd gcp-function
ls -1
cat index.js
# Source: https://gist.github.com/5b3cd6f336e2d9e6682c1a1792c860d0
####################
# Creating Cluster #
####################
# Docker for Desktop with Istio: https://gist.github.com/d9b92a8e03c2403624fcef25f3fcd4e5
# minikube with Istio: https://gist.github.com/01f562077f31750d24c8b7ef5b3ae4d0
# GKE with Istio: https://gist.github.com/80c379849b96f4ae5a2ccd30d843f205
# EKS with Istio: https://gist.github.com/957971fe8664de180ecc466a8da6017d
# Setup Cluster
for i in 1 2 3; do
docker-machine create -d virtualbox swarm-$i
done
eval $(docker-machine env swarm-1)
docker swarm init --advertise-addr $(docker-machine ip swarm-1)
@Miha-x64
Miha-x64 / Stats.java
Last active February 1, 2022 12:08 — forked from zhong-j-yu/Stats.java
class Stats - used with Stream.collect() to find min and max
package net.aquadc.util;
import java.util.Comparator;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collector;
/**
* Stats of a stream of objects, including {@linkplain #size()}, {@linkplain #min()}, and {@linkplain #max()}.
* <p>This is intended to be used with {@link java.util.stream.Stream#collect}, for example</p>
@Miha-x64
Miha-x64 / CollectionWrap.java
Last active February 1, 2022 12:10
Absolutely normal and safe decorator class which can be easily broken with type-casting
import java.util.Collection;
import java.util.Comparator;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.NavigableSet;
import java.util.Queue;
import java.util.Set;
import java.util.SortedSet;
// Java(?) way
interface Fraction<E extends Exception> {
int numerator() throws E;
int denominator() throws E;
}
class FracStatic implements Fraction<RuntimeException> // don't force catching
class FracSum<E1, E2> implements Fraction<EitherException<E1, E2>> // impossible due to type erasure
// Kotlin, Scala, Rust way
@Miha-x64
Miha-x64 / ArrayLists.java
Last active February 1, 2022 12:30
Utility-class for marking several ArrayList elements as removed and removing them all then.
package net.aquadc.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* For lists with O(n) random-deletion time (array-based lists, like {@link ArrayList}),
* it's faster to mark items as removed and them sweep them all together.
@theboreddev
theboreddev / GroupByClassifier.java
Created July 18, 2020 20:35
youngestEmployeeBySex
final Map<Employee.Sex, Optional<Employee>> youngestEmployeeBySex = employees.stream()
.collect(groupingBy(Employee::getSex, minBy(comparing(Employee::getAge))));
@theboreddev
theboreddev / GroupByClassifier.java
Created July 18, 2020 20:49
employeesOverThirtyBySex
final Map<Employee.Sex, List<Employee>> employeesOverThirtyBySex = employees.stream()
.collect(groupingBy(Employee::getSex, filtering(employee -> employee.getAge() > 30, toList())));