Skip to content

Instantly share code, notes, and snippets.

@real34
real34 / breadcrumbs.php
Created April 8, 2011 14:30
CakePHP : Breadcrumb Helper, allows to create and display breadcrumbs in a readable manner.
<?php
/**
* Breadcrumbs helper
* Allows to generate and display breadcrumbs with a convenient syntax
*
* It uses a <ul><li> syntax but can be extended and protected method overriden to
* generate the markup adapted to your situation
*
*/
class BreadcrumbsHelper extends AppHelper {
@real34
real34 / index.php
Created October 20, 2011 09:16
PHP : Simple mutex par fichiers, fonctionnant en CLI mais pas via Apache (désolé pour la variable globale qui pique les yeux ;))
<?php
$rootPath = realpath(dirname(__FILE__) . '/../') . '/';
function takeMutex($name) {
global $rootPath;
$filename = $rootPath . 'tmp/cron_' . $name . '.lock';
if (($handle = @fopen($filename, 'x')) === false) {
die('Une autre instance de cette tâche est en cours d\'exécution, ou impossible de créer le fichier "' . $filename . '", vérifiez les droits d\'écriture !');
}
@real34
real34 / memory_usage.php
Created November 1, 2011 06:59
PHP : A simple function to display the current memory usage
<?php
// @see http://fr2.php.net/manual/en/function.mb-convert-encoding.php#103300
function memory_usage() {
$mem_usage = memory_get_usage(true);
if ($mem_usage < 1024) {
$mem_usage .= ' bytes';
} elseif ($mem_usage < 1048576) {
$mem_usage = round($mem_usage/1024,2) . ' kilobytes';
} else {
$mem_usage = round($mem_usage/1048576,2) . ' megabytes';
@real34
real34 / WIO_Gmap.csv
Created November 18, 2011 14:32
Magento : French translation of Magento's Google Map Locations extension (from webideaonline)
Gmap Locations Configuration Configuration de Gmap Locations
Google Map API key Clé d'API Google Map
You can get it here http://code.google.com/apis/maps/signup.html. eg.ABQIAAAA8Y84y7AfnkshoyWtI5fyShQikMkOUW3vCdojO3o0Jxipwb7AThTTtKgn8GKXuPGojAtR759m5cLSww Vous pouvez en obtenir une ici http://code.google.com/apis/maps/signup.html. ex:ABQIAAAA8Y84y7AfnkshoyWtI5fyShQikMkOUW3vCdojO3o0Jxipwb7AThTTtKgn8GKXuPGojAtR759m5cLSww
Search Configuration Configuration de la Recherche
Show Search block Afficher le bloc de Recherche
Show Search Radius Circle Afficher le Cercle du Rayon de Recherche
in search mode shows colored circle for searched radius on map lors du mode de recherche afficher un cercle de couleur pour le rayon recherché sur la carte
Search Circle Radius Color Couleur du Cercle du Rayon de Recherche
Front End Title Titre Front End
You can leave it blank if not need Laissez vide si vous n'en n'avez pas besoin
@real34
real34 / CakePHP-Recipe.rb
Created February 23, 2012 13:58
Capistrano : CakePHP1.x deployment recipe
##
# CakePHP deployment recipe
# TODO Implement a way to revert migrations given the map.php files of a previous release
# TODO Make a difference between tmp files and others
# TODO Give a way to the application to define its own custom directories
##
_cset (:app_symlinks) { [
"/webroot/cache_css", "/webroot/cache_js",
"/tmp"
] }
@real34
real34 / delayedCall.js
Created March 14, 2012 14:01
Javascript : DelayedCall - prevent a callback to be triggered before a delay of inactivity
/**
* Class allowing to call a method only after a specific delay if no other call was made
* It is useful to prevent triggering the same callback multiple times quickly. For instance
* ajax calls on keyup. It introduces a delay before triggering the callback
*
* Usage:
* var refreshResults = new DelayedCall(1000, function() { alert('Mouse not moved for 1 second'); })
* $('body').mousemove(function() { refreshResults.trigger(); })
*
* @param delay Inactivity delay in millisecond before triggering the callback
@real34
real34 / email.php
Created March 15, 2012 08:45
CakePHP : 1.3 - Email task to use the Email component from a Shell
<?php
App::import('Core', 'Controller');
App::import('Component', 'Email');
/**
* Task permitting to use the Email component from a shell
* @see http://bakery.cakephp.org/articles/view/emailcomponent-in-a-cake-shell
*/
class EmailTask extends Shell {
/**
* Controller class
@real34
real34 / CakePHP-Recipe.rb
Created April 5, 2012 12:29
Capistrano : CakePHP2.x deployment recipe
##
# CakePHP2.x deployment recipe
# TODO Implement a way to revert migrations given the map.php files of a previous release
# TODO Make a difference between tmp files and others
# TODO Give a way to the application to define its own custom directories
##
_cset (:app_symlinks) { [
"/webroot/cache_css", "/webroot/cache_js",
"/tmp"
] }
@real34
real34 / HttpAuth-Recipe.rb
Created April 5, 2012 12:33
Capistrano : Http Authentification recipe - Generates htaccess/htpasswd Apache protection for your project
##
# HTTP Authentification deployment Recipe
# => Add htaccess password protection when deploying, with the correct htpassword file for the passed users
##
_cset (:http_auth_users) {[
["admin", "password"]
]}
_cset (:http_auth_path) { "" } # Path of the directory to add http auth, from the release root
namespace :httpAuth do
@real34
real34 / ActionsHelper.php
Created April 12, 2012 08:16
CakePHP2.x : Twitter bootstrap base for projects
<?php
/**
* Action Helper
* Allows to generate simple CRUD links for a given object and customize its rendering
* It only works for default baked urls
*
* Usage:
* <code>
* $this->Actions->setActionsOptions($order['Order']['id'], true);
* echo $this->Actions->view();