Skip to content

Instantly share code, notes, and snippets.

View FabianSchmick's full-sized avatar
💭
¯\_(ツ)_/¯

Fabian FabianSchmick

💭
¯\_(ツ)_/¯
View GitHub Profile
@FabianSchmick
FabianSchmick / MyParsedown
Created November 20, 2018 08:43 — forked from ShNURoK42/MyParsedown
Mention for Parsedown
<?php
class MyParsedown extends \Parsedown
{
function __construct()
{
$this->InlineTypes['@'][]= 'UserMention';
$this->inlineMarkerList .= '@';
}
@FabianSchmick
FabianSchmick / ConsoleExceptionListener.php
Last active April 16, 2020 12:27
Symfony - error reporting via email on critical errors or exceptions.
<?php
namespace AppBundle\EventListener;
use Symfony\Component\Console\Event\ConsoleErrorEvent;
use Psr\Log\LoggerInterface;
class ConsoleExceptionListener
{
private $logger;
@FabianSchmick
FabianSchmick / PaginationExtension.php
Last active August 31, 2018 13:19
Twig generate a pagination with breaks and prev next button
<?php
namespace AppBundle\Twig;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Component\Translation\TranslatorInterface;
class PaginationExtension extends \Twig_Extension
{
@FabianSchmick
FabianSchmick / MailerLoggerUtil.php
Last active January 31, 2019 13:25
Log swiftmailer mails in eml files
<?php
namespace AppBundle\Util;
use Gedmo\Sluggable\Util as Sluggable;
use Swift_Events_SendEvent;
use Swift_Events_SendListener;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem;
@FabianSchmick
FabianSchmick / InlineSvgExtension.php
Last active August 30, 2018 08:39
Inline Svg - Twig Filter
<?php
namespace AppBundle\Twig;
/**
* Class InlineSvgExtension.
*
* Filter which converts svg file and returns an inline svg string
*
* Usage:
@FabianSchmick
FabianSchmick / main.js
Last active August 2, 2018 12:32
HTML5 constraint validation with jQuery
function htmlConstraintValidation(e, el) {
var form = $(el).closest('form');
$(form).find('[required]').each(function (i, input) {
if (input.validity.valueMissing) {
console.log('Please fill in all required fields!');
e.preventDefault();
return false;
}
@FabianSchmick
FabianSchmick / DecimalType.php
Last active July 30, 2018 07:20 — forked from chrif/NumberToStringTransformer.php
Symfony DataTransformer for decimals (number) with comma and decimal points
<?php
namespace AppBundle\Form;
use AppBundle\Form\DataTransformer\NumberToStringTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
/**
@FabianSchmick
FabianSchmick / .php_cs.dist
Created July 16, 2018 09:44
PHP-CS-Fixer config
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
;
return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'array_indentation' => true,
@FabianSchmick
FabianSchmick / keybindings.json
Last active July 8, 2020 09:07
Sublime config
[
{
"keys": ["ctrl+7"],
"command": "toggle_comment",
"args": {
"block": false
}
},
{
"keys": ["ctrl+shift+7"],
@FabianSchmick
FabianSchmick / main.js
Last active June 7, 2018 06:22
Ajax form skeleton
$("#idForm").on('submit', function (e) {
$.ajax({
type: $(this).attr('method'),
url: $(this).attr('action'),
data: $(this).serialize()
}).done(function(data) {
console.log(data);
}).fail(function(XMLHttpRequest, textStatus, errorThrown) {
console.log('Error');
});