Posts

How to measure distance on google maps ?

Use the page here , you just click on points and the distance will appear either in miles or in kilometers. You can also mark multiple points and calculate a real length of a path.

Check if a String contains letter

public static boolean containsLetter(String s) { if ( s == null ) return false; boolean letterFound = false; for (int i = 0; !letterFound && i letterFound = letterFound || Character.isLetter(s.charAt(i)); return letterFound; }

Get MimeType of A File

Use activation.jar to access javax.activation API. File file = new File("foo.jpg"); String mimeType = new MimetypesFileTypeMap().getContentType(file)); // image/jpeg alternatively , you can use filename to detech the mime type : String mimeType = new MimetypesFileTypeMap().getContentType("foo.jpg")); // image/jpeg

Redirect StdErr to Stdin in Batch and Shell Scripts

On windows command prompt : mybatch.bat 1> log.txt 2>&1 This redirects stdin to log.txt and stderr to stdin On Bash Linux Shell: grep * &> allout.txt

Get Remote IP Address In Axis SOAP Server

Obtain remote IP from ServletRequest (Axis 1.0 only) import javax.servlet.http.HttpServletRequest; import org.apache.axis.MessageContext; import org.apache.axis.transport.http.HTTPConstants; public static String getSOAPRemoteIP() { MessageContext context = MessageContext. getCurrentContext (); String address = null ; if (context!=null && context.containsProperty(HTTPConstants. MC_HTTP_SERVLETREQUEST )) { HttpServletRequest servletReq = (HttpServletRequest) context.getProperty(HTTPConstants. MC_HTTP_SERVLETREQUEST ); if (servletReq != null ) address = servletReq.getRemoteAddr(); } return address; }

Google Chrome Ready For Download

Google has released a new browser named Google Chrome. This browser is expected to become most widespred computer program ever written. Google Chrome will set the standarts for Web2.0 and Web3.0 technologies. Chrome is a ligtweight browser and does not consume your CPU and memory and it makes Chrome fast and reliable. Download Here Here is a gread comic book for chrome on googlebooks site At first impression Google Chrome is not working properly with PHP-Admin !!!

Console Beep On Error Line of a Log File

Ok folks , this is non-java :) Today I had to watch a log file and alert some ppl when an error phrase seen on log file. This is a terrible jıb todo. First I run on my linux server: #tail -f mylogfile | grep ERRORSTRING this worked but put me in front of the screen. Why not my console beep when ERRORSTRING exists in the log file ? I need an application to beep when read a line from stdin. This is piece of cake in java but i did not want to load JVM for this purpose because of memory needs. So I warped to good old days and decided to write a C program to do this job. #include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char *argv[]) { char buf[1024]; int n; while (fgets(buf, sizeof buf, stdin) != NULL) { n = strlen(buf); if (n > 0 && buf[n-1] == '\n') { printf("\a"); printf("%s\n", buf); ...