Performance Zone is brought to you in partnership with:
DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
  • submit to reddit
Nicolas Frankel08/11/14
5102 views
0 replies

Sanitizing webapp outputs as an an afterthought

For sure, software security should be part of every developer’s requirements: they should be explained and detailed before development. Unfortunately, it happens in real life that this is not always the case. I’ve been thinking about a way to sanitize the output of a large-scale legacy Spring MVC application in a reliable way (i.e. not go on each page to fix issues).

Robert Greathouse08/11/14
5394 views
0 replies

Create Your Own Private Docker Registry

Shortly after you start building docker containers you will realize that you need some place to publish your images. You could push to the central docker registry. However, the central registry is public. Not a great idea if you are working on a private project.

David Catuhe08/08/14
6362 views
1 replies

JavaScript: using closure space to create real private members

Closure space properties can be a great way to create really private data. You may have to deal with a small increase in memory consumption but from my point of view this is fairly reasonable.

Niels Matthijs08/07/14
9200 views
2 replies

On Messing Up and Missing Deadlines

Looking at all the projects I've worked on over the years, big or small, there's been one nasty constant. A mistake that creeps up on you at least once a project and puts an indelible mark on all future work. And it has everything to do with not sticking to the optimal workflow.

Michael Mccandless08/07/14
4710 views
0 replies

A new proximity query for Lucene, using automatons

As of Lucene 4.10 there will be a new proximity query to further generalize on MultiPhraseQuery and the span queries: it allows you to directly build an arbitrary automaton expressing how the terms must occur in sequence, including any transitions to handle slop.

Hubert Klein Ikkink08/07/14
3443 views
0 replies

Grails Goodness: Using Bintray JCenter as Repository

Bintray JCenter is the next generation (Maven) repository. The repository is already a superset of Maven Central, so it can be used as a drop-in replacement for Maven Central.

Alec Noller08/07/14
6021 views
0 replies

SQL Performance Disasters: Your DBA Just Wants to Help

Your DBA just wants to help. And when you're working with large sets of data - or any sets of data, really - sometimes that's the help you need, because small mistakes can quickly balloon into large ones.

Troy Miles08/07/14
3429 views
0 replies

Ten Groovy Little JavaScript Tips

I gave this talk last year and it is still valid information. The best part is that the tips are quick and easy.

Mike Cottmeyer08/07/14
6081 views
0 replies

Agile in a Remote Workplace World

How do you enable collaboration when team members are working from home? How do remote teams engage in stand up meetings, sprint planning sessions, retrospective meetings, and other Agile ceremonies?

Swathi Venkatachala08/07/14
2986 views
1 replies

Raspberry Pi B+: Connect to your Pi with no display monitor, keyboard or mouse

The moment I had this credit card sized thing on my palm, I was so excited to get started with it. But then, wait! Do you need a HDMI TV or display monitor, USB keyboard and a USB mouse to connect to it? Oh really!? I was not interested to invest any further. Here is what I did.

//open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("/mnt/sdcard/input.pdf");
//create text stamp
com.aspose.pdf.TextStamp textStamp = new com.aspose.pdf.TextStamp("Sample Stamp");
//set properties of the stamp
textStamp.setTopMargin(10);
textStamp.setHorizontalAlignment(com.aspose.pdf.HorizontalAlignment.Center);
textStamp.setVerticalAlignment(com.aspose.pdf.VerticalAlignment.Top);

//set text properties
textStamp.getTextState().setFont(new com.aspose.pdf.FontRepository().findFont("Arial"));
textStamp.getTextState().setFontSize(14.0F);
textStamp.getTextState().setFontStyle(com.aspose.pdf.FontStyles.Bold);
textStamp.getTextState().setFontStyle(com.aspose.pdf.FontStyles.Italic);
textStamp.getTextState().setForegroundColor(java.awt.Color.GREEN);

// iterate through all pages of PDF file
for (int Page_counter =1; Page_counter<=pdfDocument.getPages().size();Page_counter++)
{
    //add stamp to all pages of PDF file
    pdfDocument.getPages().get_Item(Page_counter).addStamp(textStamp);
}
//save output document
pdfDocument.save("/mnt/sdcard/TextStamp_output.pdf");

Alec Noller08/06/14
14900 views
0 replies

Dev of the Week: Andreea Borcea

This week we're talking to Andreea Borcea, developer of patient-empowering solutions for the healthcare industry, co-host of Farstuff: The IoT Podcast, and featured author in DZone's 2014 Guide to Internet of Things.

Alec Noller08/06/14
12444 views
0 replies

The Best of DZone: July 29 - August 5

If you missed anything on DZone this week, now's your chance to catch up! This week's best include the ultimate guide to Java 8 features, a beginner's guide to JPA/Hibernate entity state transitions, when to dump Scrum for Kanban, and more.

