Skip to content

Instantly share code, notes, and snippets.

@leMaur
leMaur / Rating.vue
Last active February 13, 2017 10:21
[Vue.js] Rating Component
<template>
<div class="rating-wrapper">
<div class="rating">
<button v-for="n in 5"
type="button"
class="rating-element"
:disabled="read_only"
:class="[rating >= n ? '' : '--outlined']"
@click="setRating(n)">
</button>
@leMaur
leMaur / ValidateEmail.php
Last active August 16, 2019 06:44
Validate an email address by checking its syntax and if the given domain exists
<?php
if (function_exists(real_email)) {
/**
* Validate an email address by checking its syntax
* and if the given domain exists
*
* @param string $email The email address
* @return bool
@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 / LocalizeDatetime.php
Last active February 20, 2018 21:18
Middleware that extends Mcamara\Laravel-localization package functionalities. Set the locale LC_TIME for Carbon\Carbon to set the correctly datetime for each selected language. See comment for further details.
<?php
namespace App\Http\Middleware;
use Closure;
use Carbon\Carbon;
use Mcamara\LaravelLocalization\Middleware\LaravelLocalizationMiddlewareBase;
class LocalizeDatetime extends LaravelLocalizationMiddlewareBase
{
function logTimes(message) {
performance.mark(message); // this one is for WebPageTest
console.timeStamp(message); // this is for the Performance tab in Chrome DevTools
console.info(message, performance.now()); // this is for the console, duh
// this here is for Google Analytics
ga('send', {
hitType: 'timing',
timingCategory: 'Performance',
timingVar: message,
@leMaur
leMaur / API.md
Created September 19, 2017 12:58 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@leMaur
leMaur / app.blade.php
Created October 8, 2017 08:44
Laravel blade template
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>{{ config('app.name') }} - @yield('title')</title>
<meta name="description" content="" />
<meta name="HandheldFriendly" content="True" />
@leMaur
leMaur / ForceHttps.php
Created December 19, 2017 16:29
Laravel 5.5 Middleware to force using secure connection
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class ForceHttps
{
/**
@leMaur
leMaur / Editor.vue
Created March 20, 2018 13:30
Trix Editor for Vue.js
<template>
<div>
<input id="trix" type="hidden" :name="name" :value="value">
<trix-editor ref="trix" input="trix" :placeholder="placeholder"></trix-editor>
</div>
</template>
<script>
import Trix from 'trix';
@leMaur
leMaur / Benchmarkable.php
Created June 28, 2018 10:18
Save `Benchmarkable.php` in `app/Console`. Then use it in your Artisan Commands.
<?php
namespace App\Console;
/**
* Benchmark functionality for Artisan Command.
*
* @author Maurizio Lepora <maurizio.lepora@firstcaution.ch>
* @license MIT
*/