Skip to content

Instantly share code, notes, and snippets.

View artyuum's full-sized avatar
🎯
Focusing

Dynèsh Hassanaly artyuum

🎯
Focusing
View GitHub Profile
<?php
declare(strict_types = 1);
namespace App\EventSubscriber;
use App\Exception\interfaces\ClientErrorInterface;
use App\Security\UserTypeIdentification;
use App\Utils\JSON;
use Doctrine\DBAL\DBALException;
use Doctrine\ORM\ORMException;
@ajgarlag
ajgarlag / DecisionController.php
Last active May 28, 2021 15:56
Simple trikoder/oauth2-bundle decision flow
<?php
//src/Controller/DecisionController.php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\UriSigner;
use App\EventListener\SignedAuthorizationRequestSubscriber;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
@iamhosseindhv
iamhosseindhv / webpackEncore_browsersync.js
Created July 2, 2018 14:22
Browser sync for Webpack Encore Symfony 4
let config = Encore.getWebpackConfig();
config.watchOptions = { poll: true, ignored: /node_modules/ };
config.plugins.push(
new BrowserSyncPlugin(
{
host: 'aro.tech',
proxy: 'aro.tech',
files: [ // watch on changes
{
match: ['public/build/**/*.js'],
@whoisryosuke
whoisryosuke / incrementing-slugs.php
Last active March 21, 2022 13:17
Laravel: Check database for duplicate slugs and generate incrementing slug name (repeat-name-2, repeat-name-3). Found via: https://codereview.stackexchange.com/questions/162254/append-a-incrementing-number-to-a-slug-username
<?php
protected function create(array $data)
{
$slug = str_slug($data['first_name'] . '.' . $data['last_name']);
$next = 2;
// Loop until we can query for the slug and it returns false
while (User::where('slug', '=', $slug)->first()) {
$slug = $slug . '-' . $next;
$next++;
@signalpoint
signalpoint / example.php
Last active July 16, 2022 23:41
Drupal 8 Set Message Example
<?php
// The drupal_set_message() function is being deprecated!
// @see https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/function/drupal_set_message/8.5.x
// > Deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
// > Use \Drupal\Core\Messenger\MessengerInterface::addMessage() instead.
// In some custom code.
\Drupal::messenger()->addMessage('Say something else');
@codfish
codfish / .php_cs.dist
Last active July 6, 2023 19:12
PHP-CS-Fixer configuration file. PSR-2 plus some opinionated options to make code cleaner.
<?php
/**
* Rules we follow are from PSR-2 as well as the rectified PSR-2 guide.
*
* - https://github.com/FriendsOfPHP/PHP-CS-Fixer
* - https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
* - https://github.com/php-fig-rectified/fig-rectified-standards/blob/master/PSR-2-R-coding-style-guide-additions.md
*
* If something isn't addressed in either of those, some other common community rules are
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Subscriptions - freek@spatie.be</title>
</head>
<body>
<outline text="PHP" title="PHP">
<outline htmlUrl="http://frederickvanbrabant.com" title="frederickvanbrabant.com" xmlUrl="http://frederickvanbrabant.com/feed.xml" type="rss" text="frederickvanbrabant.com"/>
<outline htmlUrl="http://mattallan.org" title="mattallan.org" xmlUrl="http://mattallan.org/feed.xml" type="rss" text="mattallan.org"/>
<outline title="asked.io" xmlUrl="https://asked.io/rss" type="rss" text="asked.io"/>
@lenybernard
lenybernard / XliffFixerCommand.php
Created January 26, 2017 22:35
Symfony console command to parse xliff files to add or update missing id attribute
<?php
namespace AppBundle\Command;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
@azhararmar
azhararmar / Symfony - Manual User Authentication
Last active June 16, 2023 15:35
Manually Authenticate User In Symfony
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
// Manually authenticate user in controller
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
$this->get('session')->set('_security_main', serialize($token));
@muhammadghazali
muhammadghazali / What is server_names_hash_bucket_size.md
Last active February 9, 2024 14:13
Nginx: What is server_names_hash_bucket_size?

Background

While I'm learning how to use Nginx, I was instructed to update the server_names_hash_bucket_size (/etc/nginx/nginx.conf) value from 32 to 64, but I don't understand why should I increase the value to 64.

References

References that have been read so far: