Skip to content

Instantly share code, notes, and snippets.

James frodosghost

Block or report user

Report or block frodosghost

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@frodosghost
frodosghost / bubblesort.php
Created May 30, 2018
Sorting Algorithms using PHP
View bubblesort.php
<?php
/**
* BubbleSort in PHP
*
* @param array $data
* @return array
*/
function bubblesort ($data) {
$length = count($data);
@frodosghost
frodosghost / LegacySessionStorage.php
Last active Apr 28, 2016 — forked from tcz/LegacySessionStorage.php
Bridging the gap between standard $_SESSION and HttpFoundation Session with Silex.
View LegacySessionStorage.php
<?php
namespace Session\Storage;
use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage;
/**
* Session storage that avoids using _sf2_attributes subkey in the $_SESSION
* superglobal but instead it uses the root variable.
*
@frodosghost
frodosghost / CorsListener.php
Created Apr 14, 2016
CORS Listener and Handling with Symfony2
View CorsListener.php
<?php
namespace AppBundle\EventListener;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
@frodosghost
frodosghost / ScriptHandler.php
Last active Mar 24, 2016
Dependency Inception: Composer, Installing NPM, Installing Bower
View ScriptHandler.php
<?php
namespace AppBundle\Composer;
use Composer\Script\Event;
use Symfony\Component\Process\Process;
/**
* Script for Running NPM as part of Composer Update
*
@frodosghost
frodosghost / ScriptHandler.php
Last active Mar 24, 2016
Dependency Inception: Installing Bower dependencies with Composer
View ScriptHandler.php
<?php
namespace AppBundle\Composer;
use Composer\Script\Event;
use Symfony\Component\Process\Process;
/**
* Script for Running NPM as part of Composer Update
*
@frodosghost
frodosghost / app.js
Created Feb 19, 2016
AngularJS and Twig Templates
View app.js
var antelopeApp = angular.module('antelopeApp', [
'ngRoute',
'antelopeControllers'
]).config(function($interpolateProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
});
@frodosghost
frodosghost / ManyToEntityTransformer
Created Apr 12, 2014
Data Transformer: Many to Many for Entity Field
View ManyToEntityTransformer
<?php
namespace Acme\DemoBundle\Form\DataTransformer;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
@frodosghost
frodosghost / CommentType.php
Last active Dec 11, 2015
Base form code for saving multiple classes of data with Symfony2. This is for Jerome.
View CommentType.php
<?php
namespace Your\Product\Bundle\Form\CommentType;
use Your\Product\Bundle\Form\UserType;
class CommentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
View EditFormSubscriberTest.php
<?php
namespace Manhattan\Bundle\GalleryBundle\Tests\Form;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Manhattan\Bundle\GalleryBundle\Form\EventListener\EditFormSubscriber;
class EditFormSubscriberTest extends \PHPUnit_Framework_TestCase
@frodosghost
frodosghost / BasePage.php
Created Apr 13, 2012
BasePage setup for Doctrine2 Table Inheritance. Shows Content from same bundle and FrontPage from a separate Bundle.
View BasePage.php
<?php
namespace Manhattan\Bundle\ContentBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Manhattan\Bundle\ContentBundle\Entity\BasePage
*
* @ORM\Table(name="base_page")
You can’t perform that action at this time.