Skip to content

Instantly share code, notes, and snippets.

View Tirael's full-sized avatar
🏠
Working from home

Georgiy Zhuykov Tirael

🏠
Working from home
  • Moscow, Moscow City, Russian Federation
View GitHub Profile
@Tirael
Tirael / SubscribeAsync.cs
Created November 1, 2024 14:22
SubscribeAsync
// https://github.com/dotnet/reactive/issues/459
// https://github.com/dotnet/reactive/issues/459#issuecomment-555607144
/*
The difference is that Observable.FromAsync is deferred, while .ToObservable is not; i.e. the latter will execute the given async function immediately once a new item is being yielded from the observable.
This difference is due to the fact that the parameter of Observable.FromAsync(...) is a Func<Task>, while the parameter of .ToObservable is a Task; i.e. the former is a not-yet-started asynchronous operation which can be started when it is desired, while the latter is an already-started asynchronous operation.
It means that when you create an observable by using Observable.FromAsync(...) the subscriber can control the starting of the asynchronous operation, while by using .ToObservable the subscriber cannot control the starting of the asynchronous operation because that operation has already started.
You can check this behavior by running the following example:
*/
void Main()
{
asyncapi: 3.0.0
id: 'https://github.com/dalelane/my-first-asyncapi-v3-doc'
info:
title: 'Title of my app'
version: '0.0.1'
description: 'This is what **my app** does. It uses `code`.'
termsOfService: https://dalelane.co.uk/asyncapi/terms-of-service
contact:
name: Dale Lane
url: https://dalelane.co.uk
@Tirael
Tirael / prom-k8s-request-limits.md
Created November 30, 2023 13:50 — forked from max-rocket-internet/prom-k8s-request-limits.md
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /
@Tirael
Tirael / .editorConfig
Created October 26, 2023 10:09 — forked from RealDotNetDave/.editorConfig
.editorConfig by David (dotNetDave) McCarter - dotNetTips.com
# dotNetDave's (David McCarter) Editor Config - dotNetTips.com
# Updates to this file are posted quarterly at: https://bit.ly/EditorConfig5
# Updated August 2023
# dotNetDave's books available at: http://bit.ly/RockYourCodeBooks
# Rockin' the Code World with dotNetDave (weekly live show): https://www.c-sharpcorner.com/live/rockin-the-code-world-with-dotnetdave
root = true
# All Files
[*]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Building Evolutionary Architectures

Chapter 1 - Software Architecture

Architecture is 'the important stuff, whatever that is' or 'the parts that are hard to change later'. An architect analyzes business, domain, and other requirements to develop solutions that satisfy a list of prioritized architectural characteristics (-ilities). We should consider time and change with respect to architecture, or evolvability.

Software ecosystems are in a state of dynamic equilibrium. New languages, tools, methods constant force new equilibriums to emerge (free OS, linux, + free operations, puppet, led to the shift to containers). The pace of change in technology is constantly and rapidly changing in unexpected ways. We should architect systems knowing the landscape will change. Make ease of change a principal of architecture, remove the 'hard to change' definition of architecture.

An evolutionary architecture supports guided, incremental change across multiple dimensions. Evolvability is a meta characteristic that

public class RescheduleStrategy
{
private const string RetryAttemptPropertyName = "retry-attempt";
private const int MaxRetryAttempts = 5;
private const int Exponent = 2;
private readonly Random _random = new Random();
private readonly IQueueClient _queueClientImplementation;
private readonly TimeSpan _initialDelay = TimeSpan.FromSeconds(5);
public async Task ScheduleRetryAsync(Message message)
@Tirael
Tirael / grafana-curl-commands.sh
Created December 1, 2022 10:37 — forked from thenayr/grafana-curl-commands.sh
Create annotations in Grafana using Curl
# Curl command to create new annotation
curl -H "Content-Type: application/json" -X POST \
-d '{"tags":["deployment","Environment"],"text":"$serviceName was deployed to $environment with commit ID $commitID"}' \
http://grafana.qa.lonelyplanet.com/api/annotations
# Response
HTTP/1.1 200
Content-Type: application/json
{"message":"Annotation added"}
@Tirael
Tirael / Antonyms.md
Created September 29, 2022 11:21 — forked from maxtruxa/Antonyms.md
A list of common terms used in programming and their respective antonyms.

Antonym List

Note: The table headings (positive/negative) are not necessarily meaningful.

Positive Negative
acquire release
add remove (e.g. an item), subtract (arithmetic)
advance retreat
allocate deallocate (correct), free (common)
allow deny
@Tirael
Tirael / secret_detection.yml
Created September 27, 2022 08:31 — forked from halloei/secret_detection.yml
GitLab Secret Detection which fails when vulnerabilities were found
# This job overrides the default secret detection job from GitLab
# (https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Jobs/Secret-Detection.gitlab-ci.yml)
# and fails if vulnerabilities were found. The exit code represents the number of vulnerabilities.
#
# Requirements:
# - Stage "test"
include:
- template: Security/Secret-Detection.gitlab-ci.yml