Skip to content

Instantly share code, notes, and snippets.

View phuongtailtranminh's full-sized avatar

Tran Minh Phuong phuongtailtranminh

  • Hanoi
View GitHub Profile
@phuongtailtranminh
phuongtailtranminh / KeyCloak and Spring Security Get Custom Claims Info
Created May 17, 2017 04:26
KeyCloak and Spring Security Get Custom Claims Info
public String method(KeycloakAuthenticationToken token) {
OidcKeycloakAccount account = token.getAccount();
IDToken idToken = account.getKeycloakSecurityContext().getIdToken();
return idToken.getOtherClaims().get("CUSTOM_FIELD")
}
@phuongtailtranminh
phuongtailtranminh / Open command window here registry
Created May 19, 2017 10:44
Open command window here registry
Problem: http://www.winhelponline.com/blog/cmd-here-windows-10-context-menu-add/
Copy the following lines to Notepad, and save it with a .REG extension, say cmdhere.reg. Double-click the file to apply the registry settings.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\cmdprompt]
@="@shell32.dll,-8506"
"Extended"=""
"NoWorkingDirectory"=""
@phuongtailtranminh
phuongtailtranminh / OS X Sierra Change Flat Icon Tutorial
Last active July 7, 2017 03:50
The way to change flat icon on OS X Sierra
1. Concepts:
System Integrity Protection (SIP)
"Apple has enabled a new default security oriented featured called System Integrity Protection, often called rootless,
in Mac OS from versions 10.11 onward. The rootless feature is aimed at preventing Mac OS X compromise by malicious code,
whether intentionally or accidentally, and essentially what SIP does is lock down specific system level locations in the file
system while simultaneously preventing certain processes from attaching to system-level processes."
- OSXDaily [http://osxdaily.com/2015/10/05/disable-rootless-system-integrity-protection-mac-os-x/]
@phuongtailtranminh
phuongtailtranminh / latency.txt
Created March 10, 2018 11:06 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@phuongtailtranminh
phuongtailtranminh / Che Build
Last active January 15, 2019 10:26
Useful Eclipse Che build command
First time build: 40m
Second time build: 6m
[BUILD FROM SOURCE USING DOCKER]
cd YOUR_CHE_REPOSITORY
docker run -it --rm --name build-che \
-v "$HOME/.m2:/home/user/.m2" \
-v "$PWD":/home/user/che-build \
-w /home/user/che-build \
eclipse/che-dev \
package com.viettel.integration.hub.echoserver.controller;
import java.io.IOException;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
<!DOCTYPE configuration>
<configuration>
<contextName>test</contextName>
<jmxConfigurator/>
<appender name="gelf" class="biz.paluch.logging.gelf.logback.GelfLogbackAppender">
<host>udp:localhost</host>
<port>12201</port>
<version>1.1</version>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
@phuongtailtranminh
phuongtailtranminh / Backup and Restore Linux Server
Last active August 5, 2019 14:47
Backup and Restore Ubuntu Server
Backup: sudo tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/boot --one-file-system /
Restore: sudo tar -xvpzf /path/to/tar/file -C / --numeric-owner
@phuongtailtranminh
phuongtailtranminh / Linux Network Commands
Created November 17, 2016 03:44
Linux Network Commands
Network Interface Configurator.
- View network settings of an ethernet adapter:
ifconfig eth0
- Display details of all interfaces, including disabled interfaces:
ifconfig -a
- Disable eth0 interface:
ifconfig eth0 down