Skip to content

Instantly share code, notes, and snippets.

Avatar

Madalin Tache niladam

View GitHub Profile
@niladam
niladam / error_blade_directive.php
Created Mar 29, 2019 — forked from calebporzio/error_blade_directive.php
A little Blade directive to make working with validation errors a bit nicer.
View error_blade_directive.php
<?php
// Usage:
// Before
@if ($errors->has('email'))
<span>{{ $errors->first('email') }}</span>
@endif
// After:
@niladam
niladam / webpack.mix.js
Created Mar 2, 2019 — forked from calebporzio/webpack.mix.js
A webpack.mix.js file for writing NPM packages the way you write JS in a Laravel app.
View webpack.mix.js
let mix = require('laravel-mix');
mix.js('src/index.js', 'dist/foo.js').sourceMaps();
mix.webpackConfig({
output: {
libraryTarget: 'umd',
}
})
@niladam
niladam / shoot-sharing-image.js
Created Jan 4, 2019 — forked from drewm/shoot-sharing-image.js
Dynamic Social Sharing Images
View shoot-sharing-image.js
const puppeteer = require('puppeteer');
const imagemin = require('imagemin');
const imageminPngquant = require('imagemin-pngquant');
// Get the URL and the slug segment from it
const url = process.argv[2];
const segments = url.split('/');
const slug = segments[segments.length-2];
(async () => {
View nova-hot-reloading.php
<?php
class FieldServiceProvider extends ServiceProvider{
/**
* Bootstrap the field services.
* @return void
*/
public function boot()
{
Nova::serving(function (ServingNova $event) {
$files = app('files');
View gist:cb7b4102c6bf0ad077d558055ba24b30
<?php
require __DIR__ . '/vendor/autoload.php';
use GuzzleHttp\Client;
$url = "https://domain.tld/large-file.mp4";
$tmpFile = tempnam(sys_get_temp_dir(), 'guzzle-download');
$client = new Client(array(
View intervention-image-placeholder.php
<?php
//Intervention Image Package:
//http://image.intervention.io
Route::get('generate', function(){
$text = 'image/jpg';
$width = 1600;
$height = 1000;
$centerH = $width/2;
View BladeMinifyCompiler.php
<?php
//Notes: Special Thanks to OleMartinOrg (https://stackoverflow.com/users/2677898/olemartinorg)
//StackOverflow Source: https://stackoverflow.com/questions/5312349/minifying-final-html-output-using-regular-expressions-with-codeigniter.
//Usage: Place code below in new ViewServiceProvider that's registered after the Laravel version:
//$this->app->singleton('blade.compiler', function () {
// return new HtmlMinifyCompiler($this->app['files'], $this->app['config']['view.compiled']);
//});
//$this->app['view']->getEngineResolver()->register('blade', function () {
// return new CompilerEngine($this->app['blade.compiler']);
View safari-ripper.html
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {
background: repeat url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/7QCIUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAGscAVoAAxslRxwCAAACAAAcAnQAV8KpIENoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbGQgLSBodHRwOi8vd3d3LnJlZGJ1YmJsZS5jb20vcGVvcGxlL0NoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFjcHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAAABRnWFlaAAACLAAAABRiWFlaAAACQAAAABRkbW5kAAACVAAAAHBkbWRkAAACxAAAAIh2dWVkAAADTAAAAIZ2aWV3AAAD1AAAACRsdW1pAAAD+AAAABRtZWFzAAAEDAAAACR0ZWNoAAAEMAAAAAxyVFJDAAAEPAAACAxnVFJDAAAEPAAACAxiVFJDAAAEPAAACAx0ZXh0AAAAAENvcHlyaWdodCAoYykgMTk5OCBIZXdsZXR0LVBhY2thcmQgQ29tcGFueQAAZGVzYwAAAAAAAAASc1JHQiBJRUM2MTk2Ni0yLjEAAAAAAAAAAAAAABJzUkdCIElFQzYxOTY2LTIuMQAAAAAAAA
@niladam
niladam / nginx.conf
Created Aug 18, 2018 — forked from lkmadushan/nginx.conf
NGINX configuration for multi-tenant PHP application
View nginx.conf
map $http_accept $api_version {
default 0;
"application/vnd.example.v1+json" 1;
}
server {
listen 80;
listen [::]:80;