Skip to content

Instantly share code, notes, and snippets.

View hungbang's full-sized avatar
🏠
Working from home

Harry B. hungbang

🏠
Working from home
View GitHub Profile
@hungbang
hungbang / clean-docker.sh
Created August 8, 2019 04:13 — forked from marioharper/clean-docker.sh
Stop all docker processes, remove all containers, remove all images
# stop all processes
docker stop $(docker ps -aq)
# remove all containers
docker rm $(docker ps -aq)
# remove all images
docker rmi $(docker images -aq)
# delete all volumes
@hungbang
hungbang / java_conventions.md
Created September 23, 2019 02:08 — forked from goldbattle/java_conventions.md
Java Coding Conventions

Coding Conventions

This file will cover important coding practices that are important to stress when coding this program. Listed below are some of the more important details that should be stressed. Each programmer has his/her own way to deliver code. The importance of having similar coding conventions throughout this program are listed below.

  • 80% of the time spent on a piece of software goes to maintenance.
  • Hardly any software is maintained for its whole life by the original author.
  • Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly.
  • If you ship your source code as a product, you need to make sure it is as well packaged and clean as any other product you create.
@hungbang
hungbang / preloading-data-redux.md
Created October 28, 2019 16:37 — forked from heygrady/preloading-data-redux.md
Preloading data in a redux application

Preloading data in a redux application

A redux app is a chicken and egg problem. Given a particular state, the app should render a certain thing. But... where does that state come from?

Starting from empty

Given a blank state, the app needs to rely on the URL to fetch the right data to populate the state.

In a server-side app, the initial state is determined in exactly this way. Given the initial URL, populate the state, render the app, send it to the client.

In a client-side app the situation is exactly the same, except it's totally different. On the client you have way more contextual information than just the URL. Given the URL, the current app state, a components own props and its internal state... a component must decide which data it needs loaded.

@hungbang
hungbang / jsonp-proxy-request-interceptor.js
Created May 30, 2020 06:04 — forked from mzipay/jsonp-proxy-request-interceptor.js
AngularJS HTTP interceptor to work around CORS/JSONP problems
/**
* @license CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.0/)
*
* The problem:
* You need to make a cross-domain request for JSON data, but the remote
* server doesn't send the necessary CORS headers, and it only supports
* simple JSON-over-HTTP GET requests (no JSONP support).
*
* One possible solution:
* Use 'jsonp-proxy-request-interceptor' to proxy the request through
@hungbang
hungbang / Spring Chained Tx Management.md
Created July 22, 2020 02:41 — forked from anair-it/Spring Chained Tx Management.md
Best efforts 1Phase Commit using Spring chained transaction managemer and Apache Camel

Best efforts 1 Phase commit

This is a non-XA pattern that involves a synchronized single-phase commit of a number of resources. Because the 2PC is not used, it can never be as safe as an XA transaction, but is often good enough if the participants are aware of the compromises. The basic idea is to delay the commit of all resources as late as possible in a transaction so that the only thing that can go wrong is an infrastructure failure (not a business-processing error). Systems that rely on Best Efforts 1PC reason that infrastructure failures are rare enough that they can afford to take the risk in return for higher throughput. If business-processing services are also designed to be idempotent, then little can go wrong in practice.

Scenarios

Consider a jms based service, where there is an inbound Queue manager (QM1), an outbound queue manager (QM2) and a database (DB). Here are the scenarios that I would like to cover using Best efforts 1 PC commit process:

Happy path

  1. Start MQ transaction on QM1 2
@hungbang
hungbang / gist:d3fcd8f1bb3ba397b244a8dbf4e77d26
Created December 31, 2020 01:51 — forked from sanemat/gist:1010496
heroku git tag deployment
$ git push -f heroku release-20110606^{}:master
# I don't know [tag]^{}
@hungbang
hungbang / README.md
Created January 19, 2021 03:25 — forked from ondrejsika/README.md
MongoDB Cheat Sheet
@hungbang
hungbang / kubectl.md
Created March 23, 2021 07:45 — forked from so0k/kubectl.md
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
@hungbang
hungbang / ElasticsearchConfig.java
Created May 2, 2021 06:46 — forked from thetekst/ElasticsearchConfig.java
Elasticsearch. Spring Boot 2. LocalDateTime converter for document's field. Data parser
package ru.tkachenko.app.config;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import lombok.RequiredArgsConstructor;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
@hungbang
hungbang / setup-kubernetes-ubuntu-16.md
Created May 9, 2021 07:34 — forked from ruanbekker/setup-kubernetes-ubuntu-16.md
Install a 3 Node Kubernetes Cluster on Ubuntu 16

Master: Dependencies

apt update && apt upgrade -y
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF