Skip to content

Instantly share code, notes, and snippets.

View tonfever's full-sized avatar

Panuwat Srisawat tonfever

View GitHub Profile
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.hibernate.dialect;
import java.sql.Types;
import java.sql.Types;
import org.hibernate.Hibernate;
@tonfever
tonfever / log4j.properties
Last active December 31, 2015 07:59
Simple log4j.properties. Console, and Trace level (the Finest one).
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=TRACE, stdout
@tonfever
tonfever / NumberTextField.java
Created February 2, 2014 12:03
a custom JavaFX numeric textbox
public class NumberTextField extends TextField {
@Override
public void replaceText(int start, int end, String text)
{
if (validate(text))
{
super.replaceText(start, end, text);
}
}
@tonfever
tonfever / build.xml
Last active August 29, 2015 14:01
Ant File example, clean, prepare, compile ,jar
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="Create Runnable Jar for Project FreeMarkerTester with libraries in sub-folder">
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
<!--ANT 1.7 is required -->
<property name="dist.home" value="${basedir}/dist" />
<property name="src.home" value="${basedir}/src" />
<property name="bin.home" value="${basedir}/bin" />
<!-- Define the CLASSPATH -->
/*
* AS3.g3
*
* Copyright (c) 2005 Martin Schnabel
* Copyright (c) 2006-2008 David Holroyd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@tonfever
tonfever / util.java
Last active October 11, 2016 09:30
Sample of reading a property file from classpath
Properties properties = new Properties();
try {
properties.load(this.getClass().getClassLoader().getResourceAsStream("yourconfig.properties"));
} catch (IOException e) {
e.printStackTrace();
}
@tonfever
tonfever / gist:9c2076f1260d028daf38aec06150dabb
Created April 20, 2017 08:53
How to set a proxy setting for Docker in Windows (Docker toolbox)
This is how to set up the proxy for docker in Window 7 (Docker Toolbox). This window7 cannot install the latest version of docker.
Newer version of docker setting may vary. And the problem is after docker installation and you want run the first docker.
You would run "docker run hello-world". Then you got the error that you're unable to find image locally XXXX. And you found that causes
from Docker cannot access the internet to get an image. That is we have to set a proxy for Docker. Here's a step
1. Go to the config.json in the folder /$USER_HOME/.docker/machine/machines/$YOUR_MACHINE
2. Add the proxy setting in the 'Env' section as following
"HostOptions": {
.......
@tonfever
tonfever / merge.sql
Created June 15, 2017 07:22
Using merge on Oracle example
MERGE INTO <TABLE_NAME> <ALIAS1> USING
(
SELECT
:COLUMN1 AS COLUMN1
,:COLUMN2 AS COLUMN2
,:COLUMN3 AS COLUMN3
FROM DUAL
) <ALIAS2> ON
(
--- CONDITION
@tonfever
tonfever / application.properties
Last active April 24, 2018 08:36
spring boot application.properties
spring.datasource.url=jdbc:mysql://HOST:PORT/DATABASE
spring.datasource.username=USERNAME
spring.datasource.password=USER_PASSWORD
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
@tonfever
tonfever / Md5UtilTest.java
Last active May 9, 2018 07:17
Generate MD5 message
import org.apache.commons.codec.digest.DigestUtils;
import org.junit.Assert;
import org.junit.Test;
import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Md5UtilTest{