Skip to content

Instantly share code, notes, and snippets.

@mablae
mablae / noise.sh
Created October 10, 2011 13:34 — forked from rsvp/noise.sh
noise : relaxing ambient Brown noise generator (cf. white noise) | Linux bash script using sox | CogSci notes
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2011-10-04
#
# _______________| noise : ambient Brown noise generator (cf. white noise).
#
# Usage: noise [minutes=59] [band-pass freq center=1786] [wave]
# ^minutes can be any positive integer.
# Command "noise 1" will display peak-level meter.
#
# Dependencies: play (from sox package)
@mablae
mablae / awesome-php.md
Last active December 15, 2015 00:09 — forked from ziadoz/awesome-php.md
Fix Url

Awesome PHP Libraries

A list of amazingly awesome PHP libraries that you should consider using (and some other shiny extras).

# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/ngram_test
curl -X PUT localhost:9200/ngram_test -d '
{
"settings" : {
"index" : {
"analysis" : {

We create an index with:

  • two filters: synonyms_expand and synonyms_contract
  • two analyzers: synonyms_expand and synonyms_contract
  • three text fields:
    • text_1 uses the synonyms_expand analyzer at index and search time
    • text_2 uses the synonyms_expand analyzer at index time, but the standard analyzer at search time
    • text_3 uses the synonyms_contract analyzer at index and search time

.

@mablae
mablae / gist:8cd3e5b0732c88b2a90a
Created January 26, 2016 02:07 — forked from fbrnc/gist:4550079
Make Behat/Mink create a screenshot when a test fails
<?php
class FeatureContext extends MinkContext {
/**
* Take screenshot when step fails.
* Works only with Selenium2Driver.
*
* @AfterStep
*/
@mablae
mablae / BlogPostHydrator.php
Last active July 19, 2016 15:03 — forked from Ocramius/BlogPostHydrator.php
Association lazy-loading with Zend\Db
<?php
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
use Zend\Stdlib\Hydrator\HydratorInterface;
class BlogPostHydrator implements HydratorInterface
{
/**
* @var HydratorInterface
*/
<?php
/**
* This is the clock interface. It's really simple, you write it once, use it anywhere.
* Cool extra things you can do:
* - have it return custom value objects
* - separate method for currentDate() without time part
*/
interface Clock
{
@mablae
mablae / RecordResultForm.php
Created November 18, 2016 12:30 — forked from webdevilopers/RecordResultForm.php
Dynamically add Elements to Symfony Form Collection without Data
<?php
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
final class RecordResult extends AbstractType
@mablae
mablae / Bootstrap.php
Created March 20, 2017 06:18 — forked from Ocramius/Bootstrap.php
ZF2 and Doctrine Data Fixtures testing environment
<?php
/**
* @author Marco Pivetta <ocramius@gmail.com>
*/
use Zend\ServiceManager\ServiceManager;
use Zend\Mvc\Service\ServiceManagerConfig;
use DoctrineORMModuleTest\Framework\TestCase;
use ContentTest\Util\ServiceManagerFactory;
use Zend\Loader\StandardAutoloader;
@mablae
mablae / SortableDirectoryIterator.php
Created June 23, 2017 20:30 — forked from DragonBe/SortableDirectoryIterator.php
Sortable DirectoryIterator based on last modification time
class SortableDirectoryIterator extends RecursiveDirectoryIterator
{
/**
* \ArrayObject
*/
private $dirArray;
public function __construct(string $path)
{
parent::__construct($path);