Skip to content

Instantly share code, notes, and snippets.

@alpharder
alpharder / add.php
Last active April 3, 2019 11:13
У вас нет доступа к библиотекам для работы с большими числами. Дано два положительных целых числа в виде строки. Числа могут быть очень большими, могут не поместиться в 64 битный integer. Использование exec не допускается. Задание: Написать функцию которая вернет сумму этих чисел.
<?php
$sum_test_cases = [
['1', '2', '3'],
['1', '100', '101'],
['0', '0', '0'],
['1234567', '1', '1234568'],
['9999999', '1', '10000000'],
// Следующие значения значительно больше, чем Int64
@alpharder
alpharder / gist:0252239c91612be90d8e287b28e8a178
Created June 20, 2019 17:26
incorrect date/time @ API response
curl -i https://api.selcdn.ru/v3/auth/tokens -XPOST -d '{"auth": { "identity": { "methods": ["password"], "password": { "user": { "id": "foo", "password": "bar"}}}}}'
HTTP/2 201
access-control-allow-origin: *
content-length: 781
content-type: application/json
x-subject-token: xxx
date: Thu, 20 Jun 2019 17:20:45 GMT
{"token":{"expires_at":"2019-06-21T11:35:20.207420239Z","issued_at":"2019-06-20T20:20:45.207420239Z","methods":["password"],"project":{"domain":{}},"catalog":[{"endpoints":[{"id":"asd","region_id":"ru-1","url":"https://api.selcdn.ru/v1/xxx","region":"ru-1","interface":"public"},{"id":"asd","region_id":"ru-1","url":"https://api.selcdn.ru/v1/xxx","region":"ru-1","interface":"admin"},{"id":"asd","region_id":"ru-1","url":"https://api.selcdn.ru/v1/xxx","region":"ru-1","interface":"internal"}],"type":"object-store","name":"swift","id":""}],"user":{"id":"asd","name":"xxx","domain":{"id":"default","name":"Default","links":{}}},"audit_ids":[""]}}
@alpharder
alpharder / orms.md
Last active October 16, 2025 21:34
On ORMs

Business logic entities ARE NOT ORM models/entities

Important note: This paragraph doesn't attempt to describe a "silver bullet" aka "the only right way of doing things". What it describes is just a preferred approach of isolating persistence details from business logic at Tesseract. The world won't collapse if domain service makes direct calls to ORM or SQL. For some (usually small) projects, the separation of concerns described below may not be beneficial, and only add complexity and cognitive load instead.

Domain layer should know nothing about any persistence layer.