Skip to content

Instantly share code, notes, and snippets.

View shengslogar's full-sized avatar
👨‍💻
coding or whatever

Sheng Slogar shengslogar

👨‍💻
coding or whatever
View GitHub Profile
@shengslogar
shengslogar / 2024-01-22-today-i-learned-mysql-dates-are-dst-aware.md
Last active July 10, 2024 22:24
Today I Learned MySQL Dates Are DST-Aware

TIL MySQL is DST-aware and prevents storage of invalid times. This happened when running a database seeder on my local machine, time zone America/Chicago. A randomized date in 1983, 1983-04-24 02:22:57, caused the following error:

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '1983-04-24 02:22:57'

After some digging around, I realized 1983's Daylight Savings Time started on April 24th at 2 AM, where 2 AM would be skipped altogether, jumping to 3 AM. This meant any time zone-aware time between 2 and 3 AM was

@shengslogar
shengslogar / snappier-macos-dock.md
Created October 23, 2023 02:11
The only correct macOS dock settings.

On Catalina and upwards:

sudo pkill bluetoothd
@shengslogar
shengslogar / chrome-laravel-valet-macos-ssl.md
Last active November 4, 2022 06:17
Chrome not accepting Laravel Valet Self-Signed Cert on macOS Ventura

On this dark and bitter day, Friday, November 4th, 2022, Chrome randomly decided to start spitting out: NET::ERR_CERT_AUTHORITY_INVALID after almost two years of flawlessly running Laravel Valet with the same set of certs. Upgrading Valet, upgrading Homebrew dependencies, soft-reinstalling Chrome, soft-reinstalling Valet, deleting all certs from Keychain and re-adding them was to no avail.

Firefox and Safari continued to trust these certificates. Cached, perhaps?

In that process, I had deleted the "Laravel Valet CA Self Signed CN" certificate, and rerunning valet install and unsecuring/resecuring all sites didn't add this back, for some reason.

What DID work was going to ~/.config/valet/CA/, dragging LaravelValetCASelfSigned.pem into Keychain, and setting "When using this certificate" to "Always Trust". Not even a restart of Chrome was needed, and we're back in business.

See you back here in two years, apparently.

@shengslogar
shengslogar / laravel-symfony-composer-2-heroku.md
Last active January 6, 2022 18:36
01/06/2022 – Laravel/Symfony Build on Composer 2 on Heroku

Heroku Not Using Composer 2 with Laravel

January 6, 2022

Sample Error Log

-----> Building on the Heroku-20 stack
-----> Using buildpacks:
       1. heroku/php
       2. https://github.com/heroku/heroku-buildpack-cli
-----> PHP app detected

Issue with PHP-FPM inheriting system-level variables (specifically, PATH)

Running Notes

Environment: PHP 7.4, Homebrew, Laravel Valet, Apple Silicon

Problem

PHP-FPM can't resolve getenv('PATH') while PHP-CLI can.

This causes binaries to not be found when attempting to invoke directly from within a Laravel controller.

Sloppy Workaround

@shengslogar
shengslogar / php-unrecognized-compile-time-option.md
Created November 19, 2021 17:07
Uncaught ErrorException: preg_match_all(): Compilation failed: unrecognised compile-time option bit(s) at offset 0 in phar:///usr/local/bin/composer/vendor/symfony/console/Formatter/OutputFormatter.php:137

If you're getting the following error, chances are you need to upgrade libpcre2, because it's being held back for some reason (you should see this listed when you run sudo apt update, followed by upgrade).

PHP Fatal error:  Uncaught ErrorException: preg_match_all(): Compilation failed: unrecognised compile-time option bit(s) at offset 0 in phar:///usr/local/bin/composer/vendor/symfony/console/Formatter/OutputFormatter.php:137
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle()
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Formatter/OutputFormatter.php(137): preg_match_all()
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Output/Output.php(155): Symfony\Component\Console\Formatter\OutputFormatter->format()
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Output/Output.php(132): Symfony\Component\Console\Output\Output->write()
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(641): Symfony\Component\Console\Output\Output->writel
<?php 
 
use Barryvdh\Snappy\Facades\SnappyPdf as PDF;
killall -KILL NotificationCenter
killall -KILL SystemUIServer
killall -KILL Dock
killall -KILL Finder

Install Imagick on M1/Apple Silicon with Homebrew

If you're getting the following error after running pecl install imagick:

/opt/homebrew/Cellar/php@7.4/7.4.22/include/php/ext/pcre/php_pcre.h:25:10: fatal error: 'pcre2.h' file not found
#include "pcre2.h"
         ^~~~~~~~~
1 error generated.
make: *** [imagick.lo] Error 1