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 / *scratch*.txt
Created August 25, 2022 01:54 — forked from aculich/*scratch*.txt
Downgrade helm client
# How to downgrade helm version on server and client
# https://medium.com/@jyotirbhandari/how-to-downgrade-helm-version-on-server-and-client-4838ca100dbf
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash -s -- --version v2.16.9
@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
@tyb
tyb / atomikos_jms.java
Last active February 28, 2022 07:15
Spring Boot JTA Atomikos & JMS configuration
package com.xxx.common.config;
import com.atomikos.icatch.config.UserTransactionServiceImp;
import com.atomikos.icatch.jta.UserTransactionImp;
import com.atomikos.icatch.jta.UserTransactionManager;
import net.sf.ehcache.transaction.manager.TransactionManagerLookup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
@Bharathbrothers
Bharathbrothers / Unique.java
Created November 13, 2018 02:42
How to generate unique random numbers in Java?
ArrayList<Integer> array = new ArrayList<>(4);
ArrayList<Integer> input = new ArrayList<>(4);
for(int i=0;i<10;i++){
array.add(i);
}
Collections.shuffle(array);
for(int j=0;j<4;j++){
input.add(array.get(j));
#!/usr/bin/env bash
echo "
----------------------
MONGODB
----------------------
"
# import mongodb 4.0 public gpg key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
@heygrady
heygrady / preloading-data-redux.md
Created March 1, 2018 02:06
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.

@johnpapa
johnpapa / DockerCleanupScripts.md
Created August 3, 2017 01:37 — forked from spboyer/DockerCleanupScripts.md
Docker Cleanup Scripts

Docker - How to cleanup (unused) resources

Cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@ondrejsika
ondrejsika / README.md
Created June 28, 2017 07:04
MongoDB Cheat Sheet
Ondrej Sika <ondrej@ondrejsika.com>

Database

Select Database

use DATABASE_NAME
@anair-it
anair-it / Spring Chained Tx Management.md
Last active June 7, 2024 06:38
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
@hartleybrody
hartleybrody / import-db.sh
Last active April 10, 2024 16:09
Copy data from Heroku Postgres into local database
# copy/import data from heroku postgres to localhost pg database
# useful for copying admin's work on live site into local database to reproduce errors
# https://devcenter.heroku.com/articles/heroku-postgres-import-export
# take heroku pg snapshot and download
heroku pg:backups:capture
heroku pg:backups:download
# load the dump into local postgres database, assuming $DATABASE_URL set locally