Skip to content

Instantly share code, notes, and snippets.

View nautilebleu's full-sized avatar

Goulwen Reboux nautilebleu

View GitHub Profile
Client Twitter Kizlum
=====================
Features
--------
Must have
~~~~~~~~~
* Interface minimaliste (j'ai un MacBook, pas un iMac 27")
@nautilebleu
nautilebleu / gist:722377
Created November 30, 2010 20:51
How to capture patterns in glob style with Python 2.7 argparse
#!/usr/local/bin/python2.7
# coding=utf-8
import argparse
import pprint
from glob import glob
def main():
parser = argparse.ArgumentParser(description='Get some files according to a pattern')
parser.add_argument('pattern', type=file, action='store', nargs='+')
args = parser.parse_args()
@nautilebleu
nautilebleu / Gordini
Created January 20, 2011 08:48
Customize your shell (copy this in .bashrc)
### CURSOR ###
if [ "`id -u`" -eq 0 ]; then
CURSOR='#'
else
CURSOR='$'
fi
#### COLORS ###
black="\[\033[0;30m\]"
red="\[\033[0;31m\]"
green="\[\033[0;32m\]"
<?php
// in application/app/php/lib/app_manager/app_manager.class.php
class AppManager extends WebApplication
// ...
/**
* render the component
*/
public function render($template, $params)
{
$this->display_header($trail);
@nautilebleu
nautilebleu / gist:917210
Created April 13, 2011 08:47
Configuration as nested Python classes
class Conf:
class Map:
special_topics = {
'learning_objects': 'Objets d\'Apprentissage',
'authors': 'Auteur',
'footer_files': 'Barre de navigation',
}
class Package:
skeleton = 'conf/package/skeleton'
class Externals:
@nautilebleu
nautilebleu / gist:1099394
Created July 22, 2011 12:55
Custom sort of a files list
def _cmp(a, b):
if a[0].rfind(b[0]) == 0:
return -1
elif a[0].rfind(b[0]) == -1:
if a[0] < b[0] :
return -1
return 1
else:
return 0
@nautilebleu
nautilebleu / gist:1197771
Created September 6, 2011 14:54
Loading modules in Prestashop 1.4
<?php
// http://svn.prestashop.com/trunk/classes/Module.php
$file = trim(file_get_contents(_PS_MODULE_DIR_.$module.'/'.$module.'.php'));
if (substr($file, 0, 5) == '<?php')
$file = substr($file, 5);
if (substr($file, -2) == '?>')
$file = substr($file, 0, -2);
if (class_exists($module, false) OR eval($file) !== false)
{
@nautilebleu
nautilebleu / gist:1197819
Created September 6, 2011 15:13
Prévention des injections SQL dans Prestashop 1.1
<?php
// classes/Db.php
abstract class Db
{
//[…]
private static $_blacklist = 'LOAD_FILE|UNION|OUTFILE|DUMPFILE|ESCAPED|TERMINATED|CASCADE|INFILE|X509|TRIGGER|REVOKE';
//[…]
}
@nautilebleu
nautilebleu / gist:2905488
Created June 10, 2012 13:08
Activate.fish that works on OS X
# in /path/to/venv/bin/activate.fish
# replace
set -l oldpromptfile (tempfile)
#by
set -l oldpromptfile (mktemp -t tmp.oldpromptcontents.XXXX)
@nautilebleu
nautilebleu / gist:2905720
Created June 10, 2012 13:51
Fish config for Python and current git branch display on MacOS X with Homebrew
#
# Environment variables
#
# set PATH and PYTHONPATH to use Homebrew
set PATH /usr/local/Cellar /usr/local/bin /usr/local/sbin /usr/local/share/python $PATH
set PYTHONPATH /usr/local/lib/python $PYTHONPATH
set BROWSER 'open'
#