Skip to content

Instantly share code, notes, and snippets.

@seralexeev
seralexeev / ObjectSaver
Last active August 29, 2015 14:05
Preparing to save with EntityFramework
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using Framework.Maybe;
namespace Base.DAL.EF
{
public class ObjectSaver<TEntity> : IObjectSaver<TEntity> where TEntity : BaseObject
using System;
using System.Collections;
using System.Collections.Generic;
class Program {
public static void Main() {
var input = "12";
using (new switchOf(input) {
@seralexeev
seralexeev / check-gzip.sh
Created December 28, 2016 13:12 — forked from timendum/check-gzip.sh
Check if gzip is enabled [ http bash curl ]
curl -I -H "Accept-Encoding: gzip,deflate" "$URL" --silent | grep -i "Content-Encoding:"
# OR
curl -H "Accept-Encoding: gzip,deflate" "$URL" --silent --write-out "%{size_download}" --output /dev/null
curl "$URL" --silent --write-out "%{size_download}" --output /dev/null
# 2nd must be greater the 1st
at GraphQL.Utilities.SchemaPrinter.ResolveName(IGraphType type) in C:\\Projects\\graphql-dotnet\\src\\GraphQL\\Utilities\\SchemaPrinter.cs:line 344\r\n
at GraphQL.Utilities.SchemaPrinter.ResolveName(IGraphType type) in C:\\Projects\\graphql-dotnet\\src\\GraphQL\\Utilities\\SchemaPrinter.cs:line 341\r\n
at GraphQL.Validation.ValidationContext.Print(IGraphType type) in C:\\Projects\\graphql-dotnet\\src\\GraphQL\\Validation\\ValidationContext.cs:line 158\r\n
at GraphQL.Validation.Rules.ScalarLeafs.Field(IGraphType type, Field field, ValidationContext context) in C:\\Projects\\graphql-dotnet\\src\\GraphQL\\Validation\\Rules\\ScalarLeafs.cs:line 47\r\n
at GraphQL.Validation.Rules.ScalarLeafs.<>c__DisplayClass2_0.<Validate>b__1(Field f) in C:\\Projects\\graphql-dotnet\\src\\GraphQL\\Validation\\Rules\\ScalarLeafs.cs:line 26\r\n
at GraphQL.Validation.EnterLeaveListener.<>c__DisplayClass4_0`1.<Match>b__1(INode n) in C:\\Projects\\graphql-dotnet\\src\\GraphQL\\Validation\\EnterLeaveListener.cs:line 59\r
@seralexeev
seralexeev / memoize.ts
Created August 15, 2018 08:36
Implementing Memoization in Typescript
const memoize = <TS extends any[], R>(
fn: (...args: TS) => R,
keyfn: (...args: TS) => string = (...args: TS) => args.map((x, i) => `${i}=${x}`).join("|")
): ((...args: TS) => R) => {
const cache: Record<string, R> = {};
return (...args: TS) => {
const key = keyfn(...args);
return key in cache ? cache[key] : (cache[key] = fn(...args));
};
};
@seralexeev
seralexeev / RPC.md
Last active February 7, 2023 22:39

RPC / REST

ControllerInvoker is a base part of the request handling pipeline.

  • it is responsible for invoking the endpoint handler with the correct arguments.
  • it is responsible for getting the user from headers / cookies / etc.
  • ControllerInvoker can be a controller itself. If we do integration with a service that doesn't have much logic in it
  • we use class field method names with namespace as a endpoint name