Agile 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
Rob J Hyndman08/14/14
0 replies

What not to say in a job interview

I’ve interviewed a few people for jobs at Monash University, and there’s always someone who comes out with something surprising. Here are some real examples.

//Load a diagram
Diagram diagram = new Diagram("C:\\Drawing1.vdx");

//Get first page
if (diagram.getPages().getCount() == 0)
    JOptionPane.showConfirmDialog(null, "The diagram does not contain pages.");
Page page0 = diagram.getPages().getPage(0);
//Get the rectangle master
Master masterRectangle = null;
for (Master master : (Iterable<Master>) diagram.getMasters())
    if (master.getName() == "Rectangle")
        masterRectangle = master;
if (masterRectangle == null)
    JOptionPane.showConfirmDialog(null, "The diagram does not contain rectangle's master.");
//Get the next shape ID
long nextID;
for (Page page : (Iterable<Page>)diagram.getPages())
    for (Shape shape : (Iterable<Shape>) page.getShapes())
        long temp = GetMaxShapeID(shape);
        if (temp > nextID)
            nextID = temp;
//Set shape properties and add it in the shapes' collection
Shape rectangle = new Shape();
rectangle.getText().getValue().add(new Txt("Aspose Diagram"));
page0.getShapes().add(rectangle);"C:\\output.vdx", SaveFileFormat.VDX);
JOptionPane.showConfirmDialog(null, "Shape has been added.");

private long GetMaxShapeID(Shape shape)
    long max = shape.getID();
    for (Shape child : (Iterable<Shape>)shape.getShapes())
        long temp = GetMaxShapeID(child);
        if (temp > max)
            max = temp;
    return max;

Context XML (userDAO-queries.xml) part :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
<util:map id="VALIDATE_USER_CREDENTIAL" key-type="java.lang.String" value-type="java.lang.String" >
    	<entry key="QUERY" >
    		 <value>SELECT	user_id,	 user_name,  user_password 
			FROM	ty_users 
			WHERE	user_name = ? AND user_password = ?

