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 / revert-a-commit.md
Created May 20, 2021 08:41 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}'

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@hungbang
hungbang / install_linuxbrew_on_centos7.sh
Created May 18, 2021 09:15 — forked from warking/install_linuxbrew_on_centos7.sh
standalone linuxbrew setup script for CentOS 7
# Non-root account is recommended for this process
# centos-specific prepration
sudo yum -y update && sudo yum -y groupinstall 'Development Tools' && sudo yum -y install curl irb m4 ruby
# Sanitize the environment
PATH=~/.linuxbrew/bin:/usr/local/bin:/usr/bin:/bin
unset LD_LIBRARY_PATH PKG_CONFIG_PATH
# install linuxbrew
@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
@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 / 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 / README.md
Created January 19, 2021 03:25 — forked from ondrejsika/README.md
MongoDB Cheat Sheet
@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 / 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 / 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 / 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.