Skip to content

Instantly share code, notes, and snippets.

View tegos's full-sized avatar
🐼

Ivan Mykhavko tegos

🐼
View GitHub Profile
@tegos
tegos / comparing-two-my-sql-queries-for-top-solution-authors.md
Created September 14, 2025 13:53
Comparing Two MySQL Queries for Top Solution Authors

Comparing Two MySQL Queries for Top Solution Authors

This summarizes two queries to get the top users by solutions count, their corrected forms, simulated execution plans, and recommendations. For this video: Laravel Performance: Careful with withCount() by Povilas Korop.

Query 1 – Subquery in SELECT

Corrected Query

@tegos
tegos / ForbiddenFunctionTest.php
Created March 16, 2025 12:30
Detecting Forbidden Functions in Laravel with PHPUnit
<?php
declare(strict_types=1);
namespace Tests\Unit\Architecture;
use Illuminate\Support\Facades\App;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RegexIterator;
@tegos
tegos / mysql-backup.sh
Last active July 15, 2022 07:40
Mysql backup bash script for production
#!/bin/bash
TODAY=`date +%d.%m.%Y`
TODAY_TIME=`date +%d.%m.%Y-%T`
DB_BACKUP_PATH='/backups/mysql-backups'
MYSQL_CONFIG_PATH='/backups/mysql.cnf'
DATABASE_NAME='asg'
DB_FILE=${DB_BACKUP_PATH}/${TODAY}/${DATABASE_NAME}-${TODAY_TIME}.sql
@tegos
tegos / getTiles.py
Created May 5, 2021 08:29 — forked from devdattaT/getTiles.py
Downloading of Slippy Tiles using Shapely.
import math
import os
import urllib
from shapely.geometry import Polygon
def deg2num(lat_deg, lon_deg, zoom):
lat_rad = math.radians(lat_deg)
n = 2.0 ** zoom
xtile = int((lon_deg + 180.0) / 360.0 * n)
ytile = int((1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n)
@tegos
tegos / Laravel-Container.md
Created August 4, 2020 05:03
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).