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 / Dockerfile
Last active February 16, 2021 11:00
Docker Centos PHP7.3 FPM
FROM centos:latest
# -----------------------------------------------------------------------------
# PHP
# -----------------------------------------------------------------------------
RUN yum -y --setopt=tsflags=nodocs update
RUN yum -y --setopt=tsflags=nodocs --nogpgcheck install epel-release
RUN yum -y --setopt=tsflags=nodocs --nogpgcheck install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
RUN yum -y --setopt=tsflags=nodocs --nogpgcheck --enablerepo=remi-php73 install \
php-cli \
@cesurapp
cesurapp / Dockerfile
Created February 3, 2019 17:34
MariaDB for Docker Alpine
FROM alpine:latest
# -----------------------------------------------------------------------------
# Install MariaDB
# -----------------------------------------------------------------------------
RUN apk update
RUN apk add pwgen
RUN apk add mariadb mariadb-client
RUN rm -f /var/cache/apk/*
@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()
@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 / 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 / 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 / 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 / ChoiceTypeExtension.php
Created November 7, 2020 17:37
Symfony 4.4+ Remove Multiple Choice Option
<?php
/**
* ChoiceType "preferred_choice_twice" Extension
*
* @author Ramazan APAYDIN <[email protected]>
*/
class ChoiceTypeExtension extends AbstractTypeExtension
{
public function buildView(FormView $view, FormInterface $form, array $options)
@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 / 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 = '';