Skip to content

Instantly share code, notes, and snippets.

{{--
Icon view component for Laravel 7.
@disclaimer The icons used in this component are taken from "Refactoring UI Heroicons" (md-outline collection).
For more info https://github.com/refactoringui/heroicons by Steve Schoger & Adam Wathan.
@copyright MIT
@author Maurizio <https://twitter.com/mauriziolepora>
@leMaur
leMaur / Mailto.js
Last active November 30, 2023 13:25
Mailto spam-prevention
/**
* Prepare the mailto anchor tag from string or data attributes.
* Helpful to prevent spam.
*
* ==============================================
* HOW TO USE
* ==============================================
* inside an html document:
*
* Example with text :
@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)
@leMaur
leMaur / tailwind.responsive-font.js
Last active March 8, 2021 17:52
Responsive font-size for Tailwindcss
const plugin = require('tailwindcss/plugin')
module.exports = plugin(function ({ addBase, theme }) {
addBase({
':root': {
'--rf-min-fs': theme('responsive-font.min-fs'),
'--rf-max-fs': theme('responsive-font.max-fs'),
'--rf-min-vw': theme('responsive-font.min-vw'),
'--rf-max-vw': theme('responsive-font.max-vw'),
'--rf-min-fs-rem': 'var(--rf-min-fs) * 1rem',
function toggleable(id) {
return {
id: id,
show: false,
bodyNeedsOverflowHidden: false,
originalOverflow: '',
id() {
return id || `toggleable-${Math.random().toString(36).substr(2, 10)}`
},