Skip to content

Instantly share code, notes, and snippets.

@ToanPV90
ToanPV90 / Java8DateTimeExamples.java
Created August 22, 2017 03:54 — forked from mscharhag/Java8DateTimeExamples.java
Examples for using the Java 8 Date and Time API (JSR 310)
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import static java.time.temporal.TemporalAdjusters.*;
public class Java8DateTimeExamples {
@ToanPV90
ToanPV90 / SAMLServlet.java
Created April 30, 2019 14:27 — forked from jimhe/SAMLServlet.java
Servlet to handle SAML Auth request and response. on GET /saml, it will redirect to the ID Provider with the proper SAMLRequest parameter. on POST /saml, it will parse the POST parameter for a properly signed and successful response before allowing the user in.
package com.comprehend.servlet;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.opensaml.Configuration;
import org.opensaml.common.binding.BasicSAMLMessageContext;
import org.opensaml.common.xml.SAMLConstants;
import org.opensaml.saml2.binding.decoding.HTTPPostDecoder;
import org.opensaml.saml2.binding.encoding.HTTPRedirectDeflateEncoder;
import org.opensaml.saml2.core.*;
@ToanPV90
ToanPV90 / DateTimeUtil.java
Created January 20, 2020 07:25 — forked from dassiorleando/DateTimeUtil.java
A JodaTime and java.util.Date Util Class with a lot of usefull functions.
package cm.flashbusiness.core.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.joda.time.DateTime;
/**
* @author dassi
@ToanPV90
ToanPV90 / postgres-cheatsheet.md
Created January 25, 2020 06:52 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@ToanPV90
ToanPV90 / update-git.sh
Created February 13, 2020 09:56 — forked from YuMS/update-git.sh
Update git to latest version on Ubuntu
#!/bin/bash
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git -y
@ToanPV90
ToanPV90 / multiple_ssh_setting.md
Created June 2, 2022 06:35 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"

This recipe is a work in progress and has never been run as-is.

  • timeouts are in ms
  • lock timeout: in postgres, when a statement that wants a restrictive lock waits on another lock, other statements that want locks can't jump the queue. so even though the statement that is waiting might only take a very short amount of time, when it starts running, while it is waiting no other statements can begin. So we set the lock timeout pretty low and retry if we don't get it.
  • statement timeout: we set a short statement timeout before statements which do lock and which we expect to take a short amount of time, just in case something about our assumptions/understanding is wrong and the statement ends up taking a long time. if this happens the statement will bail early without causing harm, and we can investigate what is wrong with
@ToanPV90
ToanPV90 / RestTemplateHelper.java
Created June 15, 2023 05:32 — forked from slmanju/RestTemplateHelper.java
Generic RestTemplate wrapper
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
1. I see that most of your connections and queries are running on the master(writer) database instance itself without much load on the reader instance. You can consider dividing your workload such that read-only queries/workloads are directed to the reader instance, and only write queries are handled by your writer instance. This will help alleviate the large undo logs(RollbackSegmentHistoryListLength) due to long running queries and in itself this should mitigate a lot of the performance issues.
One way to achieve splitting of Reads and Writes is by making use of a third party software Proxy solution which can split reads and writes to the appropriate endpoints. Below are a few example software solutions which you can consider:
[+] ProxySQL - https://proxysql.com/
[+] Heimdall Data - https://www.heimdalldata.com/
2. If and where possible, try to split large transactions into multiple smaller transactions. This will again reduce the growth of the undo log which seems to be the main cause of t