A jQuery Side Project: a Simple Web-based HTML Table Generator and Editor

Sometime last week I needed to create a small HTML table for a post I’m currently working on.

Since it’s a rather big table, and I didn’t want to write all the trs and tds by hand, I simply searched for an online HTML table generator, and found the one or other tool.

The tools I’ve found were all missing one feature I personally needed: a simple HTML table editor that gives me the additional possibility to edit the table’s content.

Since I didn’t find a solution that matched my additional requirement, I thought it would be a good possibility to refresh my jQuery skills, and write a small and simple web-based tool to solve this little problem.

And so I created the web-based HTML Table Generator and Editor (HTGE).

Features

The HTGE is a pretty simple tool.

You first specify the number of rows and columns for the table:

After that, an editable table will be generated, which will give you the possibility to edit its content and appearance:

When you finish to edit everything, you simple can generate its markup, which you then can paste wherever you want:

Summary

As usual, it was a real pleasure to work with jQuery; thanks to it, I came up with the code behind the HTGE pretty quickly.

The reason why the HTGE is currently held that simple is because I only need it to generate plain HTML tables to use in my posts. Nonetheless, feature requests are welcome.

Regarding HTGE’s stability, the only known issue to me is that Internet Explorer 8 doesn’t print the table’s markup well formatted; this shouldn’t be a deal breaker. HTGE works perfectly with all the other browser. Nevertheless, if you should find any other issues, I’d be thankful if you’d report them to me.

If you’re a developer, and you somehow liked the HTGE, I’d also appreciate a feedback or two regarding the jQuery code behind the tool.

And finally, if you have any other feedback, you can leave a comment, or simply contact me.

Formatting Numbers In C#: Add That Appostrophe In There

In case you’ve been wondering how you could place an apostrophe for every three digits of a number (e.g. 1'337 or 1'234'567) in C# using ToString(string format), you can achieve this with the following code:

int nr = 1337;
nr.ToString("#,#0");

This code snippet will format the number to 1'337, and if nr == 0 it will print 0; if you omit the 0 in #,#0, it will just print a whitespace in the case of nr == 0.

I know, it’s not the most interesting piece of code, but nonetheless it took me some time until I figured this one out. And yes, my first attempt looked something like nr.ToString("#'#0").

I hope I’ll save somebody some precious time with this post.

A* Pathfinding for Beginners — Since the first algorithm in the list of algorithms I posted yesterday is the A* search algorithm, I was reminded that I spent some time on grasping the mechanics of this algorithm during the work on our Bachelor thesis by reading through the very well written linked article. The algorithm runs quite fast thanks to the fact that it uses heuristics to determine in which order it visits the nodes. The algorithm still has a big disadvantage; since it has to keep track of every node it visits, it uses quite a lot of memory, and therefore isn't suitable for complex problems. During the Bachelor thesis I had also a look at the Fringe search, an optimized variant of the A* algorithm; simply put, instead of saving all the nodes and thus consuming a lot of memory, the Fringe search uses a frontier (or fringe) to determine which nodes it has to visit. If you want to dig deeper in the Fringe search, I recommend you to read the paper "Fringe Search: Beating A* at Pathfinding on Game Maps."

The Most Important Algorithms — A list of alogrithms compiled by a group of people consisting mostly of computer scientists. Thanks to the latter fact, the list contains the one or other algorithm that may be new to the mundane software engineer; still, a lot of well known algorithms are listed, like Dijkstra's algorithm and the binary search. Personally, I would also add difference algorithms to the list, since they're used quite widely and are very useful in a lot of areas, e.g. in revision control systems. Another algorithm that I would add to the list, too is the Sieve of Atkin, a fast algorithm for finding all prime numbers; primegen is a very performant implementation of the algorithm, which is written by D. J. Bernstein, one of the two creators of the algorithm.

The Trouble with Checked Exceptions — The other day me and a coworker were having an interesting discussion regarding exception handling. While searching for some information about the one or other question that arose, I somehow managed to find the linked interview in the wide archives of the internet. Although it's a quite old interview with Anders Hejlsberg, the C# lead architect, I personally found it a very interesting read. Hejlsberg discusses the decision of omitting checked exceptions from the C# language, and also tells why scalability and versionability can become tedious when working with checked exceptions.