Skip to content

Instantly share code, notes, and snippets.

View JoshuaEstes's full-sized avatar
👨‍💻

Joshua Estes JoshuaEstes

👨‍💻
View GitHub Profile
@JoshuaEstes
JoshuaEstes / database.sql
Last active December 15, 2015 15:17
MySQL Database Size Information
-- Display All Database Sizes in MB
SELECT table_schema AS "Database", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;
-- Display All Database Sizes in GB
SELECT table_schema AS "Database", ROUND(SUM(data_length + index_length) / 1024 / 1024 / 1024, 2) AS "Size (GB)" FROM information_schema.TABLES GROUP BY table_schema;
-- Display All Table Sizes for a Database in MB
SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "INSERT DATABASE NAME HERE" ORDER BY (data_length + index_length) DESC;
<?php
namespace AppBundle\Form\DataMapper;
use Symfony\Component\Form\DataMapperInterface;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Security\Core\User\UserInterface;
class UserSettingDataMapper implements DataMapperInterface
{
public function mapDataToForms($data, $forms)
<?php
namespace AppBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use AppBundle\Form\DataMapper\UserSettingDataMapper;
class UserProfileSettingsType extends AbstractType
{
public function buildForm(FormBuilderInterface $build, array $options)
<?php
namespace AppBundle\Entity;
use Symfony\Component\Security\Core\User\UserInterface;
class UserSetting
{
/**
* @var UserInterface
<?php
namespace AppBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
/**
* This assumes you already have a User entity, this just shows the parts
* required
<?php
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\File\File;
public function streamAction()
{
$file = new File('/path/to/largefile.ext');
// in case you need the container
$container = $this->container;
$response = new StreamedResponse(function() use($container, $file) {
<?php
protected function interact(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getDialogHelper();
$validator = Validation::createValidator();
$inputValue = $dialog->askAndValidate($output, 'Enter some input: ', function($value) use($validator){
$errors = $validator->validateValue($value, new Assert\NotBlank());
if (count($errors)) {
throw new \InvalidArgumentException((string) $errors);
<?php
protected function interact(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getDialogHelper();
$inputValue = $dialog->askAndValidate($output, 'Enter some input: ', function($value){
$validator = Validation::createValidator();
$errors = $validator->validateValue($value, new Assert\NotBlank());
if (count($errors)) {
throw new \InvalidArgumentException((string) $errors);
<?php
protected function interact(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getDialogHelper();
$inputValue = $dialog->askAndValidate($output, 'Enter some input: ', array($this, 'validateInput'));
}
public function validateInput($value)
{