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
Steve Hanov07/24/14
2280 views
0 replies

You can cheat so your web site seems faster than it is

Previously, I was precalculating the completion which maximized the probability of the word, using some basterdized half-remembered version of bayes law. But I think there is a better approach, by running simulations on existing data.

Alec Noller07/23/14
9867 views
0 replies

Dev of the Week: Pierre-Hugues Charbonneau

Every week here and in our newsletter, we feature a new developer/blogger from the DZone community. This week we're talking to Pierre-Hugues Charbonneau, Senior IT Consultant and System Architect at CGI Inc., and author of DZone's 200th Refcard: Java Performance Optimization.

//[C# Code Sample]

Dictionary<string, Symbology> collection = new Dictionary<string, Symbology>();
collection.Add("ONE123", Symbology.Code39Standard);
collection.Add("Process Collection", Symbology.DataMatrix);
collection.Add("Dictionary Collection", Symbology.QR);
collection.Add("X06712AT", Symbology.Code128);
collection.Add("979026000043", Symbology.EAN13);
collection.Add("Aztec BarCode", Symbology.Aztec);

List<Bitmap> images = new List<Bitmap>();

foreach (KeyValuePair<string, Symbology> pair in collection)
using (BarCodeBuilder builder = new BarCodeBuilder())
{
    builder.CodeText = pair.Key;
    builder.SymbologyType = pair.Value;
    images.Add(builder.GenerateBarCodeImage());
}

int maxWidth = int.MinValue;
int sumHeight = 0;
foreach (Bitmap bmp in images)
{
    sumHeight += bmp.Height;
    if (maxWidth < bmp.Width)
        maxWidth = bmp.Width;
}

const int offset = 10;
Bitmap resultBitmap = new Bitmap(maxWidth + offset * 2, sumHeight + offset * images.Count);
using (Graphics g = Graphics.FromImage(resultBitmap))
{
    g.Clear(Color.White);

    int yPosition = offset;
    for (int i = 0; i < images.Count; ++i)
    {
        Bitmap currentBitmap = images[i];
        g.DrawImage(currentBitmap, offset, yPosition);
        yPosition += currentBitmap.Height + offset;
    }
}

resultBitmap.Save("barcode.png", ImageFormat.Png);

//[VB.NET Code Sample]

Dim collection As New Dictionary(Of String, Symbology)()
collection.Add("ONE123", Symbology.Code39Standard)
collection.Add("Process Collection", Symbology.DataMatrix)
collection.Add("Dictionary Collection", Symbology.QR)
collection.Add("X06712AT", Symbology.Code128)
collection.Add("979026000043", Symbology.EAN13)
collection.Add("Aztec BarCode", Symbology.Aztec)

Dim images As New List(Of Bitmap)()

For Each pair As KeyValuePair(Of String, Symbology) In collection
    Using builder As New BarCodeBuilder()
	builder.CodeText = pair.Key
	builder.SymbologyType = pair.Value
	images.Add(builder.GenerateBarCodeImage())
    End Using
Next

Dim maxWidth As Integer = Integer.MinValue
Dim sumHeight As Integer = 0
For Each bmp As Bitmap In images
    sumHeight += bmp.Height
    If maxWidth < bmp.Width Then
	maxWidth = bmp.Width
    End If
Next

Const  offset As Integer = 10
Dim resultBitmap As New Bitmap(maxWidth + offset * 2, sumHeight + offset * images.Count)
Using g As Graphics = Graphics.FromImage(resultBitmap)
    g.Clear(Color.White)

    Dim yPosition As Integer = offset
    For i As Integer = 0 To images.Count - 1
  	Dim currentBitmap As Bitmap = images(i)
	g.DrawImage(currentBitmap, offset, yPosition)
	yPosition += currentBitmap.Height + offset
    Next
End Using

resultBitmap.Save("barcode.png", ImageFormat.Png)

Borislav Iordanov07/23/14
7158 views
0 replies

Why is the Fundamental Theorem of Software Engineering Fundamental?

So you can see where I'm heading with the question posed at the title of this post. It is the reference resolution that is fundamental an indirection is simply what we do to (re)define what that resolution process ultimately looks like.

Hamid Shojaee07/23/14
3690 views
1 replies

Scrum and Quantum Physics

Since Scrum is an iterative process, you can have great success by focusing on things that you can say with a fair degree of confidence, while still allowing for some uncertainty in all planning and estimates.

