Skip to content

Instantly share code, notes, and snippets.

View ebuildy's full-sized avatar
🤟
South of France

Thomas Decaux ebuildy

🤟
South of France
View GitHub Profile
use Bizlunch\HelperBundle\Exception\ValidationException;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\ValidatorException;
class SupplyDataChain
{
private $value;
@ebuildy
ebuildy / a.sql
Created May 26, 2017 15:24
Get top N records of group by, with Facebook PrestoDB against Hive
SELECT * FROM (
SELECT *, RANK() OVER (PARTITION BY day, month ORDER BY hits DESC) AS row_number FROM (
SELECT country AS value, COUNT(*) AS hits, day, month
FROM hits_table
WHERE year = 2017
GROUP BY country, month, day
HAVING COUNT(*) > 1000
ORDER BY month, day, COUNT(*) DESC
)
)
@ebuildy
ebuildy / pom.xml
Created June 20, 2017 13:21
Use elastic4Hadoop with Spark
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.company.project</groupId>
<artifactId>TestSparkES</artifactId>
<version>1.0</version>
@ebuildy
ebuildy / create_model.scala
Last active July 9, 2017 19:35
Play with Naive Bayes classification with Apache Spark
import org.apache.spark.ml.feature._
import org.apache.spark.ml.Pipeline
import org.apache.spark.ml.linalg.Vector
import org.apache.spark.ml.classification._
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.expressions._
import org.apache.spark.sql.functions._
val categoryIndexer = new StringIndexer()
.setInputCol("category")
@ebuildy
ebuildy / pom.xml
Created September 14, 2017 09:38
Spring boot pom XML
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.datahub.suggest.api</groupId>
<artifactId>DatahubSuggestAPI</artifactId>
<version>1.0</version>
@ebuildy
ebuildy / ambari_services_check.py
Created September 25, 2017 11:16
Run Ambari service check for all services
import json, requests, os
from requests.auth import HTTPBasicAuth
cluster = os.environ["CLUSTER"]
url = "%s/api/v1/clusters/%s/services" % (os.environ["AMBARI_SERVER"], cluster)
respServices = requests.get(url, auth=HTTPBasicAuth(os.environ["AMBARI_LOGIN"], os.environ["AMBARI_PASSWORD"])).json()
<?php
$m = new \Memcached();
$m->addServer(getenv("MEMCACHED_HOST"), 11212);
var_dump($m->set('toto', ["toto" => "hello world!"], 3600));
var_dump($m->get('toto'));
@ebuildy
ebuildy / kibana_register_indices.sh
Created November 28, 2017 15:29
Register Kibana indices automatically
#!/usr/bin/env bash
# Usage: kibana_register_indices.sh http://localhost:9200 http://localhost:5601
ES=$1
KIBANA=$2
if [ -z "$ES" ];
then
ES=http://elasticsearch:9200
@ebuildy
ebuildy / pivot.sql
Created December 22, 2017 16:06
Wordpress wp-ml plugin: pivot term by languages
SELECT wp_icl_translations.trid,
group_concat(case when wp_icl_translations.language_code = "sp" then wp_terms.name end) as title,
group_concat(case when wp_icl_translations.language_code = "sp" then wp_term_taxonomy.term_taxonomy_id end) as sp,
group_concat(case when wp_icl_translations.language_code = "en" then wp_term_taxonomy.term_taxonomy_id end) as en
FROM wp_terms
INNER JOIN wp_term_taxonomy ON wp_term_taxonomy.term_id = wp_terms.term_id
INNER JOIN wp_icl_translations ON wp_icl_translations.element_id = wp_term_taxonomy.term_taxonomy_id AND wp_icl_translations.element_type = "tax_event-categories"
WHERE wp_term_taxonomy.taxonomy = "event-categories" AND wp_term_taxonomy.parent = 0
GROUP BY wp_icl_translations.trid
@ebuildy
ebuildy / gist:76c8d69eb2a0cb36022aefb0c5db17d7
Created January 20, 2018 11:59
Add view paths to translation:update Symfony command
<?php
namespace App\Core\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Translation\Catalogue\TargetOperation;
use Symfony\Component\Translation\Catalogue\MergeOperation;