Skip to content

Instantly share code, notes, and snippets.

View hpatoio's full-sized avatar
:shipit:

Simone Fumagalli hpatoio

:shipit:
View GitHub Profile
@hpatoio
hpatoio / AccessTokenSubscriber.php
Last active August 29, 2015 14:05
Guzzle4 subscribers for access_token
<?php
namespace Hpatoio\Bitly\Subscribers;
use GuzzleHttp\Event\EmitterInterface;
use GuzzleHttp\Event\SubscriberInterface;
use GuzzleHttp\Command\Event\PrepareEvent;
class AccessTokenSubscriber implements SubscriberInterface
{
@hpatoio
hpatoio / gist:d98fe1f6d456544b5795
Last active August 29, 2015 14:11
ID Doctrine
<?php
namespace My\Model;
/**
* @ORM\Table(name="user")
* @ORM\Entity()
*/
class User
{
@hpatoio
hpatoio / tests.php
Last active September 10, 2015 11:58
<?php
public function testGetCitiesList()
{
$getClient = static::createClient([]);
$getClient->request(
'GET',
'/api/v3/cities',
server {
proxy_cache_path /var/nginx_cache/mycache levels=1:2 keys_zone=MYCACHE:5m inactive=12h max_size=20m;
# The config is even for the non-www host later you will see how we manage the redirect
server_name www.mysite.it mysite.it;
listen 111.222.333.444:80;
access_log /var/log/nginx/nginx.mysite_it.log upstream;
proxy_redirect off;
#!/bin/sh
BACKUP="/path/to/temp/dir/$$"
DAY=$(date +"%a")
### MySQL Setup ###
MUSER="root"
MPASS="your_root_password"
MHOST="localhost"
@hpatoio
hpatoio / composer.json
Created September 17, 2012 14:30
My composer
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
@hpatoio
hpatoio / gist:3738177
Created September 17, 2012 15:58
Output for "Composer install"
Loading composer repositories with package information
Installing dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for symfony/assetic-bundle dev-master -> satisfiable by symfony/assetic-bundle dev-master.
- symfony/assetic-bundle dev-master requires kriswallsmith/assetic 1.1.* -> no matching package found.
Problem 2
- Installation request for sensio/distribution-bundle dev-master -> satisfiable by sensio/distribution-bundle dev-master.
- sensio/distribution-bundle dev-master requires symfony/framework-bundle 2.2.* -> no matching package found.
@hpatoio
hpatoio / gist:3741975
Created September 18, 2012 08:16
Working composer.json for Symfony 2.1 with some extra bundles (Doctrine, FOS ...)
{
"name": "symfony/framework-standard-edition",
"description": "My default SF2.1 project",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
@hpatoio
hpatoio / gist:3811437
Created October 1, 2012 12:42
Custom Twig template for embedded form.
{% block collection_widget %}
{% spaceless %}
{#
Inspired by:
https://groups.google.com/forum/?fromgroups=#!topic/symfony2/onor9uFte9E
https://gist.github.com/1294186
#}
{% if prototype is defined %}
@hpatoio
hpatoio / gist:3953726
Created October 25, 2012 16:11
Api call
<?php
$ch = curl_init("http://assetic.servergrove.com/yuicompressor.json");
$encoded = "charset=UTF-8&in=%2Ftmp%2FYUI-IN-YdSk7U&out=%2Ftmp%2FYUI-OUT-AzeVJU&type=css&content=%23mapCanvas+img+%7B%0A++max-width%3A+none%3B%0A%7D%0A%0Abody+%7B%0A++padding-top%3A+90px%3B%0A%7D%0A";
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);