Notes by Dr. Xi
Displaying keyword search results 1 - 10
Created by Dr. Xi on March 08, 2012 12:13:57
Last update: March 08, 2012 12:13:57
This example creates an instance of XMLGregorianCalendar and converts it to java.util.Date :
import java.util.Date;
import javax.xml.datatyp...
Created by Dr. Xi on May 02, 2011 15:59:37
Last update: February 25, 2012 09:16:37
This code snippet gets the default keystore used by the Java keytool and displays the list of aliases along with the key type (certificate or private key).
import java.io.File;
import java.io.FileInputSt...
The default keystore used by the above code is: $HOME/.keystore .
Created by Dr. Xi on February 01, 2012 12:55:28
Last update: February 01, 2012 12:55:28
You can define environment variables in the Tomcat context.xml file like this:
<?xml version="1.0" encoding="UTF-8"?>
<Context...
which is equivalent to the following in web.xml :
<env-entry>
<env-entry-name>varName</env-entr...
In Java code, the variable can be looked up like this:
// import javax.naming.Context;
// import javax...
Created by Dr. Xi on January 17, 2012 11:58:16
Last update: January 17, 2012 11:58:16
Steps to configure JavaMail resource for Tomcat 6 & 7:
Install JavaMail jar: download the JavaMail API , unzip the archive and copy mail.jar to $CATALINA_HOME/lib .
Add JavaMail resource to $CATALINA_BASE/conf/context.xml :
<?xml version="1.0"?>
<Context>
.
...
Add resource-ref for the JavaMail resource to your webapp WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app...
Use the JavaMail resource in your webapp:
// import javax.naming.*;
// import javax.mail....
Created by Dr. Xi on November 11, 2011 10:05:22
Last update: November 11, 2011 10:12:01
This is an HTML image tag filter using Java regex. It takes a string, finds the img tags, replaces the src attribute with one provided by the filter, then adds a class name to the class attribute.
import java.util.regex.*;
import java.io.*;
...
Test file:
<div id="HTML snippet">
<img src="img/big/txt-m...
Created by Dr. Xi on September 24, 2011 20:59:16
Last update: September 24, 2011 21:00:20
To import source from my-project into the svn repository:
$ svn import my-project/ file:///home/drxi/work/sv...
List the contents of the repository:
$ svn ls file:///home/drxi/work/svn-repository/
...
List the contents of the newly imported project:
$ svn ls file:///home/drxi/work/svn-repository/my-...
Created by Dr. Xi on October 01, 2007 03:26:46
Last update: August 25, 2011 08:57:40
Use the sub function in the re module to do global replacement:
import re
re.sub(pattern, replacement, inpu...
Created by Dr. Xi on August 10, 2011 14:58:49
Last update: August 10, 2011 14:58:49
In python:
#!/usr/local/bin/python
import sys
if sys.ve...
In shell script:
#!/bin/bash
PYTHON=/usr/local/bin/python
...
Created by Dr. Xi on August 02, 2011 15:44:45
Last update: August 02, 2011 15:44:45
The time module provides functions for time manipulation:
$ python
Python 2.7 (r27:82500, Sep 16 2010, 18...
Created by Dr. Xi on July 27, 2011 08:55:34
Last update: July 27, 2011 08:55:34
It is OK to remove elements from a list with Iterator , but you get UnsupportedOperationException if the list is created with Arrays.asList :
import java.util.*;
public class IteratorRe...
Prints:
ArrayList test:
================
List size: ...