CF83-64WT-T6U5-7XHM-TN9B-YQW9
Some useful JVM flags:
-XX:+UnlockDiagonosticVMOptions -XX:+PrintFlagsFinal (shows default values of all JVM flags)
-XX:InitialHeapSize=Ng (set initial heap size GB, also as shortcut -XmsNg)
-XX:MaxHeapSize=Ng (set maximum heap size GB, also as shortcut -XmxNg)
-XX:+PrintCompilation (show the degree of compilation of methods at runtime)
-XX:+UnlockDiagonosticVMOptions -XX:+LogCompilation (writes traces of compilation during runtime in a file)
-XX:+PrintCodeCache (prints the stats of code-cache)
-XX:InitialCodeCacheSize=Nm (sets initial size of code-cache to N MB)
-XX:ReservedCodeCacheSize=Nm (sets maximum size of code-cache to N MB)
-client (forces JVM to use only C1 compiler)
-server, -d64 (forces JVM to use only C2 compiler also)
-XX:-TieredCompilation (forces JVM to turn off tiered compilation and run in interpreter-mode only)
jinfo -flag CICompilerCount <java_pid> (shows default value of the given JVM flag, CICompilerCount in this case)
-XX:CICompilerCount=N (sets the number of JIT compiler-threads)
-XX:CompileThreshold=N (sets the number of invocations a method should go through for native compilation to be applied)
-XX:+PrintStringTableStatistics (shows stats about the string-pool, how many buckets in the pool, how dense the pool is etc.)
-XX:StringTableSize=N (change the number of buckets to N in string-pool)
--Some useful docker commands
sudo docker images
sudo docker ps -a
sudo docker inspect <container_id>
sudo docker start/stop/kill <container_id>
sudo docker exec -ti <name> psql -d expo9db -U expo9
--Command to enter docker bash to run further commands there
docker exec -it edb_primary bash
docker exec -ti edb_standby bash psql -d expo9db -U expo9
--Command to run sql script in docker-hosted edb from remote
sudo ssh viexpo9-edb-01 docker exec -i edb_primary psql -U expo9 -d expo9db -w -f /mnt/prod/tf/real/runtime/deployscripts/tmp/tmp.sql
--Download standard unix image containing installation of tomcat
docker image pull tomcat:8.0
--Command to show all active images, should show recently downloaded tomcat image too
docker image ls
--Creates a docker container named "ap_tomcat_container" that will wrap the recently downloaded tomcat image
--and will run on its 8080 port, but that port will be mapped to outside world to 8082
docker container create --publish 8082:8080 --name ap_tomcat_container tomcat:8.0
--command to show all containers, should show just now created "ap_tomcat_container" as well
docker container ls -a
--Start just now created "ap_tomcat_container"
docker container start ap_tomcat_container
--Command to enter the container's bash shell, tomcat installation is in "/usr/local/tomcat"
docker container exec -it ap_tomcat_container bash
--Create a file named "Dockerfile" in project's root location, and add the following lines
# extending everything from tomcat:8.0 image
FROM tomcat:8.0
MAINTAINER ayan.pal
# COPY <path-to-your-application-war> <path-to-webapps-in-docker-tomcat>
COPY target/session_management.war /usr/local/tomcat/webapps/
--Build the docker image
docker image build -t ayan_pal/session_management_image ./
--Command to show all active images, should show recently built "ayan_pal/session_management_image" image too
docker image ls
--Create and run container "ayan_pal/session_management_image" and map its port 8080 to 8081 for public
docker container run -it --publish 8081:8080 ayan_pal/session_management_image
Create a new empty file in Mac finder
Part 1: Create a new Quick Action (was Service)
In Automator, create a new Quick Action:
From the left site, click Utilities then drag "Run Applescript" over to the right panel.
Change the two pulldown menus at the top of the right panel to read:
Workflow receives no input in Finder.app
Replace ALL the purple script with:
tell application "Finder"
set txt to make new file at (the target of the front window) as alias with properties {name:"empty.txt"}
select txt
end tell
Save the Service as "New Empty Text File". This file will be saved under <home>/Library/Services directory (.workflow extension will be added automatically).
This service is now available under the Services menu in the Finder.
Part 2: Create a Keyboard Shortcut
Under System Preferences › Keyboard › Shortcuts › Services, scroll down to General (it's at the end).
You will see New Empty Text File listed with "none" as the shortcut.
Click on none and type the shortcut of your choice (I used option command N):
You can now type your shortcut in the Finder whenever you want to create a new, empty, text document.
Thanks to Syreeni, whose answer made this possible, and to RoG (comment below) who contributed the line that automatically selects the new file.
================================================
================================================
Expo VPN: URL: vpn.scl.exponential.com/ALL_DEV, Username: tf-net\Ayan.Pal
The Little MongoDB Book: here
Scala For JAVA Developers: here
Big Data docs and tutorial: here
Hadoop JPMC Training Docs: here and here
Python tutorial: here
Python windows help: here
Python windows 64bit zip: here
Python windows 32bit zip: here
Technical docs for official projects
calc_ctry_ng_architecture
==============================
====
Statements.java
====
package com.exp;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
public class Statements {
private static DecimalFormat DEC_FORMAT = new DecimalFormat(".##");
private static final String[] MONTHS = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
public static void main(String[] args) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("-1) Paytm\n-2) Indian\n-3) Allahabad\nEnter option: ");
String line = reader.readLine();
int option = Integer.valueOf(line);
if (option == 1) {
paytm();
} else if (option == 2) {
indian();
} else if (option == 3) {
allahabad();
} else {
System.out.println("Incorrect option....bye....!!");
}
} catch (Exception e) {
e.printStackTrace();
}
try {
reader.close();
} catch (Exception e) {
}
}
private static void paytm() {
BufferedReader br = null;
FileOutputStream fout = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream("paytm.txt")));
fout = new FileOutputStream("paytm.csv");
boolean proceed = true;
List<String> data = new ArrayList<String>();
Map<Key, String> map = new TreeMap<Key, String>();
while (proceed) {
String line = br.readLine();
if (line == null) {
proceed = false;
processData(data, map);
} else {
line = line.replace("\t", " ").replace(" ", " ").trim();
if ("paytm_wallet".equals(line)) {
processData(data, map);
} else {
data.add(line);
}
}
}
// Date format will be "custom-->dd/mm/yyyy hh:mm:ss" in CSV
fout.write("Date,Details,Comment,Debit,Credit\n".getBytes());
Set<Entry<Key, String>> entrySet = map.entrySet();
for (Entry<Key, String> entry : entrySet) {
System.out.println(entry.getValue());
fout.write((entry.getValue() + "\n").getBytes());
}
} catch (Exception e) {
e.printStackTrace();
}
try {
br.close();
} catch (Exception e) {
}
try {
fout.close();
} catch (Exception e) {
}
}
private static void processData(final List<String> data, final Map<Key, String> map) {
if (data.size() > 0) {
String[] parts = data.get(0).split("Transaction ID");
String details = parts[0].replace(",", ";").trim();
parts = parts[1].trim().split("-");
parts[0] = parts[0].trim();
String transactionID = parts[0].substring(0, parts[0].length() - 4);
int year = Integer.valueOf(parts[0].substring(parts[0].length() - 4));
int month = Integer.valueOf(parts[1].trim());
parts = parts[2].trim().split(" ");
int day = Integer.valueOf(parts[0].trim());
boolean isPM = "PM".contentEquals(parts[2].trim());
parts = parts[1].trim().split(":");
int hour = Integer.valueOf(parts[0].trim());
if (isPM) {
hour = hour + 12;
}
int min = Integer.valueOf(parts[1].trim());
int sec = Integer.valueOf(parts[2].trim());
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month - 1);
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, min);
cal.set(Calendar.SECOND, sec);
cal.set(Calendar.MILLISECOND, 0);
String date = (day < 10 ? "0" + day : day) + "-" + MONTHS[month - 1] + "-" + year + ":" + (hour < 10 ? "0" + hour : hour) + ":" + (min < 10 ? "0" + min : min) + ":" + (sec < 10 ? "0" + sec : sec);
double debit = 0;
double credit = 0;
if (data.size() == 4) {
debit = Double.valueOf(data.get(1).replace("Rs", "").replace(",", "").trim());
} else {
credit = Double.valueOf(data.get(1).replace("Rs", "").replace(",", "").trim());
}
parts = data.get(data.size() - 1).trim().split(" ");
String status = parts[0].trim();
String comment = "";
if (parts.length > 0) {
for (int i = 1; i < parts.length; i++) {
if (i > 1) {
comment = comment + " ";
}
comment = comment + parts[i];
}
}
comment = comment.replace("Return To Bank", "").replace(",", ";").replace(" ", " ").trim();
String debitVal = "";
if (debit != 0) {
debitVal = DEC_FORMAT.format(debit);
String[] vals = debitVal.split("\\.");
if (vals[1].length() == 1) {
debitVal = debitVal + "0";
}
}
String creditVal = "";
if (credit != 0) {
creditVal = DEC_FORMAT.format(credit);
String[] vals = creditVal.split("\\.");
if (vals[1].length() == 1) {
creditVal = creditVal + "0";
}
}
String txt = date + "," + details + ",Transaction_ID:" + transactionID + "," + status + "," + comment + "," + debitVal + "," + creditVal;
Key key = new Key();
key.cal = cal;
key.transactionId = Long.valueOf(transactionID);
map.put(key, txt);
}
data.clear();
}
private static class Key implements Comparable<Key> {
public Calendar cal;
public long transactionId;
@Override
public int compareTo(Key k) {
int calComp = cal.compareTo(k.cal);
if (calComp == 0) {
if (transactionId < k.transactionId) {
return -1;
} else if (transactionId > k.transactionId) {
return 1;
}
return 0;
}
return calComp;
}
}
private static void indian() {
BufferedReader br = null;
FileOutputStream fout = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream("indian.txt")));
fout = new FileOutputStream("indian.csv");
boolean proceed = true;
TreeMap<Integer, String> data = new TreeMap<Integer, String>(Collections.reverseOrder());
int lineCount = 0;
while (proceed) {
String line = br.readLine();
if (line == null) {
proceed = false;
} else {
String[] parts = line.trim().split("\t");
String postDate = getDateStr(parts[0]);
String valueDate = getDateStr(parts[1]);
String description = parts[2].replace(",", " ");
String debit = parts[3];
String credit = parts[4];
data.put(lineCount, postDate + "," + valueDate + "," + description + "," + debit + "," + credit);
lineCount++;
}
}
fout.write("Post Date,Value Date,Description,Debit,Credit\n".getBytes());
Set<Entry<Integer, String>> entrySet = data.entrySet();
for (Entry<Integer, String> entry : entrySet) {
System.out.println(entry.getValue());
fout.write((entry.getValue() + "\n").getBytes());
}
} catch (Exception e) {
e.printStackTrace();
}
try {
br.close();
} catch (Exception e) {
}
try {
fout.close();
} catch (Exception e) {
}
}
private static String getDateStr(String str) {
if (str != null && str.length() > 0) {
String[] parts = str.split("/");
int index = Integer.valueOf(parts[1]) - 1;
String month = MONTHS[index];
return parts[0] + "-" + month + "-" + parts[2];
}
return "";
}
private static void allahabad() {
}
}
====
==============================
==============================
private static final int br = 1680;
public static void myLog(String txt, Throwable t) {
String myLogPath = "/mnt/users/apal/work/temp/" + br + "_log.txt";
java.io.FileOutputStream fout = null;
if (txt != null && txt.length() > 0) {
try {
fout = new java.io.FileOutputStream(myLogPath, true);
fout.write((txt + "\n").getBytes());
} catch (Throwable e) {
}
}
if (t != null) {
try {
if (fout == null) {
fout = new java.io.FileOutputStream(myLogPath, true);
}
java.io.StringWriter sw = new java.io.StringWriter();
java.io.PrintWriter pw = new java.io.PrintWriter(sw);
t.printStackTrace(pw);
String stackTrace = sw.toString();
fout.write((stackTrace + "\n").getBytes());
} catch (Throwable e) {
}
}
try {
fout.close();
} catch (Throwable e) {
}
}
--another useful method to get choice
public static int choice(String property) {
int choice = 0;
java.io.FileInputStream fis = null;
java.util.Properties properties = new java.util.Properties();
try {
fis = new java.io.FileInputStream("/mnt/users/apal/work/temp/" + br + "_choice.txt");
properties.load(fis);
choice = Integer.valueOf(properties.getProperty(property));
} catch (Throwable e) {
}
try {
fis.close();
} catch (Throwable e) {
}
return choice;
}
--another useful method to get property
public static String prop(String key) {
String prop = null;
java.io.FileInputStream fis = null;
java.util.Properties properties = new java.util.Properties();
try {
fis = new java.io.FileInputStream("/mnt/users/apal/work/temp/" + br + "_prop.txt");
properties.load(fis);
prop = properties.getProperty(key);
} catch (Throwable e) {
}
try {
fis.close();
} catch (Throwable e) {
}
return prop;
}
--another method to print stack trace
public static void printStackTrace(int minLevel) {
int limit = (minLevel > 10 ? minLevel : 10);
if (choice("printStackTrace") == 1) {
StackTraceElement[] st = Thread.currentThread().getStackTrace();
for (int i = 2; i < st.length; i++) {
String msg = "st--> " + String.format("%2d ", i - 2);
for (int j = 0; j < i - 2; j++) {
if (j < i - 3) {
msg = msg + " ";
} else {
msg = msg + "|_";
}
}
myLog(msg + st[i], null);
if (i > limit) {
break;
}
}
}
}
==============================