Skip to content

Instantly share code, notes, and snippets.

View adrianalonso's full-sized avatar

Adrián Alonso Vega adrianalonso

View GitHub Profile
@adrianalonso
adrianalonso / index.html
Created May 19, 2021 18:17
Piedra Papel Tijera
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link href="style.css" rel="stylesheet" />
</head>
<body>
@adrianalonso
adrianalonso / PromotionProcessor.php
Created December 6, 2020 19:26
Sylius PromotionProcessor
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@adrianalonso
adrianalonso / pipedream-circleci.js
Created May 24, 2020 06:28
Pipedream Function to Trigger Build on CircleCI
async (event, steps) => {
const CircleCI = require("circleci-api");
const options = {
token: process.env.CIRCLECI_TOKEN,
vcs: {
type: process.env.CIRCLECI_REPOSITORY_PLATFORM,
owner: process.env.CIRCLECI_OWNER,
repo: process.env.CIRCLECI_REPOSITORY,
},
<?php
namespace AppBundle\Form\Type\SearchFilters;
use AppBundle\Entity\Category;
use AppBundle\Entity\Product;
use AppBundle\Entity\Specialty;
use AppBundle\Entity\SubCategory;
use AppBundle\Entity\User;
use AppBundle\Entity\Venue;
@adrianalonso
adrianalonso / pagination_promise_chain.js
Created January 6, 2019 11:58
Pagination Promise Chain
function getPaginatedElements(getResourcePromise, progressFn, limit = 25, offset = 0, elements = []) {
return new Promise((resolve, reject) =>
getResourcePromise({limit, offset})
.then(response => {
const newElements = elements.concat(response.records);
if (response.records.length === 0) {
resolve(newElements);
} else {
progressFn && progressFn(elements);
getPaginatedElements(getResourcePromise, progressFn, limit, offset+limit, newElements)
@adrianalonso
adrianalonso / standard_layout.html.twig
Created May 26, 2017 08:56
Custom Menu Sonata Admin
{% extends 'SonataAdminBundle::standard_layout.html.twig' %}
{% block side_bar_after_nav %}
YOUR CUSTOM MENU
{% endblock %}
@adrianalonso
adrianalonso / docker.sh
Created May 20, 2017 12:32
Eliminar contenedores e imágenes Docker
Eliminar todos contenedores
$ docker rm $(docker kill $(docker ps -aq))
Eliminar todas imágenes
$ docker rmi $(docker images -qf "dangling=true")
@adrianalonso
adrianalonso / ArrayMergeUtil.php
Created May 20, 2017 11:40
Array Merge with Integer Keys
class ArrayMergeUtil
{
/**
* @param array $array
*
* @return array
*/
public static function flatArrayAndSumValues(array $array)
{
$result = [];
@adrianalonso
adrianalonso / functions.php
Created April 6, 2017 08:25
Resize images on Wordpress
/**
* Image Resize
*
* @param $attachment_id
* @param $width
* @param $height
* @param bool $crop
* @return bool|string
*/
function rw_image_resize( $attachment_id, $width, $height, $crop = true )
@adrianalonso
adrianalonso / BodyRequestListener.php
Last active April 24, 2017 16:14
JSON BodyRequestListener
<?php
namespace AppBundle\EventListener;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**