Archive for the 'Programming' Category

A Better Binary File Generator DSL in Ruby

September 13th, 2008 | Category: Programming, Ruby

In Creating a Binary File Using a Ruby DSL I did a very small example of using a ruby DSL to generate complex binary files without having to use C or a hexeditor. I’ve beefed it up significantly since then so here is the updated version of h2b.irb.
Read more

No comments

XPath From the Command Line Using Ruby

September 13th, 2008 | Category: Programming, Ruby, XML, XPath

There are other ways of doing this, but I thought it would be fun to write a command-line xpath script in ruby using rexml. (full working example here)
Read more

No comments

Verifying Code Examples in your Documentation

September 06th, 2008 | Category: Programming, XML, XSLT, docbook

One of the more annoying aspects of writing developer documentation is that it is very easy for your code examples to get out of date, develop typos, etc(As those reading previous articles may have noticed). In this article I use docbook, xslt, and automake to generate code examples that are guaranteed to compile.
Read more

No comments

What is a C++ Functor?

July 20th, 2008 | Category: C++, Programming

I did a presentation on the spirit library in the flesh recently and was surprised to find the big sticking point was C++ functors. So I thought I’d cover the concept here.

Read more

No comments

Boost Spirit Part II (Attaching Actions to Your Grammar)

July 20th, 2008 | Category: C++, Programming

In the last article we covered how to define a grammar in the boost spirit library. This article will show you how to use the data parsed by the grammar with actions. The code for this example is here.
Read more

No comments

Boost Spirit Part I (Validating Against a Grammar)

July 01st, 2008 | Category: C++, Programming

I haven’t done a post in a while, but I thought the boost spirit library was worth an entry. Spirit provides a way of specifying and parsing a custom language grammar right inline in C++ without the need for a code generator like lex/yacc. Spirit makes it so easy to specify and use a grammar that you should never hand write even the most trivial parser again.

The full code for this example can be found here.

Read more

3 comments

Why You Shouldn’t Build Warnings Into Your Interface

April 01st, 2008 | Category: Programming

Below the link, why I think you should never under any circumstances design a feature that needs a warning message by design.
Read more

No comments

Creating a Binary File Using a Ruby DSL

March 25th, 2008 | Category: Networking, Programming, Ruby, XML

So I used ruby to convert a simple hex string into a binary file in Converting hex to Binary in 4 Languages. Today I was trying to create a mixed ascii/binary file at work and created a little Domain Specific Language that has good possibilities.

NOTE: There is an expanded version of this script here: A Better Binary File Generator DSL in Ruby
Read more

No comments

Why C Switch Statements Should go the way of the GOTO

March 15th, 2008 | Category: C, C#, Programming, Ruby

The venerable C switch statement keeps showing up in other languages presumably because the people who write new languages are familiar with C and don’t really think about it.
Read more

2 comments

Embedding Rhino Part I: Parsing Command Line Arguments in JavaScript

March 11th, 2008 | Category: Java, JavaScript, Programming

Rhino is a JavaScript/ECMAscript implementation in Java. Using the new java1.6 scripting API you can now easily embed JavaScript into your Java applications. I thought I’d try writing yet another implementation of the net_tool application using Rhino. Originally this was going to be a single article, but it turns out to be a two-fer.
Read more

No comments

Next Page »