Skip to content

Instantly share code, notes, and snippets.

@leMaur
leMaur / phpstan.neon
Created April 6, 2025 14:24
Larastan
includes:
- vendor/larastan/larastan/extension.neon
# - vendor/nesbot/carbon/extension.neon
parameters:
level: 5
paths:
- app
- bootstrap
@leMaur
leMaur / pint.json
Last active April 6, 2025 14:23
Laravel Pint
{
"preset": "laravel",
"rules": {
"backtick_to_shell_exec": true,
"declare_strict_types": true,
"final_class": true,
"final_internal_class": true,
"final_public_method_for_abstract_class": true,
"fully_qualified_strict_types": true,
"function_typehint_space": true,
@leMaur
leMaur / convert_utf8_email_address.php
Last active February 13, 2025 10:13
Convert UTF8 Email Address
if (!function_exists('convert_utf8_email_address')) {
/**
* To maintain compatibility with older systems, Amazon SES honors the 7-bit ASCII limitation
* of SMTP as defined in RFC 2821. If you want to send content that contains non-ASCII
* characters, you must encode those characters into a format that uses
* 7-bit ASCII characters.
*
* @see https://docs.aws.amazon.com/ses/latest/dg/send-email-raw.html#send-email-mime-encoding-addresses
*/
function convert_utf8_email_address(string $emailAddress): string {
@leMaur
leMaur / KeyedSession.php
Created July 18, 2023 09:32 — forked from juampi92/KeyedSession.php
KeyedSession
<?php
namespace App\Support;
use Illuminate\Session\Store;
use RuntimeException;
/**
* Helper class that transforms all sessions into a specific key.
*
<?php
function memoize($target) {
static $memo = new WeakMap;
return new class ($target, $memo) {
function __construct(
protected $target,
protected &$memo,
) {}
const passwordInput = document.getElementById('password');
passwordInput.addEventListener('keyup', function (event) {
if (event.getModifierState('CapsLock')) {
// CapsLock is open
}
});
<IfModule mod_headers.c>
<IfModule mod_rewrite.c>
# Turn on the rewrite engine (this is necessary in order for
# the `RewriteRule` directives to work).
#
# https://httpd.apache.org/docs/current/mod/core.html#options
RewriteEngine On
@props(['key' => null])
@if((bool) $key)
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={{ $key }}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
@endif
<?php
namespace {{ factoryNamespace }};
use Illuminate\Database\Eloquent\Factories\Factory;
use {{ namespacedModel }};
/**
* @method {{ model }}|\Illuminate\Support\Collection<{{ model }}> create($attributes = [], ?Model $parent = null)
* @method \Illuminate\Support\Collection<{{ model }}> createMany(iterable $records)
function toggleable(id) {
return {
id: id,
show: false,
bodyNeedsOverflowHidden: false,
originalOverflow: '',
id() {
return id || `toggleable-${Math.random().toString(36).substr(2, 10)}`
},