Skip to content

Instantly share code, notes, and snippets.

Avatar
😀

Grégoire Pineau lyrixx

😀
View GitHub Profile
View php-bench-01.php
<?php
class baseDog
{
public $name;
}
class dog
{
protected $name;
@lyrixx
lyrixx / movieList.sh
Created Jun 4, 2011
Get a sorted list of your movies
View movieList.sh
#!/bin/bash
VIDEO_FOLDER=(
/PATH/TO/MOVIE1
/PATH/TO/MOVIE2
)
VIDEO_EXTENTION=(avi mkv mpg mpeg)
OUTPUT='movie_list.txt'
OUTPUT_TEMP=${OUTPUT}.temp
@lyrixx
lyrixx / gist:1087929
Created Jul 17, 2011
Twig String equals 0
View gist:1087929
Description
-----------
For twig, a string equals 0
Test script
-----------
{% set test = 'a string' %}
{% if test == 0 %}
test == 0
@lyrixx
lyrixx / base.twig
Created Jan 3, 2012 — forked from xavierbriand/base.twig
Twig training
View base.twig
{# manipulation des variables #}
{% set une_string = 'test' %}
<p>
{{ une_string }}
</p>
<hr />
View Project_Set_Node.php
<?php
class Project_Set_Node extends Twig_Node
{
public function __construct($name, Twig_Node_Expression $value, $lineno)
{
parent::__construct(array('value' => $value), array('name' => $name), $lineno);
}
public function compile(Twig_Compiler $compiler)
{
@lyrixx
lyrixx / gist:1625927
Created Jan 17, 2012
PHP Upload file - upload_max_filesize
View gist:1625927
<html>
<?php
var_dump($_FILES);
if (isset($_FILES['test'])) {
$filetemp = $_FILES['test']['tmp_name']['file01'];
echo 'file tmp location : '.$filetemp.'<br />';
echo 'is file on disk ? : '.file_exists($filetemp).'<br />';
}
View push-git-modules.sh
MODULES=(
plugins/ftAttractionPlugin
plugins/ftCalendarPlugin
plugins/ftCommonPlugin
plugins/ftContentPlugin
plugins/ftFormPlugin
plugins/ftHotelRestaurantPlugin
plugins/ftListingPlugin
plugins/ftMasterCatalogPlugin
plugins/ftNewsTipsPlugin
@lyrixx
lyrixx / fab.py
Created May 29, 2012
Fabfile, promp with a list
View fab.py
i = 0
for dump in dumps:
print cyan('%(i)s => %(dump)s' % {'i':i, 'dump':dump})
i += 1
def validateDumpNumber(arg):
if i < int(arg):
raise Exception('You have to choose an int among [0-%(i)s], not %(arg)s' % {'i':i, 'arg':arg})
return arg
@lyrixx
lyrixx / Symfony-finder-bench.txt
Created Aug 1, 2012
Symfony-finder-bench.txt
View Symfony-finder-bench.txt
Starting benchmark, it takes several minutes...
1010 files
110 directories
10 iterations
18 cases
2 adapters
@lyrixx
lyrixx / getRandomString.php
Created Aug 7, 2012
Generate a random string
View getRandomString.php
<?php
$list = array_merge(range('a', 'z'), range('A', 'Z'), range(0, 9));
function getRandomString($length, $list) {
$str = array_fill(0, $length, null);
$str = array_map(function($item) use ($list) { return $list[array_rand($list)]; }, $str);
return join($str, '');
}