Skip to content

Instantly share code, notes, and snippets.

View vluzrmos's full-sized avatar
🏠
Working from home

Vagner Luz do Carmo vluzrmos

🏠
Working from home
View GitHub Profile
@vluzrmos
vluzrmos / DatabaseSeeder.php
Last active April 19, 2017 13:08
Laravel - Seeding 100k many rows at 1s
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use App\User;
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
@vluzrmos
vluzrmos / unnacent.php
Created July 11, 2017 18:33
PHP-Unnacent.php
<?php
function to_ascii($str, $removeUnsupported = true)
{
foreach (ascii_chars() as $key => $value) {
$str = str_replace($value, $key, $str);
}
if ($removeUnsupported) {
$str = preg_replace('/[^\x20-\x7E]/u', '', $str);
@vluzrmos
vluzrmos / .htaccess
Last active September 21, 2017 22:45 — forked from dr-dimitru/.htaccess
Laravel 4.2 HTACCESS
# ----------------------------------------------------------------------
# /PUBLIC folder .htaccess
# ----------------------------------------------------------------------
# This .htaccess file is recommended
# to be placed at root/public folder
# of your Laravel powered application
# ----------------------------------------------------------------------
# This file works with Laravel 3 and 4
# ----------------------------------------------------------------------
# Turning on the rewrite engine is necessary for the following rules and
@vluzrmos
vluzrmos / guzzle_v6_resolve_http_redirection.php
Last active September 26, 2018 17:28
PHP URL Resolve HTTP Redirection Recursively
<?php
/*
* Resolver using Guzzle
*/
if (!function_exists('resolve_http_redirection')) {
/**
* @param string $url
* @param int $limit
* @return mixed
@vluzrmos
vluzrmos / Post.php
Created August 6, 2015 01:37
Example how to remove the eager loading on Eloquent.
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
/**
* Array of relationships to load.
@vluzrmos
vluzrmos / multipart.php
Created April 30, 2020 19:54
PHP Multipart array to Guzzle Client or other ...
<?php
/**
* Turns associative arrays into multipart [['name' => 'key[0][deep]', 'contents' => 'value']]
*/
function array_multipart(array $data = [])
{
$dots = array_dot($data);
$multipart = [];
@vluzrmos
vluzrmos / principais_packages.md
Last active June 17, 2020 21:48
Lista dos principais packages para Laravel citados no 16º Hangout Laravel Brasil.
@vluzrmos
vluzrmos / Laravel_Response_Streamed.php
Created May 11, 2016 18:05 — forked from langemike/streamed.php
Laravel response macro for streamed responses with seeking support (with bug fixes & usage example)
<?php
Response::macro('streamed', function($type, $size, $name, $callback) {
$start = 0;
$length = $size;
$status = 200;
$headers = [
'Content-Type' => $type,
'Content-Length' => $size,
@vluzrmos
vluzrmos / docker-compose.yml
Created August 2, 2019 14:08
Docker-compose replace command
# ...
services:
# ...
service-name:
# ...
command: >
bash -c "
php artisan cache:clear &&
php artisan config:clear &&
@vluzrmos
vluzrmos / remote-ssh-write.sh
Created May 8, 2019 12:16
Write into a SSH Remote File
#!/bin/bash
echo 'Some Text' | ssh user@remotehost -T "cat > /remotefile.txt"
# The -T disables pseudo-terminal allocation and stops you from getting the message,
# Pseudo-terminal will not be allocated because stdin is not a terminal.
# @see https://superuser.com/a/400720/341320