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 / 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 ()
@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 / 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">
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.turn(150);
@damienalexandre
damienalexandre / robot.js
Created December 6, 2012 17:25
roundead
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
@damienalexandre
damienalexandre / pony.sh
Created April 15, 2013 09:13
Facets example with ElasticSearch. Building a Filtered Query manualy (or via Elastica) is hell.
# for real, I have a mapping and my color is not "indexed"
curl -XPUT 'http://localhost:9200/pony_index_tmp' -d '
{
settings: {
number_of_shards: 1,
number_of_replicas: 0
}
}'
curl -XPOST "http://localhost:9200/pony_index_tmp/pony/1" -d '
@damienalexandre
damienalexandre / facets.php
Created May 28, 2013 08:30
Here is an example of how to get a query Filter from a list of Facet and user query (how to apply a facet on a query) with Elastica.
<?php
/**
* Return query Filter from a list of query string & allowed Facets
*
* @param array $query The user query (facet_name => query, facet_name => query...)
* @param array $allowed_facets An array of Elastica\Facet
*
* @return \Elastica\Filter\AbstractFilter (if multiple filters, they are combined in BoolAnd filter)
*/
private function getFacetsFilters($query, $allowed_facets)
<?php
public function indexAction($page)
{
$request = $this->container->get('request');
$routeName = $request->get('_route');
$f_r = $request->query->get('f_r');
curl -XDELETE 'http://localhost:9200/pony_index_tmp'
curl -XPUT 'http://localhost:9200/pony_index_tmp' -d '
{
"number_of_shards": 5,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"francais": {
curl -XDELETE 'http://localhost:9200/pony_index_tmp'
curl -XPUT 'http://localhost:9200/pony_index_tmp' -d '
{
"number_of_shards": 5,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"francais": {