Java Code Part:
public class UserDAOImpl implements UserDAO{
	private static final Logger logger = LoggerFactory.getLogger(UserDAOImpl.class);// logger
	DBQueries dbQuery = new DBQueriesImpl("userDAO-queries.xml");//
	DBConnection dbConn = ConnectionFactory.getInstance().getConnectionMySQL();
	public List<User> authenitcUserDetails(String userName, String userPassword) {
		Map<String, String> queryMap = null;
		String query ;
		List<Map<String, Object>> mappedUserList = null;
		List<User> listUser = null;
			listUser = new ArrayList<User>();
			queryMap = dbQuery.getQueryBeanFromFactory("VALIDATE_USER_CREDENTIAL"); //passing the query-name or Map Id.
			query =  dbQuery.getQuery(queryMap);//passing the query-map to get the query.

//rest of the code is common fetching code.						
			mappedUserList = dbConn.dbQueryRead(query, new Object[]{userName,userPassword});			
				listUser =  new QueryResultSetMapperImpl<User>().mapRersultSetToObject(mappedUserList, User.class);
		}catch(Exception  ex){
			logger.error("fetchAllUser Error:: ", ex);
		return listUser;
public class DBQueriesImpl implements DBQueries {
	private static final Logger logger = LoggerFactory.getLogger(DBQueriesImpl.class);
	private ApplicationContext queriesCtx ;
	 * @Desc: Loading the queryContext xml
	 * @param queryContext
	public DBQueriesImpl(String queryContext) {
		queriesCtx = new ClassPathXmlApplicationContext(queryContext);
	 * @Desc: Reading from the loaded application context and getting the query-map, .  
	public Map<String, String> getQueryBeanFromFactory(String beanId){
		Map<String, String> queryMap = null;
		if (queriesCtx != null && beanId != null) {
			queryMap = (Map<String, String>)queriesCtx.getBean(beanId);
		return queryMap;
	 * @Desc: Getting the exact query from the query-map, .  
	public String getQuery(Map<String, String> queryMap) {
		String query=null;
				query = (String) queryMap.get(QueryConstants.QUERY_NODE);
				throw new NoSuchFieldError();
		}catch(Exception excp){
		return query;
    <title>Hello React</title>
    <link rel="stylesheet" href="//">
    <script src=""></script>
    <script src=""></script>
    <script src=""></script>
    <div class="container">
      <div class="page-header">
        <h1>ReactJS Hello World - Code Example</h1>
      <div id="sayhello"></div>  
    <script type="text/jsx">
      /** @jsx React.DOM */
      // This is the parent component comprising of two inner components
      // One of the component is UserName which is used to allow user to enter their name
      // Other component is HelloText which displays the text such as Hello, World
      var SayHello = React.createClass({
        // This is used to set the state, "data" which is 
        // accessed later in HelloText component to display the updated state
        getInitialState: function() {
          return {data: 'World'}
        // It is recommended to capture events happening with any children
        // at the parent level and set the new state that updates the children appropriately
        handleNameSubmit: function(name) {
          this.setState({data: name});
        // Render method which is comprised of two components such as UserName and HelloText
        render: function() {
            <UserName onNameSubmit={this.handleNameSubmit}/>
            <HelloText data={}/>
      // UserName component which has following two methods:
      // handleChange: Used to capture onChange event 
      // render: Code to render the component
      var UserName = React.createClass({
        handleChange: function() {
          var username = this.refs.username.getDOMNode().value.trim();
          this.props.onNameSubmit({username: username });
          this.refs.username.getDOMNode().value = '';
          return false;
        render: function() {
          <form role="form" onChange={this.handleChange}>
             <div className="input-group input-group-lg">
                <input type="text" className="form-control col-md-8"  placeholder="Type Your Name" ref="username"/>
      // HelloText component to display Hello World or Hello Name text
      // render: Consists of code display the HelloText component
      var HelloText = React.createClass({
          render: function() {
            return (
              <h3>Hello, {}</h3>
        <SayHello />,
        document.getElementById( "sayhello" )
Alec Noller08/13/14
0 replies

Dev of the Week: Markus Winand

Every week, we feature a new developer/blogger from the DZone community to catch up and find out what he or she is working on now and what's coming next. This week we're talking to Markus Winand, author, trainer, and coach specializing in helping developers deal with SQL performance issues.

Alec Noller08/13/14
0 replies

The Best of DZone: August 5 - 12

If you missed anything on DZone this week, now's your chance to catch up! This week's best include the meaning of Google's source code release, how to combine D3 with AngularJS, rules of thumb for MongoDB schema design, the release of DZone's Unit Testing Checklist, and more!

John Sonmez08/13/14
2 replies

How to Negotiate Your Salary

I’m often surprised how many software developers neglect to do any salary negotiations at all or make a single attempt at negotiating their salary and then give up and take whatever is offered. Here's how you should do it.

Raymond Camden08/13/14
0 replies

Centering a Google Map on America

Earlier this morning I was building a Google Map demo for a client and I needed to center a Google Map on America. There are a couple ways of doing this and I thought I'd share them along with some screen shots so you can see the results.

Ricci Gian Maria08/13/14
0 replies

Git submodule update error: Permission Denied Publickey

It could happen when you clone a Git Repository with submodules, issuing a git submodule update command, that you are prompted with this error error.

Has Altaiar08/13/14
0 replies

How I Reduced Worker Role Time from >5 Hours to <1 Hour

This post talks about my experience in reducing the execution time of the Worker Role from above 5 hours to under 1 hour. This Worker Role is set up to call some external APIs to get a list of items with their promotions and store them locally.

Arnon Rotem-gal-oz08/13/14
0 replies

Introduction to Big Data - Presentation

I presented Big Data to Amdocs’ product group last week. One of the sessions I did was recorded so I might be able to add here later. Meanwhile you can check out the slides.

Mike Driscoll08/12/14
0 replies

The new sh Package: A subprocess wrapper

The project’s documentation has lots more information and additional examples that are worth your time perusing. It tells you how to accomplish sub-commands, get exit codes, piping, sub-commands and more.

Dave Fecak08/12/14
1 replies

"...but I'm negotiable"

Never start negotiating downward until some objection is provided, and don’t mistake the silence of an interviewer as an objection.

Benjamin Ball08/12/14
0 replies

An Early Mover's Guide to the Internet of Things

In the very near future, as more and more things connect to the internet, internet connectivity from IoT devices will dwarf the amount of traditional web browsing. The core standards and assumptions that will drive this next revolution in computing technology are still being established.

Steven Lott08/12/14
0 replies

Some Basic Statistics

I've always been fascinated by the essential statistical algorithms. First, some basics. Once we have these, though, the definitions of mean and standard deviation become simple and kind of cool.

Rob Galanakis08/12/14
0 replies

You must manage what you can’t measure

If you want to truly engage with employees as empowered and creative individuals, you must manage what you can’t measure. If you want to create a learning organization optimized for long-term health, you must manage what you can’t measure.

Chen Harel08/11/14
0 replies

Oracle’s Latest Java 8 Update Broke Your Tools — How Did it Happen?

Learn how the latest Java 8 and Java 7 builds broke some popular 3rd party tools such as JRebel, Javassist, Google’s Guice, and even Groovy itself.

Nicolas Frankel08/11/14
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
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
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.