Skip to content

Instantly share code, notes, and snippets.

@vanthao03596
vanthao03596 / Middleware-CSP.php
Created May 3, 2023 04:30 — forked from valorin/Middleware-CSP.php
CSP Middleware - the simple CSP middleware I use across all of my projects.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\Str;
/**
* Simple Content Security Policy middleware.
<div class="form-group">
<label>Banner lớn:</label>
<div class="row">
<div class="col-md-4">
<div class="card">
<div class="card-img-actions m-1">
<img class="card-img img-fluid" src="/global_assets/images/no-image.jpg" alt="" id="preview_banner">
<div class="card-img-actions-overlay card-img">
<a href="/global_assets/images/no-image.jpg" class="btn btn-outline-white border-2 btn-icon rounded-pill" data-popup="lightbox" data-gallery="gallery1">
<i class="icon-plus3"></i>
const qs = `itemid=${id}&shopid=${shopId}`;
const qsHash = crypto.createHash('md5').update(qs).digest('hex');
const none = crypto.createHash('md5').update(`55b03${qsHash}55b03`).digest('hex');
const data = await axios.get(`https://shopee.vn/api/v2/item/get?${qs}`, {
headers: { 'if-none-match-': `55b03-${none}` },
})
@vanthao03596
vanthao03596 / Money.php
Last active October 22, 2021 02:58
MoneyCast
<?php
namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
class Money implements CastsAttributes
{
/**
* @var string
<?php
namespace App\Models\Concerns;
trait SearchBuilder
{
public function scopeSearchBuilder($query)
{
if (request()->filled('searchBuilder') && request()->query('searchBuilder') !== 'false') {
$query->where(function ($query) {
const { userAgent } = window.navigator
export const isIos = /iPhone|iPad/.test(userAgent)
export const isAndroid = /Android/.test(userAgent)
export const isMobile = isIos || isAndroid
export const isMac = /Mac/.test(userAgent)
export const isDesktopSafari = !isMobile && /Safari/.test(userAgent)
export const isIosApp = /HEY iOS/.test(userAgent)
export const isAndroidApp = /Haystack Android/.test(userAgent)
@vanthao03596
vanthao03596 / editor.cleave.js
Created August 19, 2021 15:07
editor.cleave.js
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD
define(['jquery', 'datatables.net', 'datatables.net-editor'], factory);
}
else if (typeof exports === 'object') {
// Node / CommonJS
module.exports = function ($, dt) {
if (!$) { $ = require('jquery'); }
factory($, dt || $.fn.dataTable || require('datatables.net'));
@vanthao03596
vanthao03596 / InviteCode.php
Created March 25, 2021 08:10 — forked from guanguans/InviteCode.php
InviteCode.php
<?php
/**
* Class InviteCode
* 邀请码生成类
*
* ```
* $inviteCode = new InviteCode('123456789');
* var_dump($inviteCode->enCode(1)); // string(8) "00000002"
* var_dump($inviteCode->deCode("00000002")); // int(1)
@vanthao03596
vanthao03596 / Item.md
Last active February 19, 2021 09:39
OOP
<?php

namespace App;

class Item
{
    protected float $weight;
    protected float $width;
    protected float $height;
@vanthao03596
vanthao03596 / Laravel-Container.md
Created November 6, 2020 08:33
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Translations: Korean (by Yongwoo Lee)

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).