Skip to content

Instantly share code, notes, and snippets.

View hpatoio's full-sized avatar
:shipit:

Simone Fumagalli hpatoio

:shipit:
View GitHub Profile
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);
@hpatoio
hpatoio / gist:4071207
Created November 14, 2012 09:33
Export MySQL database to CSV file
hpatoio@namazu:~$ mysqldump -uroot -p DATABASE_NAME -T '/home/simone/export_csv' --fields-terminated-by "," --fields-enclosed-by '"' --lines-terminated-by "\n"
@hpatoio
hpatoio / gist:4071244
Created November 14, 2012 09:40
Export custom MySQL query to CSV
hpatoio@namazu:~$ mysql -uroot -h HOSTNAME -p DATABASE_NAME -B -e "select field1,field2 ... fieldX from \`TABLE_NAME\`;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > my_export.csv
@hpatoio
hpatoio / gist:4100640
Created November 17, 2012 22:06
Add then day to a date
shiftDay = 10
var myDate = new Date();
myDate.setDate(myDate.getUTCDate() + shiftDay)
day = myDate.getUTCDate()
month = myDate.getUTCMonth()*1 + 1
year = myDate.getUTCFullYear()