Skip to content

Instantly share code, notes, and snippets.

View IvanGavrikov's full-sized avatar

Ivan.Gavrikov IvanGavrikov

View GitHub Profile
@IvanGavrikov
IvanGavrikov / \App\Providers\AppServiceProvider.php
Created January 4, 2023 10:32
Database query logging for Laravel
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
DB::listen(static function ($query) {
$locations = collect(debug_backtrace())
->reject(static fn($trace) => empty($trace['file'] ?? null))
@IvanGavrikov
IvanGavrikov / regexp.txt
Last active March 17, 2021 19:30
Регулярки
1. Выделения окончания ссылки.
Регулярка: /(?!\/)([^\/]+)$/
Пример: https://acuvue.testpromo.site/preview/8f34f792-6e9f-4334-8b28-e850da3f7cd2
Результат: 8f34f792-6e9f-4334-8b28-e850da3f7cd2
2. Извлечение имени файла
Регулярка: /(?<filename>^.*)(?<extension>\.[^\.]+)$/
Пример: "Screenshot from 2021-03-14. 09-00-01.png"
Результат:
filename: "Screenshot from 2021-03-14. 09-00-01"
Проблема:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 67108872 bytes) in /var/www/vendor/khanamiryan/qrcode-detector-decoder/lib/GDLuminanceSource.php on line 79
Решение:
https://github.com/khanamiryan/php-qrcode-detector-decoder/pull/76
только при значении 100 код не распознается, начинает распознаваться от 600. В докер образе без ошибки максимально 700.
lib/QrReader.php
@@ -58,13 +58,15 @@ public function __construct($imgSource, $sourceType = QrReader::SOURCE_TYPE_FILE
docker rm $(docker ps -aq)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -q)
@IvanGavrikov
IvanGavrikov / ubuntu_remove_snaps
Last active June 3, 2020 13:00
How to remove old snap versions to free up disk space
Remove old version of installed snaps
snap list --all | while read snapname ver rev trk pub notes; do if [[ $notes = *disabled* ]]; then sudo snap remove "$snapname" --revision="$rev"; fi; done
Starting from snap 2.34 and later, you can set the maximum number of a snap’s revisions stored by the system by setting the refresh.retain option.
sudo snap set system refresh.retain=2
The refresh.retain value can only be a number between 2 and 20 and has a default value of 3.
@IvanGavrikov
IvanGavrikov / ubuntu_18.04lts_touchpad_right
Last active March 10, 2020 19:17
После обновления до Ubuntu 18.04 lts вторая (правая) кнопка в тачпаде работает как основная (левая).
После обновления до Ubuntu 18.04 lts вторая (правая) кнопка в тачпаде работает как основная (левая).
gsettings set org.gnome.desktop.peripherals.touchpad click-method 'areas'
@IvanGavrikov
IvanGavrikov / array_filter_key.php
Created December 11, 2019 18:48 — forked from h4cc/array_filter_key.php
Filtering a PHP array by key instead of value.
<?php
/**
* Filtering a array by its keys using a callback.
*
* @param $array array The array to filter
* @param $callback Callback The filter callback, that will get the key as first argument.
*
* @return array The remaining key => value combinations from $array.
*/
@IvanGavrikov
IvanGavrikov / phpunit
Created July 19, 2019 20:59
phpunit private and protected methods
<?php
namespace tests;
use main\User;
class UserTest extends \PHPUnit_Framework_TestCase{
/**
* Выполнение защищенного/частного метода класса.
*
* @param object &$object Объект тестируемого класса
* @param string $methodName Вызываемое имя метода
* @param array $parameters Массив параметров (аргументов) метода.
The open source video transcoder https://handbrake.fr/downloads.php
https://confluence.atlassian.com/confkb/unable-to-play-embedded-mp4-videos-on-ipad-or-iphone-in-confluence-305037325.html
Formats http://www.bigasoft.com/articles/how-to-play-mp4-on-ipad.html
One important thing to note is that "iDevices" doesn't support all the varieties of mp4. Here is a small list about MPEG-4 and H.264 supported varieties.
According to Apple official website, iPad or iPhone 4S is only compatible with H.264 or MPEG-4 video format with the following specifications:
If it is H.264 video, it should meet: up to 1080p, 30 frames per second, High Profile level 4.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats;
If it is MPEG-4 video, it should meet: up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats;