This notebook is a collection of code snippets and technical "how to" instructions.
Search This Blog
Eclipse Ganymede J2EE plugins
by: Uki D. LucasGoogle AppEngine:
Google AppEngine - Eclipse Ganymede Installation
by: Uki D. Lucas- Verify installation of Eclipse Ganymede IDE for J2EE development
- open Help -> Software Updates ...
- add new site http://dl.google.com/eclipse/plugin/3.4
Google project hosting
by: Uki D. LucasYou can host your projects using code.google.com SVN repository.
- sign up to your google account
- go to http://code.google.com/hosting/
- click "Create a new project"
- go to "Source" Tab
- check out the code using command line SVN, or Eclipse SVN plugin (tigris)
- add your files (when you copy from previous SVN project remove all .SVN folders )
- commit
Java String parser
by: Zainab AzizTo split a String into words (tokens) where delimiter is white space...
String delims = "[ ]+";
String[] tokens = someLongString.split(delims);
Now you can look thru the tokens and do comparisons, etc.
CSS: centering DIV
by: Uki D. Lucas<body><div class="background">The centered content is here
Using Composite Class
by: Jordan BeckInteractive Map Implementation
by: Zainab AzizFunction To Censor String
by: Jordan Beckpublic String censorString(String originalString)
{
StringBuffer orig = new StringBuffer(originalString);
Pattern p = Pattern.compile("[0-9/A-Z/a-z]+");
Matcher m = p.matcher(orig);
StringBuffer censor = new StringBuffer();
boolean result = m.find();
while (result)
{
String match = originalString.substring(m.start(), m.end());
if(match.equals("badword"))
m.appendReplacement(censor, "[censored]");
result = m.find();
}
m.appendTail(censor);
return censor.toString();
}
Adding maven and SVN plugin to Eclipse 2.4.2
by: Zainab AzizGWT Client Side Date / Calculate Age
by: Jordan BeckDate today = new Date();
Integer currentYear = new Integer(DateTimeFormat.getFormat("yyyy").format(today));
Integer currentMonth = new Integer(DateTimeFormat.getFormat("M").format(today));
Integer currentDay = new Integer(DateTimeFormat.getFormat("d").format(today));
Age calculating function:
public static int calculateAge(Date dob)
{
Date today = new Date();
Integer currentYear = new Integer(DateTimeFormat.getFormat("yyyy").format(today));
Integer currentMonth = new Integer(DateTimeFormat.getFormat("M").format(today));
Integer currentDay = new Integer(DateTimeFormat.getFormat("d").format(today));
Integer dobYear = new Integer(DateTimeFormat.getFormat("yyyy").format(dob));
Integer dobMonth = new Integer(DateTimeFormat.getFormat("M").format(dob));
Integer dobDay = new Integer(DateTimeFormat.getFormat("d").format(dob));
int age = currentYear - dobYear;
if((dobMonth > currentMonth) || (currentMonth == dobMonth && dobDay > currentDay))
age--;
return age;
}