Monday, December 27, 2010

Interesting and Clever Facebook Status Messages



Pakistan may not have a Nuclear weapon, but they do have Imran Lakhani, and India cannot produce one. No matter how hard it tries. :)


Imran is Loved by Some, Hated by Many, Envied by Most, Yet Desired by Plenty.


More You Sweat In Peace, Less You Bleed In War.


All the desirable things in Life are either Illegal, Expensive, Fattening or Married to Someone Else.


Good Morning... I see the assassins have failed :)




scratch here ▒▒▒▒▒▒▒▒▒▒▒▒▒▒ to reveal today’s status.




I have an oven with a 'stop time' button. It's probably meant to be 'stop timer' but I don't touch it, just in case. ;)




Har cheez apne waqt par achi lagti hai, naiki karne ka sahi waqt hai "Jawani", hum "Naikiyan" us waqt karte hain jab "Buraiyan" karne ke qabil nahi rehte




Imran is Loading ████████████ 99%




Imran is experiencing life at a rate of several WTF's a minute




Imran is cle'a]ni.ng hi's ke]yb29oa;rd




Imran feels like getting some work done...and so I am sitting down until the feeling passes ;)






There are people who live their whole life in Default settings, never realize they can Customize it.




‎"2 GET & 2 GIVE" creates 2 many problems...
But
(Just double it)
"4 GET & 4 GIVE" solves All the problems...





(URDU)
Har Cheez Apne Waqt Par Achi Lagti Hai.
Naiki Karne ka sahi waqt Jawani Hai.
Hum Naikiyan us waqt Karte Hain, Jab Buraiyan Karne Kay Qabil Nahi Rehte


(ENGLISH)
Everything suits on Time
The Best Time for Good Deeds is Young Age
We do good deeds when we cannot commit more Sins.









Thursday, June 17, 2010

10 HR Interview Tips

The interview process nearly always includes a sit down with human resources as well as your potential future boss and colleagues. The folks in HR don’t know the most about the day-to-day requirements of the position being filled and they’re unlikely to have to deal with whoever gets the gig on a daily basis, so what exactly are they looking for and how do they determine whether you’ve made the cut?

Recently, opinionated blogger and experienced HR pro Laurie Ruettimann gives us job-hunting schmoes a break and offers a peak inside the mind of HR on her blog Punk Rock HR. Her ten tips are a must read for any job-hunter looking to wow human resources in an interview, and is particularly valuable for those new to the interview game.

  • Never badmouth anything or anyone. This applies to your former employer, coworkers, or Osama bin Laden. We’re trying to screen out whiners and troublemakers. I don’t care if your last supervisor was a tyrant. Be kind and magnanimous about everything and everyone.

  • Make sure your appearance is in order. Fair or not, you are judged based you based on how you look. Check your fly and make sure your eyebrows are smooth.

  • Don’t smoke on the day of the interview. We can smell it. We don’t like it. There is an unconscious bias against smokers, and let’s face it, you have a reputation for being lazy. Smokers are more expensive to insure, too. Why would we want you on the payroll? Help me help you. Don’t smoke.

  • Don’t be too aggressive and tell us how awesome you are. You’re here, aren’t you? A little humility, and some self-deprecating comments, will go along way with HR professionals. Trust me.

  • Don’t tell us your life story. We hate it when you confuse HR with your mother, your therapist, or your best friend.

  • Don’t expect us to have a timeline for the interview process. We have no idea how long it will take to fill the position. Ideally, we want to fill the opening tomorrow so we can get back to online shopping. Realistically, it will probably take a few months.

  • Be prepared to talk about your strengths and weaknesses. Don’t ever tell us that you struggle to delegate. You care too much. You take on too much responsibility. An interview is a conversation, not a bad eHarmony profile. Show some self-awareness.

  • When you take us through your resume, don’t gloss over the mistakes. We like it when you stop and tell us about an experience that taught you something. It shows character. Address your flaws outright and tell us how you learned something.

  • Compliment us. Seriously. We are human beings, too. Scan our offices and look for awards, photos, or something noteworthy. Make a connection. This is what salespeople do, and it works. We will remember your praise.

  • Make it easy for us to hire you. When you give us examples during the interview process, frame those examples in a way that relates to the job description, the issues in the industry, or the company’s mission. Be relevant and you will be remembered.

