Skip to content

Instantly share code, notes, and snippets.

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

Fabian FabianSchmick

💭
¯\_(ツ)_/¯
View GitHub Profile
@FabianSchmick
FabianSchmick / Brokkolinudeln-mit-Ei.md
Last active January 10, 2024 12:20
Meine Lieblings-Koch-Rezepte

Brokkolinudeln mit Ei aus dem Wok (2 Portionen)

Zutaten

  • 125g Mie-Nudeln oder Wok-Nudeln
  • 250g Brokkolie
  • 2 Knoblauchzehen
  • 30g Mandeln
  • 3 Eier
  • 2 Tl Sambal Oelek
  • 1 El Zitronensaft
  • 3 El Sojasauce
@FabianSchmick
FabianSchmick / MapService.php
Created May 25, 2020 12:57
Map geo radius search
<?php
namespace App\Service;
use App\Entity\Address;
use Doctrine\ORM\EntityManagerInterface;
use Geocoder\Provider\Nominatim\Nominatim;
use Geocoder\Query\GeocodeQuery;
use Geocoder\StatefulGeocoder;
use Http\Adapter\Guzzle6\Client;
@FabianSchmick
FabianSchmick / app.js
Created May 11, 2020 09:44
Reset radio - switch buttons
/**
* Initializes switch fields
*
* https://stackoverflow.com/a/8318129/5947371
*/
initSwitch() {
let selector = '.custom-control-input[type="radio"]';
$(selector).each((index, radio) => {
let $radio = $(radio),
@FabianSchmick
FabianSchmick / FormType.php
Last active November 13, 2019 10:23
Change Symfony Form-field in Form-event
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$data = $event->getData();
$form = $event->getForm();
$config = $form->get('groups')->getConfig(); // get the field config
$name = $config->getName(); // get the name string
$type = get_class($config->getType()->getInnerType()); // get the type class
$options = $config->getOptions(); // get the options array
$options['label'] = "Login Name"; // e.g. change the label
@FabianSchmick
FabianSchmick / Ajax.js
Last active September 30, 2019 13:42
Javascript SPA
import { addDisabled, removeDisabled } from '../../util/disable';
/**
* Available options:
*
* options = {
* settings = {
* type: 'POST' || null, // Type of request or [data-ajax-method] - default GET
* url: '/script' || null, // Url for the request or form[action] or a[href] - default current url
* data: data || [] // Additional data to be send or serialized form - default []
@FabianSchmick
FabianSchmick / DefaultController.php
Created July 19, 2019 11:24
Symfony receive content for ajax or normal request
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends Controller
{
@FabianSchmick
FabianSchmick / App_Swift_Transport_FailoverTransport .php
Created July 11, 2019 08:46
Symfony Swiftmailer multiple mailers with fallback
<?php
namespace AppBundle\Util;
class App_Swift_Transport_FailoverTransport extends \Swift_Transport_FailoverTransport
{
/**
* @param \Swift_Mailer[] $mailers
*/
public function __construct(array $mailers)
@FabianSchmick
FabianSchmick / ParseLinks.php
Last active June 17, 2019 06:19
Parse (get) all links from a website
@FabianSchmick
FabianSchmick / .scrutinizer.yml
Last active January 18, 2019 13:03
Scrutinizer Symfony 3 configuration
build:
nodes:
analysis:
project_setup:
override:
- 'true'
tests:
override:
- ./vendor/bin/simple-phpunit
- sensiolabs-security-checker-run
@FabianSchmick
FabianSchmick / Cron.php
Last active July 8, 2020 09:03
Cron schedule for Symfony commands
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Cron