Skip to content

Instantly share code, notes, and snippets.

@wersoo
wersoo / README.md
Last active February 13, 2018 18:23
Database Tools for IntelliJ IDEs, extractor for `mysqldump` alike formater

Installation

Open the scripts directory. There are a couple ways to do this...

  1. Hit SHIFTSHIFT and select "Data Extractor", then choose "Go to Scripts Directory"
  2. In an existing query, choose the output format (CSV, HTML, TSV selector), then choose "Go to Scripts Directory"

Create a new file (Right Click -> New -> File) and name it XML-Mysqldump.xml.js.

Paste the contents of XML-Mysqldump.xml.js into this file.

@wersoo
wersoo / gist:21ca5be1891a8e0ec3e8
Created June 17, 2015 16:33
Type Hinting for Arrays in PhpDoc Types and PHPStorm
<?php
/**
* @param
* @param array
* @param string[]|int[]
* @param array<int,string|int>
*/
function mergeArrays(
array $array1 = [],
@wersoo
wersoo / gist:e4d15e204131939c0d70
Last active August 29, 2015 14:19
Отображение значений Nullable поля в Symfony2

Если необходимо отображать точное значение поля, которое допускает NULL в качестве значений, можно поступить следующим образом:

$builder->add('someBooleanField', 'choice', [
    'choices'  => ['' => 'Нет значения', 0 => 'OFF', 1 => 'ON'],
    'required' => false,
]);
@wersoo
wersoo / ArrayableInterface.php
Last active August 29, 2015 14:12
Simple ArrayableTrait — with single toArray() method, which serializes the object on which it is used.
<?php
interface ArrayableInterface {
/**
* @param string[] $keys
* @return array
*/
public function toArray($keys = []);
}
@wersoo
wersoo / ArrayableInterface.php
Last active August 29, 2015 14:12
Simple ArrayableTrait — with single toArray() method, which serializes the object on which it is used. Depends on Symfony\Component\PropertyAccess
<?php
use Symfony\Component\PropertyAccess\PropertyPathInterface;
interface ArrayableInterface {
/**
* @param string[]|PropertyPathInterface[] $keys
* @return array
*/
public function toArray($keys = []);
@wersoo
wersoo / event&isteners.js
Created January 14, 2013 09:54
Fun with events and event listeners
function function_wrapper(params) {
return function(event) {
event.preventDefault ? event.preventDefault() : event.returnValue = false;
var param = params.name;
};
}
el.addEventListener ?
el.addEventListener('click', function_wrapper(params), false) :
el.attachEvent('onclick', function_wrapper(params));
@wersoo
wersoo / cssclasses.js
Created January 14, 2013 09:26
fun with css classes in js
function toggleClass(el, class_name) {
if (isClass(el, class_name)) {
removeClass(el, class_name);
} else {
addClass(el, class_name);
}
}
function removeClass(el, class_name) {
var regexp = new RegExp("(?:^|\\s)" + class_name + "(?!\\S)","g");
@wersoo
wersoo / SonataAdminBundle:standard_layout.html.twig
Created August 24, 2012 20:10
Fix for exception "Array to string conversion in SonataAdminBundle::standard_layout.html.twig"
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}