Skip to content

Instantly share code, notes, and snippets.

View tuphamphuong's full-sized avatar
🎯
Focusing

Tu Pham (Tony) tuphamphuong

🎯
Focusing
View GitHub Profile
@tuphamphuong
tuphamphuong / VNCharacterUtils.java
Created September 1, 2016 07:22
Vietnamese accent remove
public class VNCharacterUtils {
// Mang cac ky tu goc co dau
private static char[] SOURCE_CHARACTERS = { 'À', 'Á', 'Â', 'Ã', 'È', 'É',
'Ê', 'Ì', 'Í', 'Ò', 'Ó', 'Ô', 'Õ', 'Ù', 'Ú', 'Ý', 'à', 'á', 'â',
'ã', 'è', 'é', 'ê', 'ì', 'í', 'ò', 'ó', 'ô', 'õ', 'ù', 'ú', 'ý',
'Ă', 'ă', 'Đ', 'đ', 'Ĩ', 'ĩ', 'Ũ', 'ũ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ạ',
'ạ', 'Ả', 'ả', 'Ấ', 'ấ', 'Ầ', 'ầ', 'Ẩ', 'ẩ', 'Ẫ', 'ẫ', 'Ậ', 'ậ',
'Ắ', 'ắ', 'Ằ', 'ằ', 'Ẳ', 'ẳ', 'Ẵ', 'ẵ', 'Ặ', 'ặ', 'Ẹ', 'ẹ', 'Ẻ',
'ẻ', 'Ẽ', 'ẽ', 'Ế', 'ế', 'Ề', 'ề', 'Ể', 'ể', 'Ễ', 'ễ', 'Ệ', 'ệ',
'Ỉ', 'ỉ', 'Ị', 'ị', 'Ọ', 'ọ', 'Ỏ', 'ỏ', 'Ố', 'ố', 'Ồ', 'ồ', 'Ổ',
@tuphamphuong
tuphamphuong / districts.sql
Created September 1, 2016 07:24
Vietnam districts database
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
@tuphamphuong
tuphamphuong / getExtendedFbToken.java
Created September 8, 2016 04:44
RestFb get extended Facebook token
FacebookClient facebookClient = new DefaultFacebookClient(token, secretKey);
FacebookClient.AccessToken extendedAccessToken = facebookClient.obtainExtendedAccessToken(appId, secretKey, token);
String extendedToken = extendedAccessToken.getAccessToken();
@tuphamphuong
tuphamphuong / MyMonitorThread.java
Created September 10, 2016 16:14
Monitor executor service
import java.util.concurrent.ThreadPoolExecutor;
public class MyMonitorThread implements Runnable
{
private ThreadPoolExecutor executor;
private int seconds;
private boolean run=true;
public MyMonitorThread(ThreadPoolExecutor executor, int delay)
{
@tuphamphuong
tuphamphuong / Fix bug ssh etc agent stop
Created October 22, 2016 07:50
Fix bug ssh agent stop
$ git fetch
Connection to bitbucket.org closed by remote host.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
$ ssh-add -l
The agent has no identities.
$ ssh-add ~/.ssh/id_rsa
@tuphamphuong
tuphamphuong / facebook-login.sh
Created November 3, 2016 09:11
Login to Facebook via curl
#!/bin/sh
# Authenticate an facebook application directly from shell.
# Make sure to modify the EMAIL and PASS below and just run it as:
# sh facebook-login.sh "<your facebook url>"
#
# It's possible to script and run the script in a while loop (In my case this is necessary hence
# the facebook-sdk api for php causes random crashes and my script needs to run for a loooong time.
#
# for a in a b c d e f g i j k l m n o p; do while (true); do START=`date +%s`; sh facebook-login.sh "<your app url>"; expr `date +%s` \< \( $START + 20 \) > /dev/null && break; done; sleep 30; done
@tuphamphuong
tuphamphuong / CurrentWorkingDir.java
Created November 21, 2016 07:54
Get current working dir in Java 7+ one line
import java.nio.file.Paths;
Paths.get(".").toAbsolutePath().normalize().toString();
@tuphamphuong
tuphamphuong / change_encode.py
Created December 16, 2016 07:45
Python 2.x change default encoding to utf-8
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
@tuphamphuong
tuphamphuong / gist:46ef8b77ed13bbacf7797b38ad149650
Created June 15, 2018 12:36 — forked from digitaljhelms/gist:4287848
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch
╔════════════════╦═════╦═════╦══════╦═════╗
║ DDBS ║ P+A ║ P+C ║ E+L ║ E+C ║
╠════════════════╬═════╬═════╬══════╬═════╣
║ DynamoDB ║ Yes ║ ║ Yes ║ ║
║ Cassandra ║ Yes ║ ║ Yes ║ ║
║ Riak ║ Yes ║ ║ Yes ║ ║
║ VoltDB/H-Store ║ Yes ║ ║ Yes ║ ║
║ Elasticsearch ║ Yes ║ ║ Yes ║ ║
║ Bigtable/HBase ║ ║ Yes ║ ║ Yes ║
║ MongoDB ║ ║ Yes ║ ║ Yes ║