Skip to content

Instantly share code, notes, and snippets.

View sebastiaanluca's full-sized avatar
👋

Sebastiaan Luca sebastiaanluca

👋
View GitHub Profile
@freekmurze
freekmurze / validate.md
Last active February 15, 2018 17:29
A handy validate function for Laravel 5
/**
 * Validate some data.
 *
 * @param string|array $fields
 * @param string|array $rules
 * @return bool
 */
function validate($fields, $rules)
{
@martinbean
martinbean / pre-commit
Last active December 19, 2023 22:14
Pre-commit hook to detect if any .php files contain dd()
#!/usr/bin/php
<?php
$files = shell_exec('git diff-index --name-only --cached --diff-filter=ACMR HEAD | grep "\.php$"');
$files = explode("\n", trim($files));
$exitCode = 0;
foreach ($files as $file) {
if (empty($file)) {
@sgpopov
sgpopov / ruleset.xml
Last active July 15, 2019 10:07
PHP Code Sniffer Rules
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="MentorMate">
<description>
The coding standard of the MentorMate team, based on the Generic, PSR2,
Squiz and Zend coding standards.
</description>
<arg name="colors"/>
<ini name="memory_limit" value="128M"/>
@ivanvermeyen
ivanvermeyen / !NOTE.md
Last active March 15, 2023 05:25
Setup a Laravel Storage driver with Google Drive API
@themsaid
themsaid / pagination.blade.php
Created April 21, 2017 12:57
Pagination view for UIkit
@if ($paginator->hasPages())
<ul class="uk-pagination">
@if ($paginator->onFirstPage())
<li class="uk-disabled"><a href="#"><span uk-pagination-previous></span></a></li>
@else
<li><a href="{{ $paginator->previousPageUrl() }}"><span uk-pagination-previous></span></a></li>
@endif
{{-- Pagination Elements --}}
@foreach ($elements as $element)
@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(),
@adamwathan
adamwathan / 1-add-macros.php
Last active June 11, 2022 19:55
Multiformat Endpoints in Laravel
<?php
namespace App\Providers;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use Illuminate\Support\ServiceProvider;
use App\Http\Middleware\CaptureRequestExtension;
class AppServiceProvider extends ServiceProvider
@vernalkick
vernalkick / ember_exporter.rb
Last active September 30, 2021 20:20
Ember Exporter
#!/usr/bin/env ruby
# Input arguments
source_path = ARGV[0]
destinationPath = ARGV[1] || '~/Desktop/ember_backup'
# Creade destination directory if it doesn't exist
`mkdir -p #{destinationPath}`
# Find the embersnaps in the directory and count them
@HerrBertling
HerrBertling / cssnext-preset-env.md
Last active January 23, 2022 17:35
CSSNext to postcss-preset-env

My team found it rather hard to determine which stage to use – or whether it would be easier to stay with a certain stage and enable some features specifically.

So I ended up with a table of postcss-cssnext features, their postcss-preset-env counterparts (where I knew the option name) and the stage for each feature.

Here you go:

@troatie
troatie / CreatesWithLock.php
Last active September 12, 2023 13:51
Guard against race conditions in Laravel's firstOrCreate and updateOrCreate
trait CreatesWithLock
{
public static function updateOrCreate(array $attributes, array $values = [])
{
return static::advisoryLock(function () use ($attributes, $values) {
// emulate the code found in Illuminate\Database\Eloquent\Builder
return (new static)->newQuery()->updateOrCreate($attributes, $values);
});
}