Lets assume that you are looking for TreeSize alternative in the Linux world. There are a few disk usage/cleanup tools available under GNome or KDE.
If you have some time, then cleaning up your home directory is pretty simple on the command line:
Assume you want to clean your /home directory.
$> du -H /home > cleanfile
Now when you open cleanfile in your text editor, you should see the files/directories. Looking at the directory names should tell you whether you need those dirs or now.
Wednesday, June 01, 2011
Wednesday, May 18, 2011
Scheduler Jobs in JBoss AS
If you are interested in scheduling tasks in JBoss AS, there are few pointers that you should look at and choose:
1) Quartz Scheduler
The EJB3 subsystem has quartz integration that you may want to utilize.
http://docs.jboss.org/ejb3/docs/tutorial/1.0.7/html/Quartz_scheduler_integration.html
http://community.jboss.org/wiki/HowtoconfigureaQuartzservice
Reference: http://www.quartz-scheduler.org/
2) Use java.util.Timer
You will need to create your own instances of timer tasks in your application.
3) JBoss Scheduler
http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/Additional_Services-
Scheduling_Tasks.html
Section 10.7 and 10.8 of http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/index.html
1) Quartz Scheduler
The EJB3 subsystem has quartz integration that you may want to utilize.
http://docs.jboss.org/ejb3/docs/tutorial/1.0.7/html/Quartz_scheduler_integration.html
http://community.jboss.org/wiki/HowtoconfigureaQuartzservice
Reference: http://www.quartz-scheduler.org/
2) Use java.util.Timer
You will need to create your own instances of timer tasks in your application.
3) JBoss Scheduler
http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/Additional_Services-
Scheduling_Tasks.html
Section 10.7 and 10.8 of http://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/index.html
Wednesday, April 06, 2011
org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS
If you see the following exception:
javax.xml.ws.soap.SOAPFaultException: org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS cannot be cast to javax.xml.rpc.handler.soap.SOAPMessageContext
it means that in your handler class, you are using javax.xml.rpc.handler.soap.SOAPMessageContext
rather than
import javax.xml.ws.handler.soap.SOAPMessageContext
javax.xml.ws.soap.SOAPFaultException: org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS cannot be cast to javax.xml.rpc.handler.soap.SOAPMessageContext
it means that in your handler class, you are using javax.xml.rpc.handler.soap.SOAPMessageContext
rather than
import javax.xml.ws.handler.soap.SOAPMessageContext
Sunday, March 27, 2011
HttpClient4 FORM authentication example
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
String URL = "http://localhost:8080/web/secured";
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(URL);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null)
entity.consumeContent();
// We should get the Login Page
StatusLine statusLine = response.getStatusLine();
System.out.println("Login form get: " + statusLine);
assertEquals(200, statusLine.getStatusCode());
System.out.println("Initial set of cookies:");
List cookies = httpclient.getCookieStore().getCookies();
if (cookies.isEmpty()) {
System.out.println("None");
} else {
for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } // We should now login with the user name and password HttpPost httpost = new HttpPost(URL + "/j_security_check"); List nvps = new ArrayList();
nvps.add(new BasicNameValuePair("j_username", user));
nvps.add(new BasicNameValuePair("j_password", pass));
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
response = httpclient.execute(httpost);
entity = response.getEntity();
if (entity != null)
entity.consumeContent();
statusLine = response.getStatusLine();
// Post authentication - we have a 302
assertEquals(302, statusLine.getStatusCode());
Header locationHeader = response.getFirstHeader("Location");
String location = locationHeader.getValue();
HttpGet httpGet = new HttpGet(location);
response = httpclient.execute(httpGet);
entity = response.getEntity();
if (entity != null)
entity.consumeContent();
System.out.println("Post logon cookies:");
cookies = httpclient.getCookieStore().getCookies();
if (cookies.isEmpty()) {
System.out.println("None");
} else {
for (int i = 0; i < cookies.size(); i++) {
System.out.println("- " + cookies.get(i).toString());
}
}
// Either the authentication passed or failed based on the expected status code
statusLine = response.getStatusLine();
assertEquals(expectedStatusCode, statusLine.getStatusCode());
} finally {
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
}
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.cookie.Cookie;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
String URL = "http://localhost:8080/web/secured";
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(URL);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null)
entity.consumeContent();
// We should get the Login Page
StatusLine statusLine = response.getStatusLine();
System.out.println("Login form get: " + statusLine);
assertEquals(200, statusLine.getStatusCode());
System.out.println("Initial set of cookies:");
List
if (cookies.isEmpty()) {
System.out.println("None");
} else {
for (int i = 0; i < cookies.size(); i++) { System.out.println("- " + cookies.get(i).toString()); } } // We should now login with the user name and password HttpPost httpost = new HttpPost(URL + "/j_security_check"); List
nvps.add(new BasicNameValuePair("j_username", user));
nvps.add(new BasicNameValuePair("j_password", pass));
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
response = httpclient.execute(httpost);
entity = response.getEntity();
if (entity != null)
entity.consumeContent();
statusLine = response.getStatusLine();
// Post authentication - we have a 302
assertEquals(302, statusLine.getStatusCode());
Header locationHeader = response.getFirstHeader("Location");
String location = locationHeader.getValue();
HttpGet httpGet = new HttpGet(location);
response = httpclient.execute(httpGet);
entity = response.getEntity();
if (entity != null)
entity.consumeContent();
System.out.println("Post logon cookies:");
cookies = httpclient.getCookieStore().getCookies();
if (cookies.isEmpty()) {
System.out.println("None");
} else {
for (int i = 0; i < cookies.size(); i++) {
System.out.println("- " + cookies.get(i).toString());
}
}
// Either the authentication passed or failed based on the expected status code
statusLine = response.getStatusLine();
assertEquals(expectedStatusCode, statusLine.getStatusCode());
} finally {
// When HttpClient instance is no longer needed,
// shut down the connection manager to ensure
// immediate deallocation of all system resources
httpclient.getConnectionManager().shutdown();
}
Saturday, February 12, 2011
Walgreens Thermometer :: Change Celsius to Fahrenheit
1) Push the button to get the thermometer ON.
2) Wait for the L with the little C on the screen.
3) Then HOLD the button down until it changes to Fahrenheit (indicating F).
You will see the little F on the top right of the screen next to the L.
That is it. If you are unsuccessful, repeat the above process.
2) Wait for the L with the little C on the screen.
3) Then HOLD the button down until it changes to Fahrenheit (indicating F).
You will see the little F on the top right of the screen next to the L.
That is it. If you are unsuccessful, repeat the above process.
Monday, February 07, 2011
Tip: SSH Client Issues
Sometime you may see issues such as the following:
Issue 1: Public Key issue
============
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
============
Solution: Look inside the .ssh directory in your home directory. Do you see .ssh/id_rsa.pub? If not, try to get it from your backup or generate a fresh key pair (and pass the public key to your server admin).
Issue 2: ssh config file permission issue
==============
Bad owner or permissions on /home/anil/.ssh/config
fatal: The remote end hung up unexpectedly
==============
Solution: chmod 600 ~/.ssh/config
Issue 3: Unprotected Private key file
===============
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0775 for '/home/anil/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /home/anil/.ssh/id_rsa
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
==================
Solution: chmod 600 ~/.ssh/*
Issue 1: Public Key issue
============
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
============
Solution: Look inside the .ssh directory in your home directory. Do you see .ssh/id_rsa.pub? If not, try to get it from your backup or generate a fresh key pair (and pass the public key to your server admin).
Issue 2: ssh config file permission issue
==============
Bad owner or permissions on /home/anil/.ssh/config
fatal: The remote end hung up unexpectedly
==============
Solution: chmod 600 ~/.ssh/config
Issue 3: Unprotected Private key file
===============
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0775 for '/home/anil/.ssh/id_rsa' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /home/anil/.ssh/id_rsa
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
==================
Solution: chmod 600 ~/.ssh/*
Sunday, January 23, 2011
Tip: Calculate distance between two GPS endpoints on Blackberry
If you are in need of determining the distance between two geo coordinates on blackberry, use the following piece of code.
====
import javax.microedition.location.Coordinates;
private double difference( double currentLat, double currentLon, double startLat, double startLon )
{
Coordinates current = new Coordinates(currentLat, currentLon, 0);
Coordinates start = new Coordinates(startLat, startLon, 0);
float diffInMetres = current.distance(start);
return diffInMetres * 0.000621371192; //Convert into miles
}
====
====
import javax.microedition.location.Coordinates;
private double difference( double currentLat, double currentLon, double startLat, double startLon )
{
Coordinates current = new Coordinates(currentLat, currentLon, 0);
Coordinates start = new Coordinates(startLat, startLon, 0);
float diffInMetres = current.distance(start);
return diffInMetres * 0.000621371192; //Convert into miles
}
====
Friday, January 21, 2011
Tip: Eclipse and Linux Installation Troubleshoot
Problem: After installing Eclipse on Linux, if you get:
"Failed to load the JNI shared library /usr/java/jdk1.6.0_23/jre/bin/../lib/i386/client/libjvm.so"
or
"/opt/java/jdk1.6.0_23/bin/../jre/lib/i386/client/libjvm.so: cannot enable executable stack as shared object requires: Permission denied"
Solution:
If you have sudo rights,
$> sudo chcon -t execmem_exec_t '/opt/eclipse/eclipse'
"Failed to load the JNI shared library /usr/java/jdk1.6.0_23/jre/bin/../lib/i386/client/libjvm.so"
or
"/opt/java/jdk1.6.0_23/bin/../jre/lib/i386/client/libjvm.so: cannot enable executable stack as shared object requires: Permission denied"
Solution:
If you have sudo rights,
$> sudo chcon -t execmem_exec_t '/opt/eclipse/eclipse'
Subscribe to:
Posts (Atom)