Skip to content

Instantly share code, notes, and snippets.

View Marusyk's full-sized avatar
πŸ¦‡
Always be yourself, unless you can be Batman, then always be Batman

Roman Marusyk Marusyk

πŸ¦‡
Always be yourself, unless you can be Batman, then always be Batman
View GitHub Profile
@Marusyk
Marusyk / noname
Last active December 27, 2024 18:22
Find antipatterns of ToList
\.(?:ToList|ToArray)\(\)\s*\.|Select\(. => [^)]*\)|ForEach\(. => [^)]*\)|(?:ToList|ToArray)\(\)\s*\.Count > 0
// https://www.youtube.com/live/LaoRkzSE5tI?si=uejA0fmTeNj_1a9-
@Marusyk
Marusyk / start-local.sh
Created October 17, 2024 09:06
elastic start local
#!/bin/sh
# --------------------------------------------------------
# Run Elasticsearch and Kibana for local testing
# Note: do not use this script in a production environment
# --------------------------------------------------------
#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
@Marusyk
Marusyk / git-pull-all-services.sh
Created September 6, 2024 07:39
git pull all services
#!/bin/bash
REPOSITORIES=(
cloud.analytics
cloud.applications
)
BRANCH=main
for REPOSITORY in ${REPOSITORIES[*]}
do
@Marusyk
Marusyk / acr_tasks.sh
Last active September 6, 2024 07:36
Automatically purge images from an Azure Container Registry
#!/bin/bash
REGISTRY={{name}}
REPOSITORIES=$(az acr repository list --name $REGISTRY --output tsv | grep '^prefix')
for REPOSITORY in ${REPOSITORIES[*]}
do
echo =======================================================================
echo Creating task for repository: $REPOSITORY
echo =======================================================================
PURGE_CMD="acr purge --filter '$REPOSITORY:.*' --ago 7d --untagged --keep 7"
@Marusyk
Marusyk / Decrypt.cs
Created January 5, 2022 20:17
Decrypt JWE with X.509 private key
private static X509Certificate2 LoadCertificate(string certName)
{
using var store = new X509Store(StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
var certificateCollection = store.Certificates.Find(X509FindType.FindBySubjectName, certName, false);
if (certificateCollection.Count == 0)
{
throw new Exception($"No matching certificate found for subject '{deviceName}'");
}
@Marusyk
Marusyk / ValuesController.cs
Last active November 26, 2018 20:54
Demonstrates how to route works with abstract base controllers actions and inherited controllers in ASP.NET Core WebAPI
// Example for question https://stackoverflow.com/questions/53488184/asp-net-core-controllers-route-attribute-inheritance-and-abstract-controllers-ac#53488184
public abstract class BaseApiController : Controller
{
[HttpGet]
[Route("")]
public virtual IActionResult GetAll()
{
return Ok("GetAll action from base");
}