HTML5 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
John Walter10/22/14
3012 views
0 replies

Dev of the Week: Ajitesh Kumar

Every week here and in our newsletter, 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 Ajitesh Kumar, Principal Architect with Evoke Technologies.

Dele Sikuade10/21/14
312 views
1 replies

Guerilla Sessions and the Slam Dunk Chart

I’ve read many times about teams that adopt a ‘sledgehammer to crush a nut’ approach and trust me, it works. This is not the how of such sessions, just the way in which I track them for the team. If you have a big ol’ nasty nut that you intend to crush in one session, then I hope this little technique helps.

Jared Jaureguy10/21/14
182 views
0 replies

Imagining The Office of The Future

Businesses will need to adopt better network security measures alongside their device initiatives. One of the best ways a business can prepare for future issues is to create rules and guidelines for how to handle new devices.

Steven Lott10/20/14
718 views
0 replies

Scipy.optimization.anneal Problems

I'm not even certain that I could help them with some of the Python technology required to extend scipy. But, I'm sure I cannot actually do anything of value under the circumstances that (a) they have not really tried the established algorithms and (b) they're already sure that the established algorithms can't work based on religious-wars arguments.

Johanna Rothman10/20/14
4547 views
0 replies

Small Internal Releases Lead to Happy Customers

Release externally whenever you want. That is a business decision. Separate that business decision from your ability to release internally all the time.

Gen Furukawa10/20/14
1448 views
1 replies

The Key to Distributed Database Performance: Scalability

TL;DR: The realities of modern corporate networks make the move to distributed database architectures inevitable. How do you leverage the stability and security of traditional relational database designs while making the transition to distributed environments? One key consideration is to ensure your cloud databases are scalable enough to deliver the technology's cost and performance benefits.

Abby Fichtner10/19/14
2008 views
3 replies

Fun Ways to Teach Kids to Code

Following up on my Why We Need to Teach Kid to Code, here are some fun ways to help them learn. So cool – wish some of these were around when I was an 8 year old learning to code on my Atari 800!

Vinod Kumaar Ra...10/19/14
1791 views
0 replies

Disposable Software

Should we design cost-effective disposable software?

Mike Bushong10/19/14
2831 views
0 replies

On foxholes and corporate silos

The existence of silos in large companies is fairly common. But simply knowing that silos exist doesn’t help too much. The operable question for everyone operating in these environments is: What can I do to remove unnecessary silos?

Ameera Tabassum10/17/14
654 views
0 replies

Have You Chosen the Right Enterprise Risk Management Software for Your Business?

Industries have accepted ERM software in their work space and have analysed and calculated its constructive and destructive roles. Implementing a wrong, defective or inadequate program has contributed to the failure of countable enterprises.

Allan Kelly10/17/14
2080 views
0 replies

The Estimates Land Mine: Use and Misuse of Estimates

In the meantime it seems to me that a lot of the problem with Estimates lies in what they are, what they are not, how they are used and how they are mis-used.

Tom Howlett10/16/14
7735 views
3 replies

Interviewing Programmers: Start with Code

For me recruiting a programmer has to start with code. I don’t really care about the CV and the application process for this job involved a quick coding problem.

Rob Allen10/16/14
4422 views
0 replies

Context-specific history at the bash prompt

These two bind command change the way that the up and down arrow keys work once you start typing a command to only search the history for lines that start with what you've typed so far. It's quite handy and I find it easier to use than ctrl+r.

Johanna Rothman10/16/14
2652 views
0 replies

Large Program? Release More Often

Look, the more people and teams on your program, the more feedback you need. The more chances you have for getting stuck, being in the death spiral of slowing inertia. What you want is to gain momentum.

Dele Sikuade10/16/14
1703 views
0 replies

The Single Most Important Thing in Agile

Agile is a methodology that was formed to bridge the gap between abstract requirement and real-world want. It implicitly acknowledges the existence of the gap by requiring the business to participate and therefore to be complicit in the process of development and delivery. It is the best methodology I have ever seen for overcoming this problem and this problem is the single biggest cause of pain in software development.

Mike Bushong10/16/14
2572 views
0 replies

On choice-supportive bias and the need for paranoid optimism

Companies are not blind because the individuals are not talented; they are blind because there are powerful psychological dynamics at play that keep us all from seeing that which we must see the most.

Kin Lane10/16/14
2577 views
2 replies

I Am Not Signing Any More NDAs

I just replied to a company who I really like, and trust, letting them know I won’t be signing any more NDAs. There are plenty of companies that I can exchange knowledge, research, data, and other vital information without signing NDAs.

Venkatesh Kris...10/16/14
4356 views
0 replies

If you are start-up, think beyond one user!

It's extraordinarily difficult to take a product that was built perfectly for a particular user and commercialize that into a broader market.

//Insert a Document at Any Location
/**
 * Inserts content of the external document after the specified node.
 * Section breaks and section formatting of the inserted document are ignored.
 *
 * @param insertAfterNode Node in the destination document after which the content
 * should be inserted. This node should be a block level node (paragraph or table).
 * @param srcDoc The document to insert.
 */
