Skip to content

Instantly share code, notes, and snippets.

View afurculita's full-sized avatar
👽
Searching for intelligent life

Alexandru Furculita afurculita

👽
Searching for intelligent life
View GitHub Profile
@afurculita
afurculita / get-current-user.php
Last active August 29, 2015 14:07
Get Current User in Symfony2
class AcmeClass {
public function getCurrentUser()
{
return $this->container->get('security.context')->getToken()->getUser();
}
}
@afurculita
afurculita / is-user-authenticated.php
Created October 7, 2014 20:21
Check if user is authenticated in Symfony2
class AcmeClass {
public function isAuthenticated()
{
return !$this->container->get('security.context')->isGranted('IS_AUTHENTICATED_ANONYMOUSLY');
}
}
@afurculita
afurculita / is-role-granted.php
Created October 7, 2014 20:25
Check if a User Role is Granted in Symfony2
class Acme
{
public function isGranted($role)
{
return $this->container->get('security.context')->isGranted($role);
}
}
@afurculita
afurculita / gist:020650deef64e2602aba
Created October 22, 2014 13:30
MySQL – Disable Foreign Key Checks or Constraints
SET foreign_key_checks =0;
DROP TABLE `table_name` ;
DELETE FROM `table_name` WHERE id = 1;
SET foreign_key_checks =1;
@afurculita
afurculita / gist:598bf1aef83fdb421b19
Last active August 29, 2015 14:09
Best way to import large databases in MySql
mysql -u database_user_name -p -D database_name < complete_file_path_with_file_name_and_extension
Here
u stands for User
p stands for Password
D stands for Database
Complete file path with name and extension can be like
@afurculita
afurculita / gist:84e4025802958d0b303f
Created November 12, 2014 22:10
Flush DNS in Windows and Chrome
Windows:
1. Open cmd
2. Type "ipconfig /flushdns"
Google Chrome:
1. Navigate to chrome://net-internals/#dns
2. Press the "Clear host cache" button.
@afurculita
afurculita / gist:39973d799490c7c999c7
Created December 8, 2014 23:11
Offline-First Web Apps

Offline-First Web Apps

Intro

"Web" and "online" are two closely associated terms, downright synonymous to many people. So why on earth would we talk about "offline" web technologies, and what does the term even mean?

via http://www.html5rocks.com/en/features/offline

Posts

@afurculita
afurculita / gist:849142963bd08c5771c4
Created December 17, 2014 21:27
When composer runs out of memory
php -d memory_limit=-1 /usr/local/bin/composer update --verbose --profile
@afurculita
afurculita / CustomHandler.php
Last active August 29, 2015 14:18 — forked from baldurrensch/CustomHandler.php
This is a handler for the JMS serializer to handle parent and child type serialization. You need to set the type of your collection as `@Type("\Acme\MyBundle\Model\ChildType")`, so that the serializer picks up the handler correctly. Also remember that you need to hook up the handler as a service (and give it the correct tag).
<?php
namespace Acme\MyBundle\Serializer\Handler;
use JMS\Serializer\Handler\SubscribingHandlerInterface;
use JMS\Serializer\EventDispatcher\Event;
use JMS\Serializer\GraphNavigator;
use JMS\Serializer\XmlSerializationVisitor;
use JMS\Serializer\GenericSerializationVisitor;
<?php
namespace Gitonomy\Bundle\CoreBundle\Serializer\Normalizer;
use Doctrine\Common\Persistence\ManagerRegistry;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
class EntitiesNormalizer implements NormalizerInterface, DenormalizerInterface
{