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 / santa.php
Created October 31, 2014 10:23
Secret Santa matcher with PHP Generator
<?php
/**
* Secret Santa Generator - powered by PHP Generators for the lolz.
*/
$players = [
"xx@jolicode.com",
"spam@jolicode.com",
"nop@jolicode.com",
"foo@jolicode.com",
<?php
class Answer extends BaseAnswer
{
public function preSave($event)
{
if ($this->getIsTrue())
{
$q = Doctrine_Query::create()
->update('Answer')
@damienalexandre
damienalexandre / New way to set the encoder.
Created January 23, 2011 15:50
Playing with the Symfony2 serializer
<?php
// Inside your action
$this->serializer = new \Symfony\Component\Serializer\Serializer();
$this->serializer->addNormalizer(new \Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer());
$this->serializer->setEncoder('xml', new \Symfony\Component\Serializer\Encoder\XmlEncoder());
return $this->createResponse($this->serializer->encode($page, 'xml'), 200, array('Content-Type' => 'application/xml'));
@damienalexandre
damienalexandre / WhateverToolkit.class.php
Created February 16, 2011 10:52
Fix the 250 chars memcached cache key limit on symfony 1
<?php
/**
* Set cache_namespace_callable: [ pouet, generateShortenedCacheKey ] in your settings.yml
* Then the symfony cache key is shortened by MD5
*
* @author dalexandre
* @see sfViewCacheManager::generateCacheKey
* @param sfViewCacheManager $sfViewCacheManager
* @return string
*/
@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!"
@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 / 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');
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 / 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 ()