Skip to content

Instantly share code, notes, and snippets.

@danielstgt
danielstgt / README.md
Last active November 29, 2021 13:30
Tailwind CSS JavaScript Modifier/Variant

Usage

Use a js or no-js variant depending on the availability of JavaScript, e.g. no-js:hidden or js:bg-blue-500.

Tailwind CSS Config

const plugin = require('tailwindcss/plugin');

module.exports = {
@danielstgt
danielstgt / .env
Last active October 29, 2021 14:10
Create a debug only alias for console.log
MIX_JS_DEBUG="${APP_DEBUG}"
@danielstgt
danielstgt / axios-interceptor.js
Last active August 18, 2020 19:13
axios interceptor for expired sessions with SweetAlert
axios.interceptors.response.use(response => {
return response;
}, error => {
if (error.response.status === 401) {
Swal.fire({
title: 'Session expired',
text: 'Please sign in again!',
type: 'error',
}).then(result => {
if (result.value) {
@danielstgt
danielstgt / FormattedDate.php
Created May 13, 2020 14:13
Eloquent DateTime Formatted Trait (Example for Germany)
<?php
namespace App\Traits;
trait FormattedDate
{
public function initializeFormattedDate()
{
$this->append('formatted_created_at');
$this->append('formatted_created_at_date');
@danielstgt
danielstgt / ie-detect.js
Created January 7, 2019 19:09
Detect Internet Explorer
function isIE() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf('MSIE ');
var trident = ua.indexOf('Trident/');
return (msie > 0 || trident > 0);
}
if (isIE()) {
document.getElementById('ie-notice').style.display = 'block';