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 / 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 / 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 / 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 / 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 / mysql-country-list.sql
Created August 13, 2016 09:14
Mysql country list
CREATE TABLE `country` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`country_code` varchar(2) NOT NULL,
`country_name` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
KEY `cc` (`country_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `country` (`id`, `country_code`, `country_name`)
VALUES
@tuphamphuong
tuphamphuong / Fix supervisor sock no such file
Created July 12, 2016 07:38
Fix supervisor unix:///var/run/supervisor.sock no such file
sudo touch /var/run/supervisor.sock
sudo chmod 777 /var/run/supervisor.sock
sudo service supervisor restart
@tuphamphuong
tuphamphuong / EnclosedTest.java
Created January 13, 2016 07:29
JUnit Enclosed test
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
/**
* Created by Tu Pham Phuong - [email protected] on 1/13/16.
*/
@RunWith(Enclosed.class)
@tuphamphuong
tuphamphuong / TestGuavaCache.java
Created January 13, 2016 02:23
Unit test Guava cache
import com.google.common.cache.*;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.fest.assertions.Assertions.assertThat;
/**
* Created by Tu Pham Phuong - [email protected] on 7/2/15.
@tuphamphuong
tuphamphuong / BasicJUnit.java
Created January 12, 2016 13:47
Basic JUnit
package controllers;
import org.junit.*;
import static org.junit.Assert.*;
/**
* Created by Tu Pham Phuong - [email protected] on 1/11/16.
*/
public class BasicTest {
@BeforeClass
@tuphamphuong
tuphamphuong / FactoryMethod.java
Created October 21, 2015 15:58
Simple factory method in Java
public static TemplateService createTemplateService() {
return new TemplateService();
}