Skip to content

Instantly share code, notes, and snippets.

public function get($id)
{
$es = ConnectionManager::get(self::defaultConnectionName());
$search = new Search($es);
$search->addIndex('indications');
$result = $search->search($id);
return new Indication($result->getResults()[0]->getSource());
<?php
$baseDir = dirname(dirname(__FILE__));
return array (
'plugins' =>
array (
'Migrations' => $baseDir . '/vendor/cakephp/migrations/',
'Bake' => $baseDir . '/vendor/cakephp/bake/',
'DebugKit' => $baseDir . '/vendor/cakephp/debug_kit/',
),
);
@real34
real34 / ApacheErrors.json
Last active August 29, 2015 14:13
Dashboards Kibana
{
"title": "Apache errors",
"services": {
"query": {
"list": {
"0": {
"query": "type:apache_error",
"alias": "",
"color": "#7EB26D",
"id": 0,
{"initialState":{"stores":{"EventStore":{"events":[{"name":"CONTENT_CHANGED","payload":{"content":"C"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ce"}},{"name":"CONTENT_CHANGED","payload":{"content":"Cec"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci "}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci e"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci es"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est "}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est u"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un "}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un m"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un me"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un mes"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un mess"}},{"nam
@real34
real34 / store_generator.php
Last active August 29, 2015 14:06
Generates a valid CSV file for french stores for the Magento Store Locator extension. http://www.magentocommerce.com/magento-connect/store-locator-extension-1.html
<?php
require_once __DIR__ . '/vendor/autoload.php';
$faker = Faker\Factory::create('fr_FR');
$output = fopen('php://output', 'w+');
$headers = [
'storelocator_id',
'name',
'status',
<?php
function fixFilenameEncoding($filename) {
return mb_convert_encoding($filename, 'ISO-8859-2', 'UTF-8');
}
$zip = new ZipArchive;
$res = $zip->open('./elephant.zip', ZipArchive::CREATE);
if ($res === true) {
$filename = 'éléphant-man2.txt';
Plugin::load('Croogo', ['bootstrap' => true]);
@real34
real34 / csv.php
Created February 19, 2014 14:49
Filter CSV files in a quick'n'dirty way
<?php
$dir = __DIR__;
function isValid($product) {
return !empty($product[2]);
}
if (($productsFile = fopen($dir . '/products2.csv', "r")) !== FALSE) {
$missingSkus = array_map('trim', file($dir . '/missing-images-sku.csv'));
@real34
real34 / keys.php
Created December 21, 2013 08:10
Approche naïve de réponse à un question sur la ML AFUP : "Bonjour, je cherche un moyen propre et générique pour remplacer les clés d'un tableau associatif par une autre en gardant exactement la même structure pour la sortie."
<?php
$initial = array(
array(
'idcom' => 2,
'idcatalog' => 1,
'pseudo_com' => 'babar'
),
array(
'idcom' => 1,
'idcatalog' => 1,
@real34
real34 / score.exs
Last active December 30, 2015 04:59 — forked from chadrien/score.rb
# encoding: UTF-8
defmodule Score do
@missed "-"
@spare "/"
@strike "X"
def total(rolls) when is_bitstring(rolls) do
rolls |> String.codepoints |> total