Skip to content

Instantly share code, notes, and snippets.

View geekcom's full-sized avatar
🏴
Time to code...

Daniel Rodrigues geekcom

🏴
Time to code...
View GitHub Profile
<?php
$array = ['nome 1', 'nome 2', 'nome 3'];
$iter = new ArrayIterator($array);
foreach ($iter as $key => $value){
echo $key . ' - ' . $value . PHP_EOL;
}
<?php
namespace App\Controllers;
use A;
use B;
class Control
{
@geekcom
geekcom / ExampleA.php
Last active May 8, 2018 13:27
Example A
<?php
namespace App\Controllers;
use A;
use B;
class Control
{
@geekcom
geekcom / fibonacci.php
Created May 8, 2018 12:18
SPL FibonacciIterator exemplo
<?php
class FibonacciIterator implements Iterator {
protected $_previous;
protected $_current;
protected $_key;
public function rewind() {
$this->_previous = 1;
$this->_current = 0;
@geekcom
geekcom / iteratorAlfabeto.php
Created May 8, 2018 12:08
Spl iterator example
<?php
class Alfabeto implements Iterator
{
protected $_current;
protected $_key;
public function rewind()
{
@geekcom
geekcom / priorityQueue.php
Last active May 7, 2018 12:58
Ordering data by priority
<?php
$priorityQueue = new SplPriorityQueue();
$priorityQueue->insert('Person 235', 3);
$priorityQueue->insert('Person 32', 99);
$priorityQueue->insert('Person 789', 1);
$priorityQueue->insert('Person 19', -2);
$priorityQueue->insert('Person 359', 0);
while (!$priorityQueue->isEmpty()) {
@geekcom
geekcom / token.php
Last active March 29, 2018 17:50
token exception
<?php
use Tymon\JWTAuth\Exceptions\JWTException;
use Tymon\JWTAuth\Exceptions\TokenExpiredException;
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
public function validarToken($request)
{
$token = $request->input('token');
@geekcom
geekcom / comandos-docker
Created March 20, 2018 18:04 — forked from danilodorgam/comandos-docker
Comandos do Docker
Segue a lista de comandos docker e sua utilidade:
docker attach – Acessar dentro do container e trabalhar a partir dele.
docker build – A partir de instruções de um arquivo Dockerfile eu possa criar uma imagem.
docker commit – Cria uma imagem a partir de um container.
docker cp – Copia arquivos ou diretórios do container para o host.
docker create – Cria um novo container.
docker diff – Exibe as alterações feitas no filesystem do container.
docker events – Exibe os eventos do container em tempo real.
docker exec – Executa uma instrução dentro do container que está rodando sem precisar atachar nele.
@geekcom
geekcom / getQueryLog.php
Last active February 20, 2018 16:40
Retorno do método getQueryLog()
array:3 [
0 => array:3 [
"query" => "select * from "workout_plan" where "fk_user" = ?"
"bindings" => array:1 [
0 => "1"
]
"time" => 4.57
]
1 => array:3 [
"query" => "select * from "user" where "user"."id" in (?)"
@geekcom
geekcom / getQueryLog.php
Last active May 7, 2018 12:42
getQueryLog()
<?php
namespace API\Repositories;
use API\Repositories\Contracts\WorkoutPlanRepositoryInterface;
use API\WorkoutPlan;
use Illuminate\Support\Facades\Validator;
use DB;
final class WorkoutPlanRepository extends BaseRepository implements WorkoutPlanRepositoryInterface