Skip to content

Instantly share code, notes, and snippets.

View phamthaithinh's full-sized avatar

Thai Thinh phamthaithinh

View GitHub Profile
@phamthaithinh
phamthaithinh / wget-jdk-oracle-install-example.txt
Created November 11, 2015 11:10 — forked from sr75/wget-jdk-oracle-install-example.txt
wget command to install Oracle JAVA JDK from stupid oracle website for centos and ubuntu
http://d.stavrovski.net/blog/post/how-to-install-and-setup-oracle-java-jdk-in-centos-6
# rpm
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.rpm" \
-O jdk-7-linux-x64.rpm
# ubuntu
@phamthaithinh
phamthaithinh / CachingSingletonAppender .java
Last active September 3, 2015 07:38 — forked from kengelke/CachingSingletonAppender .java
A custom log appender for log4j that allows one to catch log messages generated by log4j from within the application.
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.log4j.spi.LoggingEvent;
public class CachingSingletonAppender {
private static final CachingSingletonAppender theInstance = new CachingSingletonAppender();
private List<LogEventListener> listeners;
private List<LogEvent> eventCache;
@phamthaithinh
phamthaithinh / HelloServlet.java
Last active August 29, 2015 14:26 — forked from viralpatel/HelloServlet.java
HTML5 Server-Sent Events + Java Servlet example
package net.viralpatel.servlets;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@phamthaithinh
phamthaithinh / example.wsdl
Last active August 29, 2015 14:25
Example of a WSDL file to demonstrate the soapenv:mustUnderstand attribute usage
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://example.com/schema"
targetNamespace="http://example.com/schema">
<wsdl:types>
<xsd:schema targetNamespace="http://example.com/schema" elementFormDefault="qualified">
// takes the form field value and returns true on valid number
function valid_credit_card(value) {
// accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
var nCheck = 0, nDigit = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {