Skip to content

Instantly share code, notes, and snippets.

View liemle3893's full-sized avatar

Liem Le Hoang Duc liemle3893

View GitHub Profile
@liemle3893
liemle3893 / Search-As-You-Type.elas.MD
Last active January 1, 2018 19:40
Elastic Analyser for auto complete search
  1. Remember to install 'analysis-icu' plugins first
  2. Best practices: always use alias (as you can see my stupid settings has 2 at the end that mean I already had 1 =))
  3. For case where you need to support emoticon like ❤️. Simply preprocess it to :heart: (use 3rd library or mapping char filter by elasticsearch)
    1. As of 2018 (actually on Dec 2016) Elasticsearch has provided plug-in for this feature.

analyser.json

{
    "360live_ext_2": {
@liemle3893
liemle3893 / HTML-Form-And-JSON.MD
Created April 10, 2018 04:56
Set JSON to HTML form and get JSON back from Form.

Require: JQuery

How to use?

  • Open the link above.
  • Click on Fill button to fill data from json to form.
  • Click on Get button to get data from form as json (will open an alert dialog).
  • Click on Reset button to reset data form.
  • Edit json object in Javascript box as your need and test.
@liemle3893
liemle3893 / ObjectReader.java
Created April 20, 2019 16:08
Parse Object into Map and vice versa (Only support primitive types)
import com.google.common.base.Strings;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import wpl.streaming.consumer.stream.util.reflect.annotation.Ignore;
@liemle3893
liemle3893 / Git-workflow.MD
Created May 12, 2019 16:39
My git workflow

My developer story: git workflow

I use git-flow for all of my projects.

  • Master branch: Run on Production Environment
    1. This branch was protected: only repo owner can push/accept pull request.
  • Develop branch: Run on Development/Staging environment
    1. Code that pass QC will be go on to staging
    2. Create pull request to master after QA.
  • Hotfix branch: must be base on master
@liemle3893
liemle3893 / User-Role-Privilege.md
Created February 7, 2018 06:44
Production ready User-Role-Privilege problem.

Privilege.java

    // Privilege.java
    import javax.persistence.*;
    import java.io.Serializable;
    import java.util.Set;
    
    
    @Setter
    @Getter
group "api" {
count = "1"
task "demo_api" {
driver = "docker"
config {
image = "saboteurkid/go-demo:latest-debug"
}
}
}
task "demo_api" {
driver = "docker"
config {
image = "saboteurkid/go-demo:latest-debug"
}
}
service {
name = "go-demo"
port = "http"
address_mode = "driver"
tags = [
"traefik.enable=true",
"traefik.http.middlewares.strip-go-demo.stripprefix.prefixes=/go-demo",
"traefik.http.routers.go-demo.entrypoints=http",
"traefik.http.routers.go-demo.rule=PathPrefix(`/go-demo`)",
"traefik.http.routers.go-demo.middlewares=strip-go-demo"
scrape_configs:
- job_name: 'consul_sd'
consul_sd_configs:
- server: '{{ env "NOMAD_IP_http"}}:8500'
services: []
relabel_configs:
- source_labels: [__meta_consul_service_metadata_prometheus_enable]
regex: true
action: keep
- source_labels: [__meta_consul_service_metadata_prometheus_path]
[SERVICE]
Flush 1
Log_Level info
Parsers_File parsers.conf
[INPUT]
Name tail
# Log file will be placed at: /tmp/fluent-bit/logs/<app_name>/<file_name>.log
Path /tmp/fluent-bit/logs/*/*.log
Path_Key LogSource