Skip to content

Instantly share code, notes, and snippets.

@enumag
enumag / UtcDateTimeType.php
Created May 15, 2017 07:56
UtcDateTimeType
<?php
/*
* @copyright Copyright (c) 2016 Ubiquiti Networks, Inc.
* @see https://www.ubnt.com/
*/
namespace AppBundle\Database;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\ConversionException;
<?php
declare(strict_types=1);
namespace Kdyby\Annotations\DI;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\CachedReader;
use Doctrine\Common\Annotations\Reader;
use Kdyby\DoctrineCache\DI\DoctrineCacheExtension;
```
$ sudo service mysql stop
$ sudo mysqld_safe --skip-grant-tables --skip-syslog --skip-networking
```
leave it be, run second terminal:
```
$ mysql -u root
$ UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE User='root';
@enumag
enumag / gist:2dc3516ffeab67f6203f32cf730ab97f
Created July 26, 2016 13:29
Fix double star in copyright for php-cs-fixer
find * -type f -exec sed -i 'N; s/<?php\n\/\*\*/<?php\n\/\*/' {} \;
@enumag
enumag / ResourceMacro.php
Last active August 29, 2015 14:19
ResourceMacro
<?php
namespace App\Latte;
use Latte\Compiler;
use Latte\Macros\MacroSet;
class ResourceMacro extends MacroSet
{
@enumag
enumag / HistoryListener.php
Last active August 29, 2015 14:05
HistoryListener
<?php
namespace VojtechDobes\NetteAjax;
use Nette\Application\Application;
use Nette\Object
class HistoryListener extends Object
{
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.1.deb
sudo dpkg -i elasticsearch-1.1.1.deb
@enumag
enumag / iedetector.js
Last active August 29, 2015 13:57
IE detector
(function(){
var agent = navigator.userAgent.toLowerCase();
if (/trident/.test(agent)) {
var version = (/msie ([\w.]+)/.exec(agent) || agent.indexOf('compatible') < 0 && /mozilla(?:.*? rv:([\w.]+)|)/.exec(agent) || [])[1];
if (version) {
document.documentElement.className += ' ie' + parseInt(version);
}
}
})();
@enumag
enumag / codeception-debug.php
Last active January 4, 2016 19:49
Codeception dump function
<?php
// requires -vv
// TODO: show location using @tracySkipLocation
// TODO: use colors if possible (Dumper::dump() + output buffering)
function debug($var)
{
$dump = \Nette\Diagnostics\Dumper::toText($var);
\Codeception\Util\Debug::debug("\n" . trim($dump));
}
@enumag
enumag / gist:6417587
Created September 2, 2013 21:53
Nette riddle - are these equivalent?
services:
foo:
class: FooService('two')
services:
foo:
class: FooService
arguments: [ 'two' ]