Skip to content

Instantly share code, notes, and snippets.

View EXayer's full-sized avatar
🧿
Focusing

Vitalii Honcharuk EXayer

🧿
Focusing
  • SoftHouseGroup
  • Vinnytsia, Ukraine
  • 12:46 (UTC +02:00)
  • X @theyseemenot
View GitHub Profile
@EXayer
EXayer / php_storm_quick_fix_wrong_example.php
Last active February 11, 2024 02:01
PHP Storm - wrong quick fix hint '$relationModels[Deal::class]->items[$parseResultDto->key] ?? null' is always 'null'
View php_storm_quick_fix_wrong_example.php
<?php
namespace App\Domain\Entities\LootList;
use App\Domain\Entities\LootList\Models\LootList;
use Illuminate\Database\Eloquent\Model;
use ItemSchema\Parser\DataTransferObjects\LootListParseResultDto;
class LootListToItemSyncService
{
@EXayer
EXayer / numberAbbreviation.php
Last active February 10, 2021 22:56 — forked from bcole808/numberAbbreviation.php
Shorten large numbers into abbreviations (i.e. 1,500 = 1.5k), (slightly optimized)
View numberAbbreviation.php
<?php
/**
* Shorten large numbers into abbreviations (i.e. 1,500 = 1.5k)
*
* @param int $number Number to shorten
* @return String A number with a symbol
*/
function numberAbbreviation($number) {
$abbrevs = [1000000000000 => 'T', 1000000000 => 'B', 1000000 => 'M', 1000 => 'K', 1 => ''];
@EXayer
EXayer / the_monty_hall_problem.js
Created October 9, 2020 13:31
The Monty Hall Problem - brute force proof
View the_monty_hall_problem.js
const CHANCE = 3;
function rollDoor() {
return Math.floor(Math.random() * CHANCE);
}
function randArr(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
@EXayer
EXayer / count_rectangles_inside_matrix.php
Created June 24, 2020 20:42
How many rectangles a matrix can fit?
View count_rectangles_inside_matrix.php
<?php
/**
* Counts all rectangles inside matrix by loop.
*
* For 3x3:
* *_*_* // 1x1 = 4
* *_*_* // 1x2 = 2
* * * * // 2x1 = 2
* // 2x2 = 1
View count_squares_in_matrix.php
<?php
/**
* Counts squares in matrix by loop.
*
* @param int $n
* @param int $m
* @return int
*/
function countSquares(int $m, int $n): int