Skip to content

Instantly share code, notes, and snippets.

View sglessard's full-sized avatar
🏠
Working from home

Simon Guillem-Lessard sglessard

🏠
Working from home
View GitHub Profile
@sglessard
sglessard / gist:8479368
Created January 17, 2014 19:00
Strip HTML tags (BBEdit) regexp
<[^>]*>
Process: httpd [1432]
Path: /usr/sbin/httpd
Identifier: httpd
Version: 786
Code Type: X86-64 (Native)
Parent Process: httpd [1431]
Responsible: httpd [1431]
User ID: 70
PlugIn Path: /usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/apcu.so
<form action="" method="post" novalidate="novalidate">
@sglessard
sglessard / gist:7101357
Created October 22, 2013 14:05
SGLFLTS - Doctrine2 cascade example to fetch all entities
// Init Method
$query = $this->createQueryBuilder('b')
->select('b')
->orderBy('b.number', 'DESC');
// WRONG Query
// Was feching task's works with additional SQL Queries (task's works loop in twig tmpl)
$query = $this->retrieve(true)
@sglessard
sglessard / Import-data.php
Created January 25, 2013 15:46
Use raw SQL queries with doctrine2 (from the symfony2 web directory)
<?php
/*
* Import data from old application
* http://docs.doctrine-project.org/en/2.0.x/reference/configuration.html
*/
require '../vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', '../vendor/doctrine/common/lib');
$classLoader->register();
@sglessard
sglessard / SGL\FLTSBundle\Controller\ReportController.php
Last active December 11, 2015 12:29
SGLFLTS - DateTime : tomorrow and yesterday (symfony2)
// string input ($date = '2013-01-01';)
$day = \DateTime::createFromFormat('Y-m-d', $date);
$date_errors = \DateTime::getLastErrors();
if ($date_errors['warning_count'] + $date_errors['error_count'] > 0) {
throw $this->createNotFoundException('Input date does not exist.');
}
$next_day = clone $day;
if (!isset($_SERVER['PHP_AUTH_USER'])
|| $_SERVER['PHP_AUTH_USER'] != 'user' || $_SERVER['PHP_AUTH_PW'] != 'passwd')
{
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authentification requise.';
exit;
}