July 20, 2004

The Difference Between #include <iostream> and #include

If a compiler supports both and , the headers are subtly different.In particular, if you include , you get the elements of the iostream library enclosedwithin the namespace std. If you include , you get those same elements at global scope. Getting them at global scope can lead to name

Count the Number of Occurrences of a String Within a String

The select statement below takes the name “george” and finds how many occurrences of “ge” appear within it. select (length(‘george’) – length (replace(‘george’,’ge’,”))) / length(‘ge’) countfrom dual/ COUNT———- 2 Using this information, you could write a function like the one below: create function countStr(document varchar2,search varchar2) return number is counter

Look Up a DataSource Object in Your Web Server

This code demonstrates how to look up a DataSource object in your Web server using JNDI Lookup. import javax.sql.DataSource;import java.util.Hashtable;import javax.naming.InitialContext;public void findDatasource() { // Initializing DataSource object DataSource dataSource = null; //Setting the jndi datasource path String jndiDataSourcePath = “Name_of_your_Datasource”; //Set the initial context factory. For our purpose, we

Generate a Graph of Your Ant File Targets with Vizant

When you’re dealing with huge Ant files, it can be difficult to follow targets and their dependencies.Luckily, there’s a tool called Vizant that can generate a graph of your Ant file targets. You simply specify the name of your Ant file, and voila?Vizant generates the graph for you. Here is

Sort a Collection of Objects

Suppose you have objects of type MyClass. Further assume that you have a collection (named myCollection) containing objects of type MyClass. To sort this collection, follow these steps: MyClass must implement java.lang.Comparable which has the single method: public int compareTo(Object obj) throws ClassCastException; Implement this method in MyClass. This method

Track Process Runtime for Perl Scripts

For any script that takes more than just a few seconds to run, it’s always a good idea to track the runtime itself. This is especially useful in the development stage, but it can also be a valuable resource for production scripts that are modified over time. You’d want to

Power Python: Do More with Less Code

hat’s Power Python, you ask? It’s the effective use of Python language features to get a lot of work done in fewer lines of code. The lambda, reduce, filter, map, and list comprehension constructs are some of the features that best fit this definition. This article examines each one in