Skip to content

Instantly share code, notes, and snippets.

<?php
namespace App\Http\Requests\Traits;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Validation\ValidationException;
trait FailedValidationTrait
<?php
$json = json_decode(file_get_contents('php://input'));
if (isset($json->SubscribeURL)){
file_get_contents($json->SubscribeURL);
}
file_put_contents("./cron-" . time() . '.txt', json_encode($json));
@rodurma
rodurma / first_and_last_elem.js
Created October 29, 2019 01:48
Várias maneiras de pegar o primeiro e último elemento de um array com JavaScript
// considerando o array abaixo
const arr = [4, 7, 10, 82, 35];
// Opção 1: Pelo tamanho do array
let first = arr[0];
let last = arr[arr.length-1];
// Opção 2: Com shift(), pop() e Spread operator
let first = [...arr].shift();
let last = [...arr].pop();
@rodurma
rodurma / sort_players.js
Created October 29, 2019 02:12
Ordenando um array com sort
const players = [
{ name: 'Rodrigo', kills: 12 },
{ name: 'Vitor', kills: 9 },
{ name: 'Camila', kills: 17 },
{ name: 'Amanda', kills: 6 }
];
const orderAsc = (a, b) => a.kills - b.kills;
const orderDesc = (a, b) => b.kills - a.kills;
<?php
echo "Hello World";
version: '3.2'
services:
mysql:
image: mysql:8.0
container_name: mysql
hostname: mysql
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_DATABASE=opencart
- MYSQL_ROOT_PASSWORD=change_to_secure_password