Monday, May 3, 2010

Iterating Over Files and Writing in Another Directory -- Java

Below is the sample code for iterating over all the files in a directory and copying them to another place.


package com.learn;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;


public class CopyFile {

public static void main(String[] args) {
try {
System.out.println("==================");
File dir = new File("/your/directory/path/");

File newDir = new File(dir.getAbsolutePath() + "/copy");
newDir.mkdir();

File[] files = dir.listFiles();
for (File file : files) {
if (!file.isDirectory()) {
FileReader in = new FileReader(file);
FileWriter out = new FileWriter(newDir.getAbsolutePath() + "/" + file.getName());
int c;
while ((c = in.read()) != -1)
out.write(c);

in.close();
out.close();
System.out.println(file.getName() + " is copied ");
}
}
System.out.println("==================");
} catch (Exception e) {
e.printStackTrace();
}
}

}

Wednesday, April 28, 2010

Hudson Address Bind Issue (java.net.BindException: Address already in use)

Hudson is a great software tool, but unfortunately yesterday as soon as I updated my hudson WAR, it stopped working and keeps giving me error below.

java.net.BindException: Address already in use
at java.net.PlainDatagramSocketImpl.bind0(Native Method)
at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82)
at java.net.DatagramSocket.bind(DatagramSocket.java:368)
at java.net.MulticastSocket.(MulticastSocket.java:147)
at java.net.MulticastSocket.(MulticastSocket.java:112)
at hudson.UDPBroadcastThread.(UDPBroadcastThread.java:58)
at hudson.model.Hudson.(Hudson.java:606)
at hudson.WebAppMain$2.run(WebAppMain.java:224)

It happens due to previous hudson application failed to close the port 33848.

It took my 2 hours but finally i was able to find the solution.

This is the line that saves my life :)
-Dhudson.udp=33849

Solution is the simple below line that need to be added in your tomcat's catalina.sh.

JAVA_OPTS="$JAVA_OPTS -Dhudson.udp=33849"


Reference: http://issues.hudson-ci.org/browse/HUDSON-5177

HTTP Clent 4 HTTP PUT Multipart Client Code Sample

Few days back got stuck in usage of HTTP Client 4.0 Library usage for Multi Part Put Request.
Finally found a workaround and thought to share with everyone.

Below is the Sample code.


import java.io.File;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.CoreProtocolPNames;
import org.apache.http.util.EntityUtils;


public class PutRequestTest {

public static void main(String[] args) {
try {
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);

HttpPost method = new HttpPost("http://localhost:8080/AdamService/service/sharedshelf/json/insertImage");

File file = new File("/Users/imranlakhani/a.JPG");
MultipartEntity mp = new MultipartEntity();
mp.addPart("projectId", new StringBody("1234", Charset.forName("UTF-8")));
mp.addPart("Name", new StringBody("image.jpg", Charset.forName("UTF-8")));
mp.addPart("username", new StringBody("imran", Charset.forName("UTF-8")));
mp.addPart("instituteId", new StringBody("2", Charset.forName("UTF-8")));
mp.addPart("password", new StringBody("", Charset.forName("UTF-8")));
FileBody fileBody = new FileBody(file);
mp.addPart("File", fileBody);
method.setEntity(mp);

System.out.println("executing request " + method.getRequestLine());
HttpResponse response = httpclient.execute(method);
HttpEntity resEntity = response.getEntity();

System.out.println(response.getStatusLine());
if (resEntity != null) {
System.out.println(EntityUtils.toString(resEntity));
}
if (resEntity != null) {
resEntity.consumeContent();
}

httpclient.getConnectionManager().shutdown();

} catch (Exception e) {
e.printStackTrace();
}

}
}