Skip to content

Instantly share code, notes, and snippets.

View thinkverse's full-sized avatar
🦖

Kim Hallberg thinkverse

🦖
View GitHub Profile
@valorin
valorin / Middleware-CSP.php
Last active June 28, 2024 21:16
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.
@Illizian
Illizian / DateTimeComponent.php
Last active September 28, 2021 14:05
Laravel localised DateTimes with UTC Database storage
<?php
namespace App\View\Components;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Carbon;
use Illuminate\View\Component;
class DateTime extends Component
{
@thinkverse
thinkverse / gallery.css
Last active June 8, 2021 02:59
Single-line images gallery with `array_*` functions and `scandir`.
@whitep4nth3r
whitep4nth3r / gist:e6b10ef17636e29010d7a8b57800685e
Created May 5, 2021 12:13
Delete all branches merged into main
// Add to your shell configuration to improve your life!
dam() {
git checkout main && git branch --merged | egrep -v "(^\*|main)" | xargs git branch -d
}
@lukeraymonddowning
lukeraymonddowning / Macro.php
Created March 26, 2021 09:36
Tailwind specificity helper for Laravel Blade
ComponentAttributeBag::macro('fallback', function($classes) {
$fallbacks = Collection::wrap($classes)
->mapWithKeys(fn($partial, $fallback) => is_int($fallback) ? [$partial => Str::of($partial)->before("-")->when(Str::contains("-", $partial), fn($string) => $string->append('-'))->__toString()] : [$fallback => $partial])
->toArray();
return $this->class($fallbacks);
});
@thinkverse
thinkverse / tailwind-v1.config.js
Last active July 12, 2023 12:12
Useful TailwindCSS config that saves paddings and margins upon build
// https://v1.tailwindcss.com/docs/controlling-file-size#purge-css-options
module.exports = {
future: {
removeDeprecatedGapUtilities: true,
purgeLayersByDefault: true,
},
purge: {
content: ['./public/**/*.html'],
options: {
whitelistPatterns: [
@5t3ph
5t3ph / element-classes-and-ids-vanilla.css
Last active January 25, 2022 04:06
Tag HTML elements with their class names and IDs to visualize page structure
*[class],
*[id] {
position: relative;
outline: 2px dashed red;
}
*[class]::before, *[class]::after,
*[id]::before,
*[id]::after {
position: absolute;
@ybiquitous
ybiquitous / skip-ci-on-actions.yml
Last active February 9, 2021 10:11
How to "[skip ci]" on GitHub Actions
# See also:
# - https://github.com/actions/runner/issues/774
# - https://help.github.com/en/actions/reference/events-that-trigger-workflows#push-event-push
# - https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request
# - https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions
name: "[skip ci]" on Actions
on: [push, pull_request]