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
Roman Pichler08/18/14
0 replies

From Personas to User Stories

User stories are a powerful technique to capture the product functionality from the perspective of a user or customer. But how do we discover the right stories? When should they be written and how detailed should they be? Read this post to find out my answers to these questions.

Mike Bushong08/17/14
0 replies

Visualization Tools for Network Engineers

Networking is a visual field. In fact, we can generalize and say all of IT is. Come to think of it, is there a technical field that isn’t? In this post, I’ll cover a handful of visualization tools that have recently helped me think through and communicate difficult Network Engineering stuff.

John Cook08/15/14
0 replies

What would Donald Knuth do?

I’ve seen exhortations to think like Leonardo da Vinci or Albert Einstein, but these leave me cold. I can’t imagine thinking like either of these men. But here are a few famous computer scientists I could imagine emulating when trying to solve a problem. What would you add to the list?

Johanna Rothman08/15/14
0 replies

Agile Bootcamp Talk Posted on Slideshare

I posted my slides for my Agile 2014 talk, Agile Projects, Program & Portfolio Management: No Air Quotes Required on Slideshare. It’s a bootcamp talk, so the majority of the talk is making sure that people understand the basics about projects. Walk before you run. That part.

Mike Cottmeyer08/15/14
0 replies

Agile Chronicles (Composite Stories) - Agile Artifacts - Ephemeral v. Enduring Value

During retrospection, when evaluating the quality and value of our artifacts for Epic, Feature and Story decomposition a common theme for our scrum teams is that these artifacts are by design barely sufficient and as such are ephemeral and provide no enduring value.

Victor Savkin08/15/14
1 replies

Using Trello for Your Personal Productivity System

I like this system because I find the visual aspect very important. It gives me a sense of accomplishment, which I value. Since most of what I do is creative work, fighting procrastination and “resistance” is high on my list of priorities, and visual tools help me with that.

Mike Cottmeyer08/14/14
0 replies

Aggressive Decoupling of Scrum Teams

What does aggressive decoupling look like?

Mike Bushong08/14/14
0 replies

Is your career a destination or a journey?

When most people think about their careers, they tend to think 5 years out and picture the job they would like to have. This works well when you know with precision where you want to be, but what happens if your future isn’t quite so certain?

Mark Needham08/14/14
0 replies

R: Grouping by two variables

In my continued playing around with R and meetup data I wanted to group a data table by two variables – day and event – so I could see the most popular day of the week for meetups and which events we’d held on those days.

Rob J Hyndman08/14/14
1 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.

Trevor Parsons08/14/14
0 replies

How D3 can help you build effective data visualizations

This post will show the value of D3 in doing this manipulation during resizing of different elements and that there are other steps we can take to be clever in designing and developing graphs.

//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
3 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.

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.