Ayende Rahien07/23/14
5327 views
0 replies

Avoid where in a reduce clause

We got a customer question about a map/reduce index that produced the wrong results. The problem was a problem between the conceptual model and the actual model of how Map/Reduce actually works.

Mike Bushong07/23/14
2584 views
0 replies

Scenario planning for first-line managers

Almost every New Product Introduction process includes some placeholder slots to talk about risk. Everyone knows enough to put mitigation plans in these slots. But those mitigation plans are drafted and then ignored by the vast majority of managers.

Kin Lane07/23/14
2055 views
0 replies

GitHub Commit Storytelling: Now or Later

When you are making GitHub commits you have to provide a story that explains the changes you are committing to a repository. Many of us just post 'blah blah’, ‘what I said last time", or any other garbage that just gets us through the moment. You know you’ve all done it at some point.

-- Relative time with interval
DATE_SUB(NOW(), INTERVAL 25 HOUR)
 
-- Select all users that were updated in the last 24 hours.
SELECT * FROM users
WHERE users.updated > DATE_SUB(NOW(), INTERVAL 24 HOUR);
 
-- Select all users that were updated in the last 7 days.
SELECT * FROM users
WHERE users.updated > DATE_SUB(NOW(), INTERVAL 7 DAY);
Mike Bushong07/22/14
3026 views
0 replies

Network abstractions need equivalent of packet walkthrough

Whenever a new networking platform is evaluated, one of the early sales calls includes a packet walkthrough. But why?

Rob J Hyndman07/22/14
4124 views
0 replies

I am not an econometrician

Econo­met­rics is often “the­ory dri­ven” while sta­tis­tics tends to be “data dri­ven”. I dis­cov­ered this in the inter­view for my cur­rent job when some­one crit­i­cized my research for being “data dri­ven” and asked me to respond.

Mike Cottmeyer07/22/14
1627 views
0 replies

What is the ROI of Your Event?

So, where did our new event fall on a scale compared to the others? Did I feel like attendees received value and did I feel like we got a good return on our investment? Let me give a little comparison.

Alec Noller07/21/14
10173 views
0 replies

DZone's 200th Refcard Released: Java Performance Optimization

Today, DZone released Refcard #200: Java Performance Optimization. To mark the significance of this milestone, this Refcard boasts a complete redesign - all the information you expect from a Refcard in a shiny new package!

David Winterbottom07/21/14
5121 views
0 replies

Linking to Github

It's dangerous to link to lines or blocks of code on Github without explicitly specifying the commit hash in the URL. This emits the Github URL to the HEAD commit on the current branch, specifying the commit hash in the URL

Ayende Rahien07/21/14
3633 views
0 replies

Introducing inefficiencies into RavenDB, on purpose

The administrators on the server noted the high I/O and that a single thread was constantly busy and decided that this is likely a hung thread. The long term fix was to actually make sure that we abort the operation after a while, report to the remote server that we scanned up to a point, and had nothing to show for it, and go back to the replication loop.

Mark Needham07/21/14
2842 views
0 replies

R: ggplot: Problem automatically picking scale for difftime object

I thought it’d be interesting to create some visualisations around the times that people RSVP ‘yes’ to the various Neo4j events that we run in London. I tried to use ggplot to create a bar chart of the data. Unfortunately that resulted in this error:

Johanna Rothman07/21/14
4803 views
0 replies

What is Your Minimum Agile Reading List?

I have created a Minimum Reading List for an Agile Transition. Note the emphasis on minimum. I could have added many more books to this list. But the problem I see is that people don’t read anything. They think they do agile if they say they do agile.

Phil Whelan07/21/14
599 views
0 replies

Release! Card Game Adds New Twist to Software Development

"Release!" is a card game about making software inspired by development strategies like Lean, Agile, and DevOps.

Chris Odell07/19/14
4112 views
0 replies

Agile Decompiled : Incremental And Iterative Releases

Proponents of the Waterfall Model suggest that by doing all the design up front and making sure that each part of the process is correct before moving onto the next part, means that bugs are found sooner and therefore costs are reduced.

Jim Bird07/18/14
10330 views
0 replies

Trust instead of Threats

According to Dr. Gary McGraw’s ground breaking work on software security, up to half of security mistakes are made in design rather than in coding. For the last 10 years we’ve been told that we are supposed to do this through threat modeling. What else can we do to include security in application design?