Recent Notes
Displaying keyword search results 1 - 10
Created by voodoo on January 03, 2012 08:41:21
Last update: February 16, 2012 15:50:06
This is the command to print all regular files in the src folder but excluding all files within the .svn folders:
$ find src -name .svn -prune -o -type f -print
where -o is the or operator.
Define a shortcut:
ff ()
{
find $1 -name .svn -prune -o -...
Created by Dr. Xi on February 03, 2011 13:47:22
Last update: February 03, 2011 13:47:22
Read a directory and sort files by modified date (oldest to newest):
$dirname = ".";
opendir(DIR, $dirname) or die $...
Same, but with glob (note that the output is a bit different):
$dirname = ".";
@files = sort { -M $b <=> -M $...
Switch the places of $a and $b to order from newest to oldest.
Created by Dr. Xi on February 01, 2011 14:38:55
Last update: February 01, 2011 14:40:59
Create the stuff you want to manufacture with the factory:
package tc.demo;
public class Junk {
...
Create the factory:
package tc.demo;
import java.util.Enumerati...
Tell Tomcat to use your factory. Create file context.xml and put it under the directory META-INF of your web application:
<Context>
<Resource name="/find/junk/here"
...
Note that beside name , type and factory , you can put any arbitrary attribute in the Resource element.
Access the thing with JNDI:
<%@page language="java" import="javax.naming.*,tc....
The server side log looked like this:
INFO: jndiName: here
INFO: name: scope, value: ...
Also note that, in contrast to Tomcat documentation , resource-ref is not needed in web.xml .
Created by Fang on April 03, 2010 20:21:15
Last update: April 04, 2010 03:30:22
The tags <c:out> The <c:out> tag evaluates an expression and outputs the result on the page. The syntax is:
<c:out value="value" [escapeXml="{true|false}"] ... where escapeXml defaults to true and default defaults to empty string "". <c:out value="${expr}" escapeXml="false"/> is equivalent to ${expr} . If a variable is set in multiple scopes, the lower scope wins. In the following example code, attribute1 is set in request, session, and application scopes; attribute2 is set in session and application scopes; attribute3 is set in the application scope. The results are: <c:out value="${attribute1}"/> : Attribute1 request scope <c:out value="${attribute2}"/> : Attribute2 session scope <c:out value="${attribute3}"/> : Attribute3 application scope To access values in higher scopes, you have to specify the scope explicitly, like this: <c:out value="${sessionScope.attribute1}"/> : Attribute1 session...
Created by Fang on April 01, 2010 22:24:58
Last update: April 02, 2010 02:49:38
In this note I'll show you how to create and package a JSP custom tag. The purpose of this tag is to display a random splash image for a home page, among a set of images. We should be able to add or delete candidate splash images from the WAR archive without the need to change the JSP. This is the intended use of the tag:
<%@ taglib uri="http://custom.tag.com/demo" prefix... In the above example you provide a set of images named splash*.png (e.g., splash1.png, spalsh2.png, ...), and the tag will pick a random one to display when the JSP is rendered. Let's get started. I'll use Maven for this purpose. Create the standard Maven directory structure ./pom.xml ./src ./src/main ./src/main/jav... pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0"... SplashTag.java package tagdemo; import java.util.ArrayList......
Created by Dr. Xi on December 11, 2007 22:10:28
Last update: January 14, 2010 03:39:31
The subroutine recurse traverses a directory tree. The function to be performed, which works on the current file with optional parameters, is passed in as a parameter.
# perl - recursive dirctory tasks
# 1. recursiv...
Created by Dr. Xi on December 04, 2009 04:33:05
Last update: December 04, 2009 04:33:05
Variable Meaning $_ The default or implicit variable. @_ Within a subroutine the array @_ contains the parameters passed to that subroutine. $a, $b Special package variables when using sort() $<digit> Contains the subpattern from the corresponding set of capturing parentheses from the last pattern match, not counting patterns matched in nested blocks that have been exited already. $. Current line number for the last filehandle accessed. $/ The input record separator, newline by default. $| If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after...
Created by Dr. Xi on October 18, 2009 04:25:25
Last update: October 18, 2009 04:25:25
start python with python -v
import django and print version:
Type "help", "copyright", "credits" or "license" f...
Created by Dr. Xi on December 16, 2008 21:17:15
Last update: December 16, 2008 21:19:04
The -h switch prints file or directory sizes in human readable format:
# disk usage for current directory
$ du -ks...
Created by Dr. Xi on September 25, 2008 23:16:04
Last update: September 25, 2008 23:16:04
In Perl, you can use the global hash %ENV to get and set environment variables. For example, you may want to add your home directory to PATH in order to start an executable in the directory.
#!/usr/bin/perl
$ENV{'PATH'} = '/bin:/usr/b...