Skip to content

Instantly share code, notes, and snippets.

check application use by port
sudo lsof -P -i -n|grep '80.*LISTEN'
1. view ssl certificate text
openssl x509 -in cerfile.cer -noout -text
2. create private key and cert file
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
3. Generate a self-signed certificate
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout privateKey.key -out certificate.crt
https://www.sslshopper.com/article-most-common-openssl-commands.html
https://phoenixnap.com/kb/how-to-setup-ftp-server-install-vsftpd-centos-7
create file /etc/vsftpd/chroot_list
add testuser to this file
@ledangtuanbk
ledangtuanbk / check cors online
Created September 20, 2019 01:40
check cors online
1. go to page with http
2. in console run this command to check
fetch('./api/some.json')
.then(
function(response) {
if (response.status !== 200) {
console.log('Looks like there was a problem. Status Code: ' +
response.status);
return;
1. http://62.4.19.189:8090/spaces/viewspace.action?key=MAN dtrantri/12345678
2 gitlab
tledang/tuan1989
3. jenkins
http://62.4.19.164:8080/login?from=%2F
tledang/12345678
4. dev enviroment
SessionFactory
Session
Transaction
ConnectionProvider
Transaction Factory
1. jpa-entity-class
- @javax.persistance.Entity
- public, protected no-argument contructor
- class not declare final, no method, persistence instance variables is final.
- if an entity is passed by value as detached object. such as through a session bean remote. class must by implementaion Serialization
- Entity may extends both entity and non-entity class.
- fields: not annotated
1. JPA Java Persistence API provides a specification for persisting, reading and managing data from your java object to relational tables in database
2. Hibernate is an object ralational mapping solution for java enviroments. ORM is a programming technique to map application domain model objects to relational database tables;
Hibernate provides a reference implementation of Java Persistence API that make it a greate choice as ORM tools with benefit of loose coupling.
Note that JPA is a specification and Hibernate is a JPA provider of implementation.
3. Spring Data is a part of the Spring Framework. The goal of Spring Data repository abstraction is reduce amount of
boilerplate code requited to implement data access layer.
@ledangtuanbk
ledangtuanbk / ssh_tunnel
Last active November 14, 2019 03:08
How to use ssh_tunnel
1. Connecting to a database behind a firewall
ssh -L 9000:localhost:5432 user@example.com database postgres run port 5432 only access from localhost
2. Remote port forwarding
ssh -R 9000:localhost:3000 user@example.com
Localhost running port 3000 and want to acess from internet port 9000
- set GatewayPorts yes in /etc/ssh/sshd_config
- this can be done by autossh
autossh -M 0 -f -q -N -o "ServerAliveInterval 5" -o "ServerAliveCountMax 1" -o "ExitOnForwardFailure yes" -R 0.0.0.0:[SERVER]:localhost:[CLIENT_IP] [SERVER_USER]@[SEVER_IP]
- remember to run on reboot
package com.ldt.test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TestMain2 {
public static void main(String[] args) {
int[][] datas = new int[][]{