public static void insertDocument(Node insertAfterNode, Document srcDoc) throws Exception
{
    // Make sure that the node is either a paragraph or table.
    if ((insertAfterNode.getNodeType() != NodeType.PARAGRAPH) &
      (insertAfterNode.getNodeType() != NodeType.TABLE))
        throw new IllegalArgumentException("The destination node should be either a paragraph or table.");

    // We will be inserting into the parent of the destination paragraph.
    CompositeNode dstStory = insertAfterNode.getParentNode();

    // This object will be translating styles and lists during the import.
    NodeImporter importer = new NodeImporter(srcDoc, insertAfterNode.getDocument(), ImportFormatMode.KEEP_SOURCE_FORMATTING);

    // Loop through all sections in the source document.
    for (Section srcSection : srcDoc.getSections())
    {
        // Loop through all block level nodes (paragraphs and tables) in the body of the section.
        for (Node srcNode : (Iterable<Node>) srcSection.getBody())
        {
            // Let's skip the node if it is a last empty paragraph in a section.
            if (srcNode.getNodeType() == (NodeType.PARAGRAPH))
            {
                Paragraph para = (Paragraph)srcNode;
                if (para.isEndOfSection() && !para.hasChildNodes())
                    continue;
            }

            // This creates a clone of the node, suitable for insertion into the destination document.
            Node newNode = importer.importNode(srcNode, true);

            // Insert new node after the reference node.
            dstStory.insertAfter(newNode, insertAfterNode);
            insertAfterNode = newNode;
        }
    }
}

//Insert a Document During Mail Merge

//This example relies on the InsertDocument method shown at the beginning of the article to insert a document into a merge field during mail merge execution. This code demonstrates how to use the InsertDocument method to insert a document into a merge field during mail merge.

public void insertDocumentAtMailMerge() throws Exception
{
    // Open the main document.
    Document mainDoc = new Document(getMyDir() + "InsertDocument1.doc");

    // Add a handler to MergeField event
    mainDoc.getMailMerge().setFieldMergingCallback(new InsertDocumentAtMailMergeHandler());

    // The main document has a merge field in it called "Document_1".
    // The corresponding data for this field contains fully qualified path to the document
    // that should be inserted to this field.
    mainDoc.getMailMerge().execute(
        new String[] { "Document_1" },
        new String[] { getMyDir() + "InsertDocument2.doc" });

    mainDoc.save(getMyDir() + "InsertDocumentAtMailMerge Out.doc");
}

private class InsertDocumentAtMailMergeHandler implements IFieldMergingCallback
{
    /**
     * This handler makes special processing for the "Document_1" field.
     * The field value contains the path to load the document.
     * We load the document and insert it into the current merge field.
     */
    public void fieldMerging(FieldMergingArgs e) throws Exception
    {
        if ("Document_1".equals(e.getDocumentFieldName()))
        {
            // Use document builder to navigate to the merge field with the specified name.
            DocumentBuilder builder = new DocumentBuilder(e.getDocument());
            builder.moveToMergeField(e.getDocumentFieldName());

            // The name of the document to load and insert is stored in the field value.
            Document subDoc = new Document((String)e.getFieldValue());

            // Insert the document.
            insertDocument(builder.getCurrentParagraph(), subDoc);

            // The paragraph that contained the merge field might be empty now and you probably want to delete it.
            if (!builder.getCurrentParagraph().hasChildNodes())
                builder.getCurrentParagraph().remove();

            // Indicate to the mail merge engine that we have inserted what we wanted.
            e.setText(null);
        }
    }

    public void imageFieldMerging(ImageFieldMergingArgs args) throws Exception
    {
        // Do nothing.
    }
}
 
//If a document to be inserted is stored as binary data in the database field (BLOB field), use the following example. A slight variation to the above example to load a document from a BLOB database field instead of a file.

private class InsertDocumentAtMailMergeBlobHandler implements IFieldMergingCallback
{
    /**
     * This handler makes special processing for the "Document_1" field.
     * The field value contains the path to load the document.
     * We load the document and insert it into the current merge field.
     */
    public void fieldMerging(FieldMergingArgs e) throws Exception
    {
        if ("Document_1".equals(e.getDocumentFieldName()))
        {
            // Use document builder to navigate to the merge field with the specified name.
            DocumentBuilder builder = new DocumentBuilder(e.getDocument());
            builder.moveToMergeField(e.getDocumentFieldName());

            // Load the document from the blob field.
            ByteArrayInputStream inStream = new ByteArrayInputStream((byte[])e.getFieldValue());
            Document subDoc = new Document(inStream);
            inStream.close();

            // Insert the document.
            insertDocument(builder.getCurrentParagraph(), subDoc);

            // The paragraph that contained the merge field might be empty now and you probably want to delete it.
            if (!builder.getCurrentParagraph().hasChildNodes())
                builder.getCurrentParagraph().remove();

            // Indicate to the mail merge engine that we have inserted what we wanted.
            e.setText(null);
        }
    }
public void imageFieldMerging(ImageFieldMergingArgs args) throws Exception
    {
        // Do nothing.
    }
}

//Insert a Document During Replace

//This example shows how to insert content of one document into another during a customized find and replace operation.

[Code Sample]

public void insertDocumentAtReplace() throws Exception
{
    Document mainDoc = new Document(getMyDir() + "InsertDocument1.doc");
    mainDoc.getRange().replace(Pattern.compile("\\[MY_DOCUMENT\\]"), new InsertDocumentAtReplaceHandler(), false);
    mainDoc.save(getMyDir() + "InsertDocumentAtReplace Out.doc");
}

private class InsertDocumentAtReplaceHandler implements IReplacingCallback
{
    public int replacing(ReplacingArgs e) throws Exception
    {
        Document subDoc = new Document(getMyDir() + "InsertDocument2.doc");

        // Insert a document after the paragraph, containing the match text.
        Paragraph para = (Paragraph)e.getMatchNode().getParentNode();
        insertDocument(para, subDoc);

        // Remove the paragraph with the match text.
        para.remove();

        return ReplaceAction.SKIP;
    }
}
Alec Noller10/15/14
6344 views
1 replies

Dev of the Week: Ashwini Kuntamukkala

Every week here and in our newsletter, 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 Ashwini Kuntamukkala, Software Architect at SciSpike, Inc.