Skip to content

Instantly share code, notes, and snippets.

View mattkomarnicki's full-sized avatar
🌶️

Matt Komarnicki mattkomarnicki

🌶️
View GitHub Profile
exiftool -XMP:GPSLatitude=1.288249 -XMP:GPSLongitude=103.851536 -P -overwrite_original A7304765.ARW
// Reload metadata in Capture One
// -overwrite_original will prevent from making extra copy of the target file
<?php
private function camelCaseToHuman(string $input): string
{
$result = preg_split('/(^[^A-Z]+|[A-Z][^A-Z]+)/', $input, -1, PREG_SPLIT_NO_EMPTY| PREG_SPLIT_DELIM_CAPTURE);
return ucfirst(implode(' ', $result));
}
SELECT YEAR(FROM_UNIXTIME(post_time)) as `year`, LPAD(MONTH(FROM_UNIXTIME(post_time)), 2, 0) as `month`, COUNT(post_id) as count FROM phpbb3_posts
GROUP BY `year`, `month`
ORDER BY `year`, `month` ASC
@mattkomarnicki
mattkomarnicki / format_number_in_k_notation.php
Last active June 28, 2019 04:49
Formats given integer into short version with a suffix. For example "1500" will become "1K+".
<?php
if (!function_exists('format_number_in_k_notation')) {
function format_number_in_k_notation(int $number): string
{
$suffixByNumber = function () use ($number) {
if ($number < 1000) {
return sprintf('%d', $number);
}
@mattkomarnicki
mattkomarnicki / Laravel-Container.md
Created June 4, 2018 04:29
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

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).

Accessing the Container