Skip to content

Instantly share code, notes, and snippets.

View ludofleury's full-sized avatar
🐼
Yay

Ludovic Fleury ludofleury

🐼
Yay
View GitHub Profile
<?php
/*
* $Id: UnitOfWork.php 7684 2010-08-24 16:34:16Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
@ludofleury
ludofleury / FileRelation.class.php
Created December 18, 2010 17:19
lib/model/doctrine/FileRelation.class.php Relational model between object model and file model Implement LooseCoupling doctrine behavior concept from Christian Schaefer.
<?php
/**
* FileRelation
*
*
* @package shop
* @subpackage model
* @author Christian Schaefer <caefer@ical.ly>
* @author Ludovic Fleury <ludovic.fleury@w3brothers.com>
@ludofleury
ludofleury / Admin gen on multiple primary keys Model.
Created January 30, 2011 20:54
Ever dream to use admin-gen (symfony 1.4 + Doctrine 1.2) with a Model using composite primary keys ? Fast & furious tips for the routing :
app/routing.yml
In this example, my Model is identified by A string + an id.
That's why I specified requirements.
attached_file:
class: sfDoctrineRouteCollection
options:
model: AttachedFile
module: attachment
prefix_path: /attachment
// Ouvre le premier lien enfant de l'élément cible
// Reproduit le comportement des navigateurs (ctrl ou cmd ou middleclick = nouvel onglet)
$('.line-click').live('click', function(e){
e.stopPropagation();
href = $(this).children('a:first').attr('href');
if (e.ctrlKey || e.metaKey || e.which == 2) {
window.open(href);
} else {
window.location = href;
}
@ludofleury
ludofleury / gist:828193
Created February 15, 2011 20:36 — forked from tyx/gist:816180
// Ouvre le premier lien enfant de l'élément cible
// Reproduit le comportement des navigateurs (ctrl ou cmd ou middleclick = nouvel onglet)
$('.line-click').live('click', function(e){
e.stopPropagation();
href = $(this).children('a:first').attr('href');
if (e.ctrlKey || e.metaKey || e.which == 2) {
window.open(href);
} else {
window.location = href;
}
@ludofleury
ludofleury / sdzDoctrineGenerateMigrationsDiffTask.php
Created March 22, 2011 11:25
Custom migrations using schema.yml revision.
<?php
class sdzDoctrineGenerateMigrationsDiffTask extends sfDoctrineBaseTask
{
/**
* @see sfTask
*/
protected function configure()
{
$this->addOptions(array(
@ludofleury
ludofleury / routing.yml
Created June 6, 2011 08:16
Use multiple routing files.
## Default rules ===============================================================
homepage:
url: /
param:
module: home
action: index
sf_format: html
<?php foreach(glob(dirname(__FILE__).DIRECTORY_SEPARATOR.'routing'.DIRECTORY_SEPARATOR.'*.yml') as $yml){ require($yml); echo "\n"; } ?>
anonymous
anonymous / gist:1292475
Created October 17, 2011 12:01
public function getHandInfo() {
$straight_courant = 0;
foreach($this->hcard as $hcard) {
if($hcard > 0) {
if($hcard == '2') {
$this->pair++;
}
elseif($hcard == '3') {
$this->threeKind++;
@jakzal
jakzal / deploy.rb
Created October 25, 2011 11:41
parameters.yml configuration during capifony deployment for Symfony2
set :shared_files, [app_path + "/config/parameters.yml"]
namespace :symfony do
namespace :configure do
def shared_parameters_path
"#{shared_path}/#{app_path}/config/parameters.yml"
end
def app_parameters_path
"#{latest_release}/#{app_path}/config/parameters.yml"
@ludofleury
ludofleury / pre-commit
Created November 18, 2011 10:15
Symfony Git pre-commit hook a little more verbose based on vendor/Symfony/check_cs
#!/usr/bin/env php
<?php
/*
* Coding Standards (a.k.a. CS)
*
* This script is designed to clean up the source files and thus follow coding
* conventions.
*
* @see http://symfony.com/doc/2.0/contributing/code/standards.html
*