Skip to content

Instantly share code, notes, and snippets.

View gpfiel's full-sized avatar

Gabriel Pinheiro Fiel gpfiel

View GitHub Profile
@gpfiel
gpfiel / miamed.php
Created May 18, 2017 15:57
Miamed Refactor
<?php
namespace Com\Company\System;
use \Com\Company\Interfaces;
class VerifyHelper
{
/**
@gpfiel
gpfiel / Question3Toptal.php
Created April 20, 2016 21:05
Question3Toptal
<?php
function solution($A)
{
$sum = 0;
while (count($A)) {
// remove the last part
array_pop($A);
@gpfiel
gpfiel / Question1Toptal.php
Created April 20, 2016 20:50
Question1Toptal
<?php
function solution($K, $L, $M, $N, $P, $Q, $R, $S) {
//get inputs to check intersection
$leftSide = max($K, $P);
$rightSide = min($M, $R);
$bottomSide = max($L, $Q);
$topSide = min($N, $S);
//the area of the sum of the rectangles
$sum = (($M - $K) * ($N - $L)) + (($R - $P) * ($S - $Q));
<?php
function test($v, $arr1) {
$arr2 = [];
while(1){
$count1 = isset(array_count_values($arr1)[$v]) ? array_count_values($arr1)[$v] : 0;
$count2 = isset(array_count_values($arr2)[$v]) ? array_count_values($arr2)[$v] : 0;
if(count($arr1) == 0 || $count1 == count($arr2) - $count2) {
return count($arr1);
}
$arr2[] = array_shift($arr1);
<?php
function solution($X, $A) {
foreach ($A as $key => $value) {
$part1 = array_slice($A, 0, $key);
$part2 = array_slice($A, $key, count($A) - 1);
$arrayPart1Indexes = array();
$arrayPart2Indexes = array();
foreach ($part1 as $part1key => $part1Value) {
<?php
$dataArray = array('nome_vendedor' => $this->proposta->vendedor->nome,
'nome_comprador' => $this->proposta->comprador->nome,
'proposta' => $this->proposta->mensagem,
'mensagem' => $request->input("resposta"),
'linkAnuncio' => url('anuncio/'.$this->proposta->anuncio->slug));
$email_comprador = $this->proposta->comprador->email;
Mail::send('email.responderProposta', $dataArray, function ($m) use ($email_comprador) {
$dataArray = array('nome_vendedor' => $this->proposta->vendedor->nome,
'nome_comprador' => $this->proposta->comprador->nome,
'proposta' => $this->proposta->mensagem,
'mensagem' => $request->input("resposta"),
'linkAnuncio' => url('anuncio/'.$this->proposta->anuncio->slug));
$email_comprador = $this->proposta->comprador->email;
Mail::send('email.responderProposta', $dataArray, function ($m) use ($email_comprador) {
$m->from('bidcarros@bidcarros.com', 'BidCarros Portal');
@gpfiel
gpfiel / ContaFornecedor.php
Created April 3, 2014 14:18
ContaFonecedor.php
<?php
/**
* @author Gabriel P. Fiel <comercial@toolsystems.com.br>
*/
namespace Application\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Application\Interfaces\SoftDeleteInterface;
<?php
/**
* Persistir o objeto da mensagem, verifica se irá alterar ou cadastrar
* @param EntityManager $em
* @param Resposta &$objResposta
* @return Array Dados necessários para o registro do log
*/
public function persistir(EntityManager $em, Resposta &$objResposta)
{
<?php
namespace Admin\Form;
use Zend\Form\Form;
use Zend\InputFilter\InputFilterProviderInterface;
class GaleriaForm extends Form implements InputFilterProviderInterface
{
public function init()
{