Skip to content

Instantly share code, notes, and snippets.

View maximgorbatyuk's full-sized avatar

Maxim Gorbatyuk maximgorbatyuk

View GitHub Profile
/// <summary>
/// Get https://localhost:5001/home/StringEqualsTest
/// </summary>
public async Task<IActionResult> StringEqualsTest()
{
(string post1, bool isCacheHit1) = await GetValuesLower("post1");
(string post2, bool isCacheHit2) = await GetValuesLower("post2");
(string post1_1, bool isCacheHit1_1) = await GetValuesLower("post1");
@maximgorbatyuk
maximgorbatyuk / fingerprint.md
Created November 26, 2019 03:39 — forked from zmts/fingerprint.md
Get browser fingerprint example (fingerprintjs2)

Get browser fingerprint example (fingerprintjs2)

import * as Fingerprint2 from 'fingerprintjs2'

function _getFingerprint () {
  return new Promise((resolve, reject) => {
    async function getHash () {
      const options = {
        excludes: {
@maximgorbatyuk
maximgorbatyuk / docker.md
Created December 17, 2019 10:02 — forked from zmts/docker.md
Docker, TypeScript, Node.js

Docker, TypeScript, Node.js

Preconditions:

  • TS application listening port: 7777
|-- dist
|-- src
|-- .dockerignore
|-- Dockerfile
@maximgorbatyuk
maximgorbatyuk / Directory.build.props
Last active February 17, 2020 02:20
How To Rreject Invalid Code. Backend
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Description>An implementation of StyleCop rules using the .NET Compiler Platform</Description>
<Product>StyleCop.Analyzers</Product>
<Company>Tunnel Vision Laboratories, LLC</Company>
<Copyright>Copyright © Tunnel Vision Laboratories, LLC 2015</Copyright>
<NeutralLanguage>en-US</NeutralLanguage>
version: '3.4'
services:
db:
image: postgres:13.0
container_name: postgresql-13
restart: always
environment:
POSTGRES_USER: promo
POSTGRES_PASSWORD: Str0ngPassword!
using System;
using System.Text.RegularExpressions;
namespace Utils.Helpers
{
public class EmailValidRegex : Regex
{
private const string Pattern =
@"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$";
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace MultiThread_25
{
class Program
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Utils.Helpers;
namespace YourNamespace
{
public static class JsonSerializationExtensions
{
private static readonly SnakeCaseNamingStrategy _snakeCaseNamingStrategy
= new SnakeCaseNamingStrategy();
using System.Text.Json;
using Utils.Serialization;
namespace YourNamespace
{
public class SnakeCaseNamingPolicy : JsonNamingPolicy
{
public override string ConvertName(string name) => name.ToSnakeCase();
}
}
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// ...
services
.AddMvc()
.AddJsonOptions(x =>
{
x.JsonSerializerOptions.PropertyNamingPolicy = new SnakeCaseNamingPolicy();