Skip to content

Instantly share code, notes, and snippets.

View damienalexandre's full-sized avatar
❤️
I̴͍͋ ̶͉͠Ḻ̸̅O̸͈̚V̷̨͒E̸̛ ̵̲̓Ü̷Ṅ̴̩I̴̳͑C̵͉͂O̷̹͗D̸̤̃È̴̪

Damien Alexandre damienalexandre

❤️
I̴͍͋ ̶͉͠Ḻ̸̅O̸͈̚V̷̨͒E̸̛ ̵̲̓Ü̷Ṅ̴̩I̴̳͑C̵͉͂O̷̹͗D̸̤̃È̴̪
View GitHub Profile
@damienalexandre
damienalexandre / exception.html.twig
Created August 5, 2012 15:20
A custom exception file with GIF instead of scary ghost
<div class="sf-exceptionreset">
<div class="block_exception">
<div class="block_exception_detected clear_fix">
<div class="illustration_exception">
<img alt="Exception detected!" src="http://damienalexandre.fr/lab/random-fail" style="width:145px" />
</div>
<div class="text_exception">
<div class="open_quote">
@damienalexandre
damienalexandre / patch.diff
Created May 22, 2012 13:32
How to use the translationClass option in the default Translatable repository
diff --git a/lib/Gedmo/Translatable/Entity/Repository/TranslationRepository.php b/lib/Gedmo/Translatable/Entity/Repository/TranslationRepository.php
index 50b106e..2451fd0 100644
--- a/lib/Gedmo/Translatable/Entity/Repository/TranslationRepository.php
+++ b/lib/Gedmo/Translatable/Entity/Repository/TranslationRepository.php
@@ -64,9 +64,14 @@ class TranslationRepository extends EntityRepository
$entityClass = $wrapped->getMetadata()->name;
$translationMeta = $this->getClassMetadata(); // table inheritance support
+
+ // Get the custom translationClass
@damienalexandre
damienalexandre / jhintSpec.js
Created March 24, 2012 18:14
Jasmine Spec which run a list of files against JSHint
/**
* This spec run some files against JSHint
*
* Inspired by https://github.com/bkeepers/lucid/blob/master/spec/javascripts/z_jshint_spec.js
* @author bkeepers
* @author dalexandre
*
* @require JSHint, jQuery
*/
describe('JSHint', function ()
socket.on('batchmove', function(data) {
for (var i = 0; i < data.length; i++) {
socket.emit('move', {x: data[i].x, y: data[i].y, id: myId});
}
});
socket.on('batchmove', function(data) {
for (var i = 0; i < data.length; i++) {
socket.emit('move', {x: data[i].x, y: data[i].y, id: myId});
}
});
@damienalexandre
damienalexandre / gist:1507857
Created December 21, 2011 21:47
Web Storage API
// Stocker une valeur
sessionStorage.setItem('key', 'value');
localStorage.setItem('key', 'value');
// Récupérer une valeur
var item = sessionStorage.getItem('key');
var item = localStorage.getItem('key');
// Supprimer une valeur
sessionStorage.removeItem('key');
@damienalexandre
damienalexandre / function.php
Created October 20, 2011 10:13
Run a shell command in backgroud using PHP
<?php
/**
* Run a command in background (Windows and linux \o/)
*
* @param wait wait for the command to terminate
* @author dalexandre
* @author jbenoist
* @since 24/02/2009
* @update 19/08/2009
* @param String $cmd
@damienalexandre
damienalexandre / tool.php
Created October 3, 2011 09:47
Download large file from the web via php
<?php
/**
* Download a large distant file to a local destination.
*
* This method is very memory efficient :-)
* The file can be huge, PHP doesn't load it in memory.
*
* /!\ Warning, the return value is always true, you must use === to test the response type too.
*
* @author dalexandre
@damienalexandre
damienalexandre / src_Dalexandre_MyBundle_Pagerfanta_Adapter_DoctrineORMNativeQueryAdapter.php
Created August 23, 2011 08:29
This file is not part of the Pagerfanta package. We hack the Pagerfanta to allow Doctrine nativeQuery pagination.
<?php
/*
* This file is not part of the Pagerfanta package.
* We hack the Pagerfanta to allow Doctrine nativeQuery pagination.
*/
namespace Dalexandre\MyBundle\Pagerfanta\Adapter;
use Doctrine\ORM\QueryBuilder;
@damienalexandre
damienalexandre / face-capture-timed.sh
Created June 6, 2011 13:16
Take a webcam capture, store it and push a notification.
#!/bin/bash
DATE=`date +%s`
FILENAME="/home/username/CamStream/$DATE.jpeg"
# Call the streamer
streamer -f jpeg -o $FILENAME
# Display a user notification
DISPLAY=:0.0 notify-send -u 'low' -i $FILENAME "Cheese!" "Stream saved!"