Skip to content

Instantly share code, notes, and snippets.

@grandmanitou
grandmanitou / ZipStream.php
Created January 20, 2020 13:56
Create a zip file without keeping it on disk
$options = new \ZipStream\Option\Archive();
$options->setSendHttpHeaders(true);
$options->setDeflateLevel(9);
//$options->setEnableZip64(false);
$zip = new \ZipStream\ZipStream('fichiers.zip', $options);
foreach($clients as $client) {
$documentName = $client->getFirstMedia('document')->file_name;
$documentPath = str_replace(auth()->user()->email, $client->user_email, $client->getFirstMediaPath('document'));
$zip->addFileFromPath(Str::slug(trim($client->user_email), '-') . '/' . $documentName, $documentPath);
@grandmanitou
grandmanitou / map.blade.php
Created January 16, 2020 14:33
Locate user with mapbox
let geoTracker = new mapboxgl.GeolocateControl({
positionOptions: {
enableHighAccuracy: true
},
trackUserLocation: false,
showUserLocation: true,
});
geoTracker.on('geolocate', function (e) {
getGeoJson(e.coords.longitude, e.coords.latitude, 5);
@grandmanitou
grandmanitou / Export.php
Created December 17, 2019 15:52
Laravel Export Trait for Box/Spout
<?php
namespace App\Traits;
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
trait Export
{
public static function export($target, $items)
{
$writer = WriterEntityFactory::createXLSXWriter();
@grandmanitou
grandmanitou / Registration.php
Created December 15, 2019 23:48
Laravel Export Trait using Box/Spout
<?php
namespace App;
use App\Traits\Export;
use Illuminate\Database\Eloquent\Model;
class Registration extends Model
{
use Export;
@grandmanitou
grandmanitou / composer.json
Created November 26, 2019 17:33
My favorite composer package for a fresh Laravel 6.x install
"require": {
"php": "^7.2",
"bacon/bacon-qr-code": "^2.0",
"barryvdh/laravel-dompdf": "^0.8.5",
"box/spout": "^3.0",
"caouecs/laravel-lang": "^4.0",
"fideloper/proxy": "^4.0",
"fzaninotto/company-name-generator": "dev-master",
"giggsey/libphonenumber-for-php": "^8.10",
"guzzlehttp/guzzle": "^6.3",
@grandmanitou
grandmanitou / Https.php
Last active October 10, 2019 20:06
Laravel 6.x Https Middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Log;
class Https
{
/**
@grandmanitou
grandmanitou / _variables.scss
Last active May 19, 2022 18:01
Bootstrap 4 custom file input setup with laravel mix
$custom-file-text: (
en: "Browse",
es: "Elegir",
fr: "Parcourir"
);
@grandmanitou
grandmanitou / gist:9302f081781425898a484af67c9597fc
Last active September 28, 2019 11:55
Extend Faker with Laravel 5.x and 6.x
<?php
/** composer require fzaninotto/company-name-generator */
use App\Models\MyModel;
use Faker\Generator as Faker;
$factory->define(MyModel::class, function (Faker $faker) {
$faker->addProvider(new CompanyNameGenerator\FakerProvider($faker));
@grandmanitou
grandmanitou / MyModel.php
Created September 28, 2019 11:44
Uuid trait for laravel 5.x & 6.x models
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Traits\Uuid;
class MyModel extends Model
{
use Uuid;
@grandmanitou
grandmanitou / .zshrc
Last active September 26, 2019 21:29
# mac book pro
export PATH=$HOME/.composer/vendor/bin:$PATH
POWERLEVEL9K_MODE='nerdfont-complete'
source ~/powerlevel9k/powerlevel9k.zsh-theme
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh dir vcs newline status)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shel$