Skip to content

Instantly share code, notes, and snippets.

Avatar

Tristan Bessoussa tristanbes

View GitHub Profile
@tristanbes
tristanbes / example.sh
Created Nov 9, 2012
Install Graphite on Debian Server
View example.sh
# Installing graphite dependencies
apt-get install -y python2.6 python-pip python-cairo python-django python-django-tagging
apt-get install -y libapache2-mod-wsgi python-twisted python-memcache python-pysqlite2 python-simplejson
pip install whisper
pip install carbon
pip install graphite-web
# Setup a vhost by grabbing the example the graphite team released on their repo.
# In this file, you'll provide the url used to access to your Graphite dashboard
wget https://raw.github.com/tmm1/graphite/master/examples/example-graphite-vhost.conf -O /etc/apache2/sites-available/graphite
@tristanbes
tristanbes / config.yml
Created Feb 22, 2013
Session cookie name for Symfony2 and subdomains
View config.yml
framework:
esi: { enabled: true }
translator: { fallback: %locale% }
secret: %secret%
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: %kernel.debug%
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
@tristanbes
tristanbes / snapshot.sh
Created Aug 29, 2017 — forked from danharper83/snapshot.sh
Creates a snapshot on platform using platform commands
View snapshot.sh
#!/usr/bin/env bash
ORIGIN="develop"
TARGET="master"
if [ "$PLATFORM_BRANCH" = "$ORIGIN" ]; then
/app/.platformsh/bin/platform self-update -y -q
/app/.platformsh/bin/platform backup -y -q -p $PLATFORM_PROJECT -e $TARGET
fi
@tristanbes
tristanbes / Book.php
Created Mar 19, 2012
How to dynamically add translations to your I18N object using SonataAdminBundle & DoctrineExtensions
View Book.php
<?php
namespace Demo\BookBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* Demo\BookBundle\Entity\Book
View spotify_battery_drain.bash
# If you open your Ressource monitoring under OSX, you'll see that the
# Process "Spotify Helper" is eating between 20% and 30% of CPU constantly
# It means that when you're on battery, it'll drain it faster.
# To prevent the Spotify Helper (which are basically ads for spotify) from spawning process,
# you should disable access to the app doing this (close Spotify first) :
sudo chmod 000 "/Applications/Spotify.app/Contents/Frameworks/Spotify Helper EH.app"
sudo chmod -N "/Applications/Spotify.app/Contents/Frameworks/Spotify Helper EH.app"
View GuzzleExceptionListener.php
<?php
namespace Tristanbes\ElophantBundle\EventListener;
use Guzzle\Http\Exception\BadResponseException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Tristanbes\ElophantBundle\Manager\StatsManager;
View GuzzleExceptionListener.php
<?php
namespace Tristanbes\ElophantBundle\EventListener;
use Guzzle\Http\Exception\BadResponseException;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Tristanbes\ElophantBundle\Manager\StatsManager;
View app.php
// ...
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
View Plugin.php
<?php
/**
* This class handles MoxieManager SymfonyAuthenticator (Symfony < 2.x).
*
* @author Tristan Bessoussa <tristan.bessoussa@gmail.com>
*/
class MOXMAN_SymfonyAuthenticator_Plugin implements MOXMAN_Auth_IAuthenticator
{
public function authenticate(MOXMAN_Auth_User $user)
View security.yml
main:
remember_me:
key: "%secret%"
lifetime: 31536000
path: /
domain: .my-domain.com # Defaults to the current domain from $_SERVER
You can’t perform that action at this time.