Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻

Joshua Estes JoshuaEstes

👨‍💻
View GitHub Profile
@JoshuaEstes
JoshuaEstes / database.sql
Last active Dec 15, 2015
MySQL Database Size Information
View database.sql
-- 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;
View UserSettingDataMapper.php
<?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)
View UserProfileSettingsType.php
<?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)
View UserSetting.php
<?php
namespace AppBundle\Entity;
use Symfony\Component\Security\Core\User\UserInterface;
class UserSetting
{
/**
* @var UserInterface
View User.php
<?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
View gist.php
<?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) {
View gist.php
<?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);
View gist.php
<?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);
View gist.php
<?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)
{
You can’t perform that action at this time.