Andrew Gilmartin08/06/14
7568 views
0 replies

Logging and the utility of message patterns

We use a logging layer over log4j to encourage our developers to log at any point in the code where they thought some extra context would help resolve runtime errors. The layer had to have a familiar API, be effortless to code, and cheap to call. This posting is mostly about the cost to call the logger and a little about enhancing the presentation of logged values.

Chase Seibert08/05/14
13561 views
1 replies

Why software engineers should maintain a blog

I have a few pieces of standard advice that I give to anyone starting out in software engineering. Join a startup, max out your 401k and start a blog. Why should you start blogging?

Trevor Parsons08/05/14
7804 views
0 replies

How to combine D3 with AngularJS

As we all know, Angular and D3 frameworks are very popular, and once they work together they can be very powerful and helpful when creating dashboards.

Ian Mitchell08/05/14
5029 views
0 replies

Pattern of the Month: Minimum Viable Product

Minimum Viable Product is a term for which we might expect a rigorous definition, but it actually means different things to different people. In this article we consider the intent and motivation behind MVP's and discern the pattern behind their usage.

Lijin Joseji08/05/14
4741 views
0 replies

6 sparkling features of Apache Spark!

What is Apache Spark? Why there is a serious buzz going-on about this? If you are in the Big Data analytics business, should you really care about Spark? I hope this post will help to answer some of these questions which might have coming to your mind these days.

Mike Bushong08/05/14
1534 views
0 replies

At the office, are you a doctor or a patient?

Every interaction with your management chain is effectively a dress rehearsal for your career. With this in mind, be mindful of whether the conversation you initiate is closer to a doctor-patient or a doctor-doctor discussion.

MainActivity.java :

package www.andygeeks.blogspot.com;

import java.net.SocketTimeoutException;
import java.net.UnknownHostException;

import org.json.JSONArray;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
    
boolean timeoutexcep=false,httpexcep=false,genexcep=false;
    
private static final String TAG_NAME = "J_Name";
private static final String TAG_ID = "J_Id";
private static final String TAG_PLACE = "J_Place";
private static final String TAG_MOBILE = "J_Phone";
    
public static String dist="Krishnagiri",type="P",no="50";
String Name,Id,Place,Phone;
    
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new pay().execute();
}

class pay extends AsyncTask<Void, Void, Void> {

private final ProgressDialog dialog = new ProgressDialog(MainActivity.this);

@Override
protected void onPreExecute() {
this.dialog.setMessage("Loading data");
this.dialog.show();
}

@Override
protected Void doInBackground(Void... unused) {

final String NAMESPACE = "http://tempuri.org/";
final String URL = "http://www.xxxxxx.com/xxxx/xxx.asmx";
final String SOAP_ACTION = "http://tempuri.org/xxxxx";
final String METHOD_NAME = "xxxxx";

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

request.addProperty("sDistrict", dist);
request.addProperty("sTaxType", type);
request.addProperty("sTaxNo", no);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;

envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;

try {
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

String responseJSON=response.toString();
JSONArray jarray =new JSONArray(responseJSON);

Name=jarray.getJSONObject(0).getString(TAG_NAME);
Id=jarray.getJSONObject(0).getString(TAG_ID);
Place=jarray.getJSONObject(0).getString(TAG_PLACE);
Phone=jarray.getJSONObject(0).getString(TAG_MOBILE);

System.out.println(request);
System.out.println(responseJSON);

}
catch(SocketTimeoutException e){
timeoutexcep=true;
e.printStackTrace();
}
catch(UnknownHostException e){
httpexcep=true;
e.printStackTrace();
}
catch (Exception e) {
genexcep=true;
e.printStackTrace();
}
return null;
}

@Override
protected void onPostExecute(Void result) {
if (this.dialog.isShowing()) {
this.dialog.dismiss();
}
if(timeoutexcep){
Toast.makeText(MainActivity.this, "Unable to connect to server, Please try again later",Toast.LENGTH_LONG).show();
}
else if(httpexcep){
Toast.makeText(MainActivity.this, "Please check your Internet connection",Toast.LENGTH_LONG).show();
}
else if(genexcep){
Toast.makeText(MainActivity.this, "Please try later",Toast.LENGTH_LONG).show();
}

else{
tableview();
}
timeoutexcep=false;httpexcep=false;genexcep=false;
}
}

public void tableview(){
try{
TextView name = (TextView)findViewById(R.id.textView5);
name.setText(Name);

TextView door = (TextView)findViewById(R.id.textView6);
door.setText(Id);

TextView ward = (TextView)findViewById(R.id.textView7);
ward.setText(Place);

TextView mobile = (TextView)findViewById(R.id.textView8);
mobile.setText(Phone);
}
catch(Exception e){
}
}
    
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}