Skip to content

Instantly share code, notes, and snippets.

View cesurapp's full-sized avatar
🎯
odaklanma

Cesur APAYDIN cesurapp

🎯
odaklanma
View GitHub Profile
@cesurapp
cesurapp / FilteredJsonResource.php
Created May 11, 2023 22:43
Laravel Filtered JsonResource
<?php
namespace App\Resources;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Resources\Json\JsonResource;
class FilteredJsonResource extends JsonResource
{
public static function collection($resource)
@cesurapp
cesurapp / docker-compose.yml
Created October 7, 2021 09:06
Ldap Test Server
version: '3.5'
services:
ldap:
image: osixia/openldap
ports:
- 389:389
ldap_admin:
image: osixia/phpldapadmin
@cesurapp
cesurapp / TablePrefixListener.php
Created April 4, 2021 22:11
Symfony Doctrine Table Add Prefix
<?php
namespace App\Listener;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
class TablePrefixListener
{
protected string $tablePrefix = '';
@cesurapp
cesurapp / jwt.php
Created March 14, 2021 12:01
JWT Custom User Key
<?php
$userHashKey = 'password';
$privateUserPayloadData = [
'userId' => 1,
'exp' => (new \DateTime('+5 hours'))->getTimestamp()
];
// Generate Token
$token = JWT::encode($privateUserPayloadData, $userHashKey,'HS256');
@cesurapp
cesurapp / ChoiceTypeExtension.php
Created November 7, 2020 17:37
Symfony 4.4+ Remove Multiple Choice Option
<?php
/**
* ChoiceType "preferred_choice_twice" Extension
*
* @author Ramazan APAYDIN <apaydin541@gmail.com>
*/
class ChoiceTypeExtension extends AbstractTypeExtension
{
public function buildView(FormView $view, FormInterface $form, array $options)
@cesurapp
cesurapp / AsyncQuery.php
Created September 11, 2020 11:33
Symfony Async Query using Process Component
<?php
namespace App\Service;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Query\Parameter;
use Symfony\Component\Process\Process;
/**
* Async SQL Query
@cesurapp
cesurapp / addWorkDay.php
Last active July 22, 2020 20:26
Add Working Day with Holidays
<?php
/**
* Add Working Day with Holidays
*
* @param \DateTimeInterface $first
* @param int|null $weekDay
* @param \DateTimeInterface[]|null $holidays
*
* @return \DateTimeInterface
@cesurapp
cesurapp / hexToRgba.php
Last active January 10, 2020 08:16
PHP Hex to RGBA
<?php
/**
* Hex to RGBA
*
* @param string $hexColor
* @param string|int|double $opacity
*
* @return string
*/
@cesurapp
cesurapp / AuthorizationChecker.php
Created November 30, 2019 19:17
Symfony 4.4 or 5.x Override AuthorizationChecker
<?php
# src/Security/AuthorizationChecker.php
namespace App\Security;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
@cesurapp
cesurapp / watcher.py
Created July 3, 2019 03:25
Bind9 Zone Directory Watcher
import time
import os
import subprocess
import re
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
def outputCmd(cmd):
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout,stderr = proc.communicate()