Skip to content

Instantly share code, notes, and snippets.

View SebLours's full-sized avatar

Sébastien Lourseau SebLours

View GitHub Profile
@javilobo8
javilobo8 / download-file.js
Last active July 1, 2024 23:21
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@rosskevin
rosskevin / Enable overlay fs in docker on Ubuntu 15.04
Last active March 31, 2017 20:30
Enable the overlay fs for Docker on Ubuntu 15.04
systemctl stop docker
# kill all old images etc
rm -rf /var/lib/docker
# change the startup options for docker service
mkdir /etc/systemd/system/docker.service.d
cd /etc/systemd/system/docker.service.d
vi storage.conf
<?php
namespace Acme\Serializer\Normalizer;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer;
@jordwest
jordwest / Makefile
Created April 20, 2015 06:23
Simple front-end builds with Makefiles
# Specify directories under /client/src to be copied directly
COPYDIRS = lib img
client: copy client/build/js/app.js client/build/css/app.css
clean:
rm -Rf client/build
rebuild: clean client
@jgornick
jgornick / criteria-to-query-builder.php
Created January 28, 2014 16:57
Doctrine: Criteria Array to Doctrine QueryBuilder
<?php
/**
* Recursively takes the specified criteria and adds too the expression.
*
* The criteria is defined in an array notation where each item in the list
* represents a comparison <fieldName, operator, value>. The operator maps to
* comparison methods located in ExpressionBuilder. The key in the array can
* be used to identify grouping of comparisons.
*
@jamesmoey
jamesmoey / ExtendedArrayCollection.php
Last active July 24, 2023 07:02
Extend array collection from Doctrine with operation to perform on all the item in the collection.
<?php
namespace Collections;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\PropertyAccess\PropertyAccess;
class ExtendedArrayCollection extends ArrayCollection
{
/**
@rybakit
rybakit / JsonListener.php
Last active December 23, 2015 08:49
Json listener for Buzz http client
<?php
use Buzz\Listener\ListenerInterface;
use Buzz\Message\MessageInterface;
use Buzz\Message\RequestInterface;
class JsonListener implements ListenerInterface
{
/**
* {@inheritdoc}
@loganlinn
loganlinn / do.sh
Created March 22, 2012 23:00
PHP strcmp+strtolower VS strcasecmp Benchmark
for i in 50 100 250 500; do echo "String length: $i"; php strcmpbench.php $i; php strcasecmpbench.php $i; echo "\n"; done
# Example run:
#
# String length: 50
# ************************
# * strcomp + strtolower *
# ************************
# Time: 0.000082
# Memory: 1456
@snc
snc / InteractiveLoginListener.php
Created October 25, 2011 13:44
Custom FOSUB redirects
<?php
namespace My\Bundle\EventListener;
use My\Bundle\User\User;
use Symfony\Component\Routing\Router;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
class InteractiveLoginListener
{