Skip to content

Instantly share code, notes, and snippets.

View NBoulfroy's full-sized avatar
🎯
Focusing

Nicolas BOULFROY NBoulfroy

🎯
Focusing
View GitHub Profile
@NBoulfroy
NBoulfroy / README.md
Last active July 3, 2023 09:06
[Failed to start docker.service: Transport endpoint is not connected] #docker #wsl2

Execute this commands like this to solve the error "Failed to connect to bus: Host is down".

  1. sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig
  2. sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
  3. exec sudo nsenter -t $(pidof systemd) -m -p su - $LOGNAME
@NBoulfroy
NBoulfroy / UserSubscriber.php
Created November 8, 2021 14:11
[Doctrine event with data fixtures] Prevent doctrine event with data fixtures #PHP #Symfony #Doctrine
<?php
namespace App\EventListener;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\EventSubscriber\EventSubscriberInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Events;
class UserSubscriber implements EventSubscriberInterface
@NBoulfroy
NBoulfroy / utils.php
Last active April 7, 2021 15:27
[Get Attributes from SimpleXMLElement] Get Attributes from SimpleXMLElement in array #PHP
<?php
/**
* @param SimpleXMLElement $data
*
* @return array
*/
function getAttributes($data)
{
$attributes = [];
@NBoulfroy
NBoulfroy / utils.php
Last active April 7, 2021 15:26
[Camel case formatter] Function to format a snake case string to camal case string #PHP
<?php
/**
* @param string $string
*
* @return string
*/
function camelCaseFormatter($string) {
$format = null;
$stringExplode = explode('_', $string);
@NBoulfroy
NBoulfroy / noAccent.php
Last active April 7, 2021 15:28
[Remove accents from string] Function to replace accents #PHP
<?php
/**
* @param string $string
*
* @return string
*/
public function toNoAccent(string $string)
{
$accent = array(
@NBoulfroy
NBoulfroy / input.js
Last active October 15, 2019 14:00
[Add data & clear old data with Materialize] Add data & clear old data in select input with Materialize #materialize #jQuery
let element = $('#point_sale_city');
let select = $('#point_sale_district');
let url = '{{ path('route_ajax', {id: 0}) }}';
$(document).ready(function() {
select.on('contentChanged', function() {
$(this).material_select();
});
ajax(element.val());
@NBoulfroy
NBoulfroy / SecurityController.php
Last active April 7, 2021 15:28
[Login system] A login system for Symfony with Doctrine without FosUserBundle #PHP #symfony4 #doctrine2
<?php
/**
* SecurityController.
*
* @Project : console_prospeneo
* @File : SecurityController.php
* @Author : BOULFROY Nicolas
* @Create : 2019/09/27
*/