Skip to content

Instantly share code, notes, and snippets.

View MrZoidberg's full-sized avatar

Mikhail Merkulov MrZoidberg

View GitHub Profile
@MrZoidberg
MrZoidberg / assignment.go
Created December 19, 2023 13:13
Integer Bag (Golang)
package main
type IntegerBag interface {
// Gt counts the number of items in the bag greater than or equal (>=) {@Code int}
// @param i - The number to compare each integer to.
// @return - How many integers match the criteria.
Gt(i int) int
// Ge counts the number of items in the bag greater than (>) {@Code int}
/// <summary>
/// Registers <see cref="IOptions{TOptions}"/> and <typeparamref name="TOptions"/> to the services container.
/// Also runs data annotation validation on application startup.
/// </summary>
/// <typeparam name="TOptions">The type of the options.</typeparam>
/// <param name="services">The services collection.</param>
/// <param name="configuration">The configuration.</param>
/// <returns>The same services collection.</returns>
public static IServiceCollection ConfigureAndValidateSingleton<TOptions>(
this IServiceCollection services,
@MrZoidberg
MrZoidberg / rabbitconsumer.py
Created March 28, 2021 19:37
Rabbit consumer in Python
#!/usr/bin/env python
import pika
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.exchange_declare(exchange='events', exchange_type='fanout')
result = channel.queue_declare(queue='create-order-failures', exclusive=True)
@MrZoidberg
MrZoidberg / example.cs
Last active June 5, 2020 20:49
Fluent validation
class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
static class PersonValidationExtensions
{
[Pure]
public static Func<IValidationContext<Person, string>> FirstName(this Func<IValidationContext<Person, Person>> context)
version: '3'
services:
mysql:
image: mysql
@MrZoidberg
MrZoidberg / test.html
Last active February 13, 2018 11:38
test html
<html lang="en-US" style="
height: 100%;
">
<body style="
/* width: 400px; */
/* max-height: 400px; */
/* background-color: red; */
overflow: hidden;
margin: 0;
display: inline-block;
@MrZoidberg
MrZoidberg / makefile
Last active February 2, 2018 11:20
Help command for makefile with colored output
# Needed SHELL since I'm using zsh
SHELL := /bin/bash
.PHONY: help
help: ## This help dialog.
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
printf "%-30s %s\n" "target" "help" ; \
printf "%-30s %s\n" "------" "----" ; \
for help_line in $${help_lines[@]}; do \
@MrZoidberg
MrZoidberg / README.md
Created January 26, 2018 23:35 — forked from rantav/README.md
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

@MrZoidberg
MrZoidberg / Makefile
Created January 10, 2018 15:44 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)