Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Vagner Luz do Carmo vluzrmos

🎯
Focusing
Block or report user

Report or block vluzrmos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vluzrmos
vluzrmos / docker-compose.yml
Created Aug 2, 2019
Docker-compose replace command
View docker-compose.yml
# ...
services:
# ...
service-name:
# ...
command: >
bash -c "
php artisan cache:clear &&
php artisan config:clear &&
@vluzrmos
vluzrmos / remote-ssh-write.sh
Created May 8, 2019
Write into a SSH Remote File
View remote-ssh-write.sh
#!/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
@vluzrmos
vluzrmos / hyperv-ubuntu.sh
Last active Jun 20, 2019
Hyper-V and Ubuntu integration tools.
View hyperv-ubuntu.sh
#!/bin/bash
# Integração Ubuntu 18.04.2 + Hyper V
sudo apt-get update -y && sudo apt-get install -y \
linux-cloud-tools-common \
linux-tools-generic \
linux-cloud-tools-generic
@vluzrmos
vluzrmos / apt-install.sh
Last active May 1, 2019
WSL Ubuntu Configuration. (Microsoft Windows Subsystem For Linux)
View apt-install.sh
#!/bin/bash
## It will install apache2, php, mysql and another stuffs.
# Note: Should run this scripts as root or sudoer
# [MYSQL]
# Note: If you want to connect with root user from WSL Host (from windows)
# you should replace mysql password plugin method from "auth_socket" to "mysql_native_password".
# @see https://stackoverflow.com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost/42742610#42742610
#
@vluzrmos
vluzrmos / guzzle_v6_resolve_http_redirection.php
Last active Sep 26, 2018
PHP URL Resolve HTTP Redirection Recursively
View guzzle_v6_resolve_http_redirection.php
<?php
/*
* Resolver using Guzzle
*/
if (!function_exists('resolve_http_redirection')) {
/**
* @param string $url
* @param int $limit
* @return mixed
@vluzrmos
vluzrmos / phpstorm.cmder.md
Last active Jul 4, 2019
Configurar o Laragon CMDER dentro do PHPSTORM
View phpstorm.cmder.md

1- Adicionar a variável de ambiente CMDER_ROOT com o caminho para C:\laragon\bin\cmder (local do cmder no computador)

2- Abrir o phpstorm, ir em File (Menu) > Settings > Tools > Terminal e alterar o caminho padrão "cmd.exe" para:

"cmd.exe" /k ""%CMDER_ROOT%\vendor\init.bat""

3- Pode acontecer de a variável CMDER_ROOT não estar pronta, você pode precisar reiniciar sua máquina.

@vluzrmos
vluzrmos / HasWithCountScope.php
Last active Aug 17, 2019
Laravel 5.1 withCount(relation) method.
View HasWithCountScope.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOneOrMany;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Database\Query\Expression;
@vluzrmos
vluzrmos / unnacent.php
Created Jul 11, 2017
PHP-Unnacent.php
View 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 / paginate.php
Created Jul 20, 2016
Laravel Paginate Collection or Array
View paginate.php
<?php
/**
* Gera a paginação dos itens de um array ou collection.
*
* @param array|Collection $items
* @param int $perPage
* @param int $page
* @param array $options
*
* @return LengthAwarePaginator
@vluzrmos
vluzrmos / Laravel_Response_Streamed.php
Created May 11, 2016 — forked from langemike/streamed.php
Laravel response macro for streamed responses with seeking support (with bug fixes & usage example)
View Laravel_Response_Streamed.php
<?php
Response::macro('streamed', function($type, $size, $name, $callback) {
$start = 0;
$length = $size;
$status = 200;
$headers = [
'Content-Type' => $type,
'Content-Length' => $size,
You can’t perform that action at this time.