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 / 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
@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 / jenkins.your-domain.com
Created May 11, 2018 18:49
Jenkins subdomain - NginX config. ( /etc/nginx/sites-available/jenkins.your-domain.com )
server {
listen 80;
server_name jenkins.your-domain.com;
location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
@liemle3893
liemle3893 / Docker-multistage-example.MD
Last active November 3, 2023 14:52
Docker Multistage + Spring Boot = Smaller Container Sized

docker-multi-stage

Spring Boot + Docker Multistage = Smaller container size

Use can use prebuild version by using:

$ docker run -d -p 8080:8080 saboteurkid/smaller-spring:1.0

Wait for docker to pull and up. Then jump to step #6

1. Clone example project from Spring Boot repository

@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
job "demo" {
datacenters = [
"dc1"]
group "api" {
count = "1"
task "demo_api" {
driver = "docker"
config {
image = "saboteurkid/go-demo:latest-debug"
port_map {
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"
}
}