Skip to content

Instantly share code, notes, and snippets.

@zxdcm
zxdcm / Mark Massé - REST API Design Rulebook.md
Created March 15, 2023 18:18
Mark Massé - REST API Design Rulebook

Mark Massé - REST API Design Rulebook

CHAPTER 1. Introduction

REST API Design

For many of us, designing a REST API can sometimes feel more like an art than a science. Some best practices for REST API design are implicit in the HTTP standard, while other pseudo-standard approaches have emerged over the past few years. Yet today, we must continue to seek out answers to a slew of questions, such as:

  • When should URI path segments be named with plural nouns?
  • Which request method should be used to update resource state?
@zxdcm
zxdcm / CustomerController.cs
Created July 11, 2022 09:20 — forked from vkhorikov/CustomerController.cs
Handling failures and input errors in a functional way
[HttpPost]
public HttpResponseMessage CreateCustomer(string name, string billingInfo)
{
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo);
Result<CustomerName> customerNameResult = CustomerName.Create(name);
return Result.Combine(billingInfoResult, customerNameResult)
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
.OnSuccess(() => new Customer(customerNameResult.Value))
.OnSuccess(
@zxdcm
zxdcm / README.md
Created March 23, 2022 11:30 — forked from andris9/README.md
Extremely simple HTTP proxy for changing Host: header Useful when proxying requests to virtual hosts that require Host: header to be set.

Setup reverse tunnel

Run the following in your client machine

ssh -R EXPOSED_PORT:localhost:SERVICE_PORT USER@HOST

Where

  • EXPOSED_PORT is the port exposed to the internet in the proxy server
  • SERVICE_PORT is the port your application is listening in your machine
@zxdcm
zxdcm / tokens.md
Created July 4, 2021 18:25 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
GUIDs hurt performance of inserts.
Relational databases use B+ tree structure to store data.
If data coming in is not ordered, then a lot of IO work is required to rearrange the leafs.
GUIDs are random, so they may lead to heavy performance drawbacks, especially with large tables.
Database generated integers may hurt performance of inserts as well but for another reason.
When a database generates a new auto-incremented value for a primary key, it takes a lock to avoid race conditions.
It causes a performance issue that shows up in scenarios with multithread or bulk inserts.
IF EXISTS (SELECT * FROM dbo.Ids WHERE EntityId = @EntityId)
1. Базовая структура блока plsql
Declare - необязательно
(const, vars, types, cursors, user exceptions)
Begin - обязательно
(PL/SQL, SQL commands)
Exception - необязательно
Действий при возникновении ошибки
1. async vs defer
<script src="1.js" defer></script>
<script src="2.js" defer></script>
defer - preserve the execution order.
Naming:
jquery obj ? $name : name
https://www.learnentityframeworkcore.com/
1. Adding
2. Modifying
a)
var author = context.Authors.First(a => a.AuthorId == 1);
author.FirstName = "Bill";
context.SaveChanges();
Схема позиционирования
Существует три схемы позиционирования.
Стандартная: объект размещается согласно своему положению в дереве отображения и в дереве DOM
а также своему типу и размерам окна
Плавающая: сначала по стандартной схеме, затем смещается в крайнее правое или крайнее левое положение
Абсолютная: положение объекта в дереве отображения отличается от его положения в дереве DOM.
@zxdcm
zxdcm / gist:069deadf53ed04990d9f34e73a49c276
Last active November 23, 2020 21:35
Networks, HTTP, DNS, and so on
Proxy may return info from cache!!
Forward proxy (for client)
Reverse proxy (for server, service)
(можно на отдельный сервер вынести отправку статического контента,
как раз reverse proxy)
CDN - Content Delivery Network
Proxy may return info from cache