Skip to content

Instantly share code, notes, and snippets.

View alOneh's full-sized avatar

Alain Hippolyte alOneh

  • @sensiolabscc
  • Paris, France
View GitHub Profile
<?php
// tests/App/ReflectionTrait.php
namespace App\Tests;
trait ReflectionTrait
{
/**
* @param $object
* @param $methodName
* @param array $parameters
@alOneh
alOneh / DashboardApp.vue
Last active December 11, 2022 19:05
Example of a Vue.js app integrated in a twig template
<template>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="info-box">
<span class="info-box-icon bg-green"><i class="fa fa-users"/></span>
<div class="info-box-content">
<span class="info-box-text">Active users</span>
<span class="info-box-number">{{ usersCount || 0 }}</span>
</div>
</div>
@alOneh
alOneh / User.php
Created March 7, 2019 17:03
How to serialize User information in session
<?php
class User implements UserInterface, \Serializable
{
/**
* {@inheritdoc}
*/
public function serialize(): string
{
return serialize([$this->id, $this->username, $this->password]);
@alOneh
alOneh / CsvReader.php
Created January 31, 2019 10:50
A CsvReader with utf8 encoding
<?php declare(strict_types=1);
namespace App\CSV;
use League\Csv\Reader;
use League\Csv\Statement;
use voku\helper\UTF8;
class CsvReader
{
<?php
namespace App\Faker\Provider;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumber;
use libphonenumber\PhoneNumberUtil;
use libphonenumber\PhoneNumberFormat;
class PhoneNumberProvider
@alOneh
alOneh / twig_templates_used.sh
Last active February 14, 2018 16:35
Little script to retrieve the templates used in you Symfony App
#!/bin/bash
# escape the slash in document root
DOCUMENT_ROOT=\/var\/www\/html\/
SYMFONY_ENV=dev
# The full path is written by the Twig compiler, generally at the end of the cache file in the getSourceContext() method
grep -RhoP "${DOCUMENT_ROOT}.*\.html\.twig" app/cache/${SYMFONY_ENV}/twig/ | grep -v vendor
@alOneh
alOneh / Version00000000000000.php
Created September 15, 2016 09:36
Migration 0 exemple
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
class Version00000000000000 extends AbstractMigration
{
public function up(Schema $schema)
@alOneh
alOneh / www.example.com.conf
Created November 6, 2014 13:45
Symfony 1.4 Nginx configuration
server {
listen 80;
root /var/www/example.com/web;
index index.php;
server_name example.com.dev;
access_log /var/log/nginx/$host.access.log;
error_log /var/log/nginx/$host.error.log;
<?php
$zip = new ZipArchive();
$t = $zip->open('MA.20130715-174538.ZIP');
$fp = $zip->getStream('MA.XML');
while (!feof($fp)) {
echo fread($fp, 4096);
}
fclose($fp);
$zip->close();
@alOneh
alOneh / gist:2953365
Created June 19, 2012 10:10
RegexConverter for Flask app
# source http://stackoverflow.com/questions/5870188/does-flask-support-regular-expressions-in-its-url-routing
from flask import Flask
from werkzeug.routing import BaseConverter
app = Flask(__name__)
class RegexConverter(BaseConverter):
def __init__(self, url_map, *items):
super(RegexConverter, self).__init__(url_map)
self.regex = items[0]