Skip to content

Instantly share code, notes, and snippets.

View reinink's full-sized avatar

Jonathan Reinink reinink

View GitHub Profile
@reinink
reinink / nginx_cache_busting.conf
Last active February 16, 2022 03:12
Nginx Filename Based Cache Busting
location ~* '\.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|mp4|ogg|ogv|webm|htc|css|js|ttf|ttc|otf|eot|woff)$'
{
expires 1y;
add_header Cache-Control "public";
add_header "Cache-Control" "no-transform";
location ~* '(.+)\.(?:\d+)\.(js|css|png|jpg|jpeg|gif)$'
{
try_files $uri $1.$2;
}
<?php
use PHPUnit\Framework\Assert;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Testing\TestResponse;
TestResponse::macro('data', function ($key) {
return $this->original->getData()[$key];
});
<?php
use getID3;
$id3 = (new getID3())->analyze(Request::file('file')->getPathname());
$duration = isset($id3['playtime_string']) ? str_pad($id3['playtime_string'], 8, '00:00:00', STR_PAD_LEFT) : null;
<template>
<inertia-head>
<title v-if="title">{{ title }} - My App</title>
<title v-else>My App</title>
<slot />
</inertia-head>
</template>
<script>
export default {
@reinink
reinink / webpack.mix.js
Created November 20, 2017 13:19
Using Purgecss with Tailwind and Laravel Mix
let cssImport = require('postcss-import')
let cssNext = require('postcss-cssnext')
let glob = require('glob-all')
let mix = require('laravel-mix')
let purgeCss = require('purgecss-webpack-plugin')
let tailwind = require('tailwindcss')
mix.js('resources/assets/js/app.js', 'public/js')
.postCss('resources/assets/css/app.css', 'public/css/app.css', [
cssImport(),

Laravel Developer - Interview Exercise

  • Setup a fresh Laravel 5.8 application.
  • Use Tailwind CSS as the CSS framework.
    • CDN version is fine.
    • Bonus points if installed via NPM.
  • Create a new contact page at /contact.
  • Create a contact form on the page.
  • The form should be built as a Vue component.
  • The form should submit via ajax.

Setup PHP Code Sniffer in Sublime Text

The PHP Code Sniffer helps identity violations again coding standards (ie. PSR) as well as syntax errors in your code. The following tutorial explains how to setup the PHP Code Sniffer in Sublime Text (on OSX). This has been tested in Sublime Text 2 and Sublime Text 3.

1. Install PHP_CodeSniffer

Using Pear

You can use Pear, but that's just confusing, and requires you to have Pear installed. Move on to the next option.

@reinink
reinink / Model.php
Created April 20, 2021 18:55
Laravel - Recently Created
<?php
namespace App\Models;
use Illuminate\Support\Facades\Session;
use Illuminate\Database\Eloquent\Model as Eloquent;
abstract class Model extends Eloquent
{
protected $guarded = [];
@reinink
reinink / php-headers.php
Created April 27, 2012 00:36
PHP header examples
<?php
// Source: http://www.jonasjohn.de/snippets/php/headers.htm
// Use this header instruction to fix 404 headers
// produced by url rewriting...
header('HTTP/1.1 200 OK');
// Page was not found:
header('HTTP/1.1 404 Not Found');
@reinink
reinink / toggle.md
Last active March 12, 2021 14:53
Toggle.md
// Option 1: Manually
this.$inertia.post(`/toggle-thing/${this.user.id}`, {}, { preserveScroll: true })
<!-- Option 2: Inertia Link -->
<inertia-link :href="`/toggle-thing/${user.id}`" preserve-scroll>Toggle</inertia-link>