Skip to content

Instantly share code, notes, and snippets.

@giorrrgio
giorrrgio / gist:3129752
Created July 17, 2012 14:34 — forked from chanon/gist:661597
Facebook iframe Canvas App Authentication in node.js
var querystring = require("querystring");
var base64ToString = function(str) {
return (new Buffer(str || "", "base64")).toString("ascii");
};
var base64UrlToString = function(str) {
return base64ToString( base64UrlToBase64(str) );
};
@giorrrgio
giorrrgio / raphael-svg-buildjson
Created August 27, 2012 09:49 — forked from benbarnett/raphael-svg-buildjson
loop through the 'paper' variable from Raphael JS and build up the JSON object describing all images and paths within it.
// loop through the 'paper' variable from Raphael JS and build up the JSON object describing all images and paths within it.
buildJSON = function(paper) {
var svgdata = [];
svgdata.push({
width: 390,
height: 400
});
$.each(paper,
@giorrrgio
giorrrgio / ImagineResizer.php
Last active August 1, 2018 08:34
best fit images
<?php
namespace Acme\MyBundle\Service;
use Symfony\Component\HttpFoundation\File\File;
use Imagine\Image\ImagineInterface;
use Imagine\Image\BoxInterface;
use Imagine\Image\Point;
use Imagine\Image\Box;
@giorrrgio
giorrrgio / Migration1.php
Created October 17, 2012 06:57
Symfony 2.1 Doctrine Migrations and Sluggable
<?php
namespace Application\Migrations;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Acme\MyBundle\Command\UpdateSlugsCommand;
use Symfony\Component\Console\Tester\CommandTester;
use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;
#open ~/.zshrc with your favourite editor
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="kolo"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
@giorrrgio
giorrrgio / convert.php
Last active December 15, 2015 19:09
JSON TO KML
<?php
include('php-kml/lib/kml.php');
$jsonFile = file_get_contents("data.json");
$json_a = json_decode($jsonFile, true);
$a = new kml_Document();
$a->set_id('uid000000111');
@giorrrgio
giorrrgio / WebTestCase.php
Last active December 19, 2015 07:28
A helper method to save Symfony Client content to an html file and immediately open the page on your browser
<?php
namespace MyNamespace\CoreBundle\Test;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as SymfonyWebTestCase;
use Symfony\Component\Process\Process;
abstract class WebTestCase extends SymfonyWebTestCase
{
@giorrrgio
giorrrgio / xdphp.sh
Last active August 29, 2015 14:06
xdphp.sh
#!/bin/bash
php -dxdebug.remote_autostart=On -didekey=PHPSTORM -dremote_host=localhost $*
@giorrrgio
giorrrgio / composer.json
Last active August 29, 2015 14:06
HtmlScraper
{
"require": {
"symfony/dom-crawler": "*",
"symfony/css-selector": "*"
}
}
<?php
namespace Acme\Controller;
class FooControllerTest extends \PHPUnit_Framework_TestCase
{
public function testHook()
{
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['HTTP_USER_AGENT'] = 'Foobar Agent';