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
@ebuildy
ebuildy / TranslatorAwareTrait.php
Created January 20, 2018 12:17
Make your class translate ready ! Symfony 4 translate aware trait.
namespace App\Core\Utils\Services;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
use Symfony\Component\Translation\TranslatorInterface;
trait TranslatorAwareTrait
{
/**
* @var TranslatorInterface
*/
@ebuildy
ebuildy / DateTimeType.php
Created January 22, 2018 16:30
Symfony DateTime form type, with 2 text input widgets
<?php
namespace App\Core\Form\Type;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer;
use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer;
use Symfony\Component\Form\Extension\Core\Type\TextType;
@ebuildy
ebuildy / README.md
Created February 6, 2018 20:19
Use Socat to support multiple backend with jwilder/nginx-proxy

Problem from nginx-proxy/nginx-proxy#59, you cannot setup multiple backend for one container.

The solution here, is to use socat as an HTTP proxy.

My use case is "I setup a Apache Spark cluster, I want to access to web UI of master and worker".

@ebuildy
ebuildy / search.json
Last active April 16, 2018 18:42
Calcul cumulative sum metric (such as elasticearch node stat query_total) difference between 2 timestamps.
{
"source" : {
"size": 0,
"query": {
"query_string": {
"query": "@timestamp:[{{start_date}}:00+02:00 TO {{end_date}}:59+02:00] AND data.attributes.master:false"
}
},
"aggs": {
"nodes": {
@ebuildy
ebuildy / 1st try
Last active September 17, 2018 16:17
strace of couchbase moxi proxy - 3 nodes cluster - "GET test_1" operation
[pid 219] accept(41, {sa_family=AF_INET, sin_port=htons(45182), sin_addr=inet_addr("192.168.160.1")}, [16]) = 43
[pid 219] sendto(32, "\0", 1, 0, NULL, 0) = 1
[pid 273] recvfrom(31, "\0", 1, 0, NULL, NULL) = 1
[pid 273] recvfrom(43, "\200\r\0\6\0\0\0\0\0\0\0\6\0\1\0\0\0\0\0\0\0\0\0\0test_1\200\n\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0", 2048, 0, NULL, NULL) = 54
[pid 273] socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 51
[pid 273] connect(51, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.0.0.11")}, 16) = 0
[pid 273] sendmmsg(51, {{{msg_name(0)=NULL, msg_iov(1)=[{"\240o\1\0\0\1\0\0\0\0\0\0\7server3\3poc\0\0\1\0\1", 29}], msg_controllen=0, msg_flags=0}, 29}, {{msg_name(0)=NULL, msg_iov(1)=[{"\274\345\1\0\0\1\0\0\0\0\0\0\7server3\3poc\0\0\34\0\1", 29}], msg_controllen=0, msg_flags=0}, 29}}, 2, MSG_NOSIGNAL) = 2
[pid 273] recvfrom(51, "\274\345\201\200\0\1\0\0\0\0\0\0\7server3\3poc\0\0\34\0\1", 2048, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("127.
@ebuildy
ebuildy / ElasticsearchMockClient.java
Last active October 1, 2018 15:24
elasticsearch mockup server
package com.qwant.datahub.djobi.test;
import org.json.JSONArray;
import org.json.JSONObject;
import org.mockserver.client.server.MockServerClient;
import org.mockserver.model.HttpRequest;
import org.mockserver.model.HttpResponse;
import org.mockserver.verify.VerificationTimes;
import java.util.ArrayList;
@ebuildy
ebuildy / kafka.feature
Created October 29, 2018 11:01
Python Behave steps to func test Apache Kafka
Scenario: send JSON to Kafka with Spark
Given kafka topic
When I run pipeline "output_kafka_spark.yml"
Then I must see 3 messages from kafka
public void setLength(int newLength) {
if (newLength < 0)
throw new StringIndexOutOfBoundsException(newLength);
ensureCapacityInternal(newLength);
if (count < newLength) {
Arrays.fill(value, count, newLength, '\0');
}
count = newLength;
@ebuildy
ebuildy / README.md
Last active January 22, 2019 09:13
Simple & pure JS sticky

Will stick vertically element with class "sticky-item".

Usage is for Table > sticky cells, so this code check element left to create sticky groups.

@ebuildy
ebuildy / build.gradle
Last active January 23, 2019 11:23
Gradle task to create release note
plugins {
...
id "org.ajoberstar.grgit" version "3.0.0"
}
task createReleaseReportFile() {
doLast {
file("$projectDir/src/main/resources/release_note.properties").text = """## Automated generated by Gradle ##