Thursday, December 25, 2008

question: is svg path data definition retarded?

Imagine you were going to write an XML description of a polygon type structure... Wouldn't you do something like:

<pt x="100" y="100"/>
<pt x="300" y="100"/>
<pt x="200" y="300"/>

There are probably a lot of variations, but wouldn't it look something like that?

I mean... it's kinda a no brainer, right? Sort of hard to screw up, though there are probably a lot of ways to get it right.

If you were handing this out as a homework assignment in an XML 101 class, what grade you would give someone who came up with something like this:

<path d="M 100 100 L 300 100 L 200 300 z"/>

What if they went on to tell you, you could also write it in any of the following acceptable forms:

<path d="M 100 100 L 300 100 L 200 300 z"/>
<path d="M 100,100 L 300,100 L 200,300 z"/>
<path d="M 100 100L300 100L200 300 z"/>

Would you think they were being smart by saving space?

What if they told you:

  • the "M" meant "move to the absolute position"

  • the "m" meant "the point which relative to the last point"

  • the "L" meant "draw a line to the absolute position"

  • the "l" meant "draw a line the point which relative to the last point"

Would you think they were really smart? Or would you think they were pretty dumb?

Would you recommend it for inclusion in the W3 SVG standard?

I'm just wondering... cuz to me... it seems pretty stupid.

Way to drop the ball... I really would not have thought someone could screw that up so badly.

Monday, December 15, 2008

a point in haxe: inline ftw!

A while back, I talked about how delineating between structures and objects could have some performance implications.

Since then I have periodically doubted the conclusions I drew from my observations. My results still indicate that for Java with the JVM I used, structuring the code into a point structure and implementing the operations as a collection of static operators does make for a significant performance increase.

What I came to doubt was the universality of this observation.

Specifically, I wanted to see if this design methodology also payed off with haxe or if it was more of a JVM implementation artifact.

To test it, I wrote 3 different implementation of a "point" class:

typedef TypedPoint = {
public var x : Float;
public var y : Float;
public var z : Float;
class TypedPointOps {
public inline static function add( dest:TypedPoint, a:TypedPoint, b:TypedPoint ) : TypedPoint {
dest.x = a.x + b.x;
dest.y = a.y + b.y;
dest.z = a.z + b.z;
return dest;

class Point {
public var x : Float;
public var y : Float;
public var z : Float;

public function new( ?x:Float, ?y:Float, ?z:Float ) {
this.assign( x, y, z );

public function assign( ?x:Float, ?y:Float, ?z:Float ) : Point {
this.x = x;
this.y = y;
this.z = z;
return this;

public function add( a:Point, b:Point ) : Point {
this.x = a.x + b.x;
this.y = a.y + b.y;
this.z = a.z + b.z;
return this;

I wrote another version called "InlinePoint" which is just like "Point", but used the "inline" keyword.

Here is the result:

It basicly "adds" two points together 1 million times.

Here is the breakdown:

point : 0.019s
inline : 0.010s
typed : 1.355s

As you can see, the object version using the "inline" keyword is extremely fast compared to the alternatives.

In testing, I used the neato flashplayer command line tool that came as part of the Adobe Flex Builder Linux Public Alpha

% flashplayer pointsDemo.swf

For some reason it shows the "point" time as "0.149s"... weird... The "typed" time was also pretty different... eh...

So... why did I bother? Now I know I can port my JS 3D library straight to haxe without any major refactoring! :-D

Monday, December 8, 2008

Fallout 3 S.P.E.C.I.A.L Calculator

Fallout 3 is super-hoopy! And you are nuts not to devote tons of free time to it!

Here is some stuff on character creation gathered up with a lame calculator... No warrantees... don't sue me!

SPECIAL is 7 attributes starting with 5 points, with an extra 5 to spread around.. So... 40 points in all:

If that doesn't work, try hitting it directly

Even works under in (lame olde) IE... Use FF.

Here is some random advice I culled from some guys who actually put in the time to really document this stuff.

Since it's a mashup and different builds are different (ya reckon?), a lot of this is contradictory...

The following notes are culled from those links and are pretty much the words of the original authors.


I would suggest never going lower than three, and never going higher than five.

every type of character needs [..] inventory, [..] recommended that Strength be at least a 5


I wouldn't say a high level of Perception is desperately needed, but it will make your life easier. Put at least one point in there, if not two or three.

Perception needs to be brought to 6 eventually as a Perk prerequisite


If you want to use [big guns or unarmed ...] up to seven or eight. Otherwise, [...] drop it down to four or so


it's actually quite important if you want to be able to talk your way out of situations, and definitely worth putting two or three points in.

you can take Charisma down to 1 if you don't mind getting slightly worse prices on buying and selling and having little chance to use Speech skill.


Note that almost all characters in Fallout 3 should have 9-10 Intelligence


Unless it's just not in-line with how you want your character to be, push it up to eight.


If you don't care about any perks related to Luck, you could drain Luck to support other attributes. Unlike previous Fallout games, a low level of Luck won't cause any directly negative effects.

maxing your Agility and Intelligence early, with Luck following afterwards.


Haven't incorporated it yet, but is really interesting. Google search for "fallout 3 attributes build" turns up some good stuff

Sorry I'm too lazy to attribute the quotes to the right source. This is mostly for me to crib from... You should real the full texts, it's worth it.

I know my calculator looks pretty dumb... the real one looks like this

Tuesday, December 2, 2008

svg transform matrix

Oh what fun you can have with svg!

I'm working on a little flash game and I wanted to design the boards in inkscape, save as svg, transform them to my xml format and load 'em up... but...

Have you seen a one of these yet?


According to the spec, the syntax is matrix(a,b,c,d,e,f) which get laid out in matrix form like this:

if you guessed that, my hat is off to you! To me it is just bizarre...

OK, so what... matrix math rules out the xsl, right? Wrong...

Assuming you can pull out the a,b,c,d,e,f from that kooky string... then you can do this to apply the transformation matrix:

<xsl:attribute name="x">
<xsl:value-of select="$x * $a + $y * $c + $e"/>
<xsl:attribute name="y">
<xsl:value-of select="$x * $b + $y * $d + $f"/>

You have to do the same thing for width and height, too...

Happily, I had some old point * matrix implementation to pull from... if you don't have one handy... see above...


If you read the spec, you will see a bunch of other stuff I didn't bother with cuz I don't need it. Sorry...

Uhhmmm.... and I only ever see the case transform="matrix(0,1,-1,0,0,0)" so I hardcode the values for a,b,c,d,e,f,g like so

<xsl:variable name="a" select="'0'"/>
<xsl:variable name="b" select="'1'"/>
<xsl:variable name="c" select="'-1'"/>
<xsl:variable name="d" select="'0'"/>
<xsl:variable name="e" select="'0'"/>
<xsl:variable name="f" select="'0'"/>

Yeah... I know...

In case it helps, here is the board.xsl as it stands right now...

btw: alias xencode="sed 's/</\&lt;/g;s/>/\&gt;/g;s/\"/\"/g'"

why I left wordpress

Oh, what a heavy heart!
I freakin' ❤'d wordpress, but ultimately I had to move to here's why:

  1. adsense: wordpress doesn't allow it, does.
  2. embed: let's me put flash content in my blog. Since I blog about haxe a lot, this was a real bummer

  3. javascript: I also do some crazy stuff with js and I needs to demo stuff

  4. css: I liked being able to make pre tags look like terminals

I bummed, really, bummed. Even adding the vaulted google analytics I don't have a nice charts and graphs...

And I'm going to have to relink all my projects... woe! woe is me!

I hate to do it, but ... sometimes things are just like that...

find jars by sha1sum :

Ever have a mystery jar? Ever taken over an ant project and need to find what version of log4j the chuckle-heads were using so you can port the project to maven?

Check it out... jar-czar can help... Converting from an sha1sum to a url is ez and will provide you with the version info you needs.

Here is some really simple javascript... to pull form an input called 'sha1sum'

javascript:( function() {
document.location = (
document.getElementById( 'sha1sum' ).value
.replace( /(.*)/, '$1 $1' )
.replace( /^(...)/, '$1x' )
.replace( /(x...)/, '$1x' )
.replace( / /, 'x' )
.replace( /x/g, '/' )
.replace( /(.*)/, '$1-jar-czar.xml' )

as seen on

Here is the shell script way:

% sha1sum jcr-1.0.jar
% sha1sum *.jar | sed 's,\([^ \t]*\) *.*,\1 \1,;s,^...,&/,;s,/...,&/,;s, ,/,;s,.*,,'
% alias sha1_to_jar_car="sed 's,\([^ \t]*\) *.*,\1 \1,;s,^...,&/,;s,/...,&/,;s, ,/,;s,.*,,'"
% sha1sum *.jar | sha1_to_jar_car

Tuesday, November 25, 2008

better automagic java collections

A few years ago, I started writing java code like this to automagically initialize collections of junk and stuff:

private Collection< String > values_;

public Collection< String > getValues() {
return (
null == this.values_
? this.values_ = new ArrayList<>()
: this.values_

public void setValues( Collection< String > values ) {
this.values_ = values;

Nowadays you can find a lot of code like this in places like JAXB generated code, etc. Where you want the consumer of the class to be able to start doing stuff like:

Wizzle wuzzle = new Wizzle();
wuzzle.getValues().add( "ok" );

But there are a few problems with this. For one thing it assumes that there is no value to having the getValues call return null. Which impacts code like:

int sum = 0;
int count = 0;
for ( Wizzle wuzzle : wuzzles ) {
if( null != wuzzle.getValues() ) {
sum += wuzzle.getValues().size;
if ( 0 != count ) {
"average is "
+ ( sum / ( double ) count )

Of course, I also suddenly have created a bunch of ArrayLists I really don't need.

Now you might say: so what? And OK, but the fact is, a collection being unset (ie: null) is used in a fair number of places to perform logic or calculations.

Notice how the coolio automagic collection trick throws off my averages in this code that assumes null == wuzzle.getValues() mean "undefined."

Now I am writing (ok, generating) code like this instead:

private Collection< String > values_;

public Collection< String > getValues() {
return (
? this.setNewValues()
: this.values_

public boolean valuesUnSet() {
return ( null == this.values_ );

protected Collection< String > setNewValues() {
return ( this.values_ = this.newValues() );

public Collection< String > newValues() {
return new ArrayList< String >();

public void setValues( Collection< String > values ) {
this.values_ = values;

But in order for this to really work, the code to do the average has to be changed to:

int sum = 0;
int count = 0;
for ( Wizzle wuzzle : Wuzzles ) {
if( !wuzzle.valuesUnSet() ) {
sum += wuzzle.getValues().size;
if ( 0 != count ) {
"average is "
+ ( sum / ( double ) count )

The nice thing about this refactored code is that it doesn't make the assumption that "null" for a collection means uninitialized.

Instead the decision as to whether or not the Collection has been initialized is left up to the model object's implementation.

This approach removes a potentially dangerous assumption while allow automagic collections to be used without penalty.

It is a small incremental improvement on the basic design.

Friday, November 21, 2008

generating serializable classes with jaxb-maven2-plugin

So I told my pal Danny about the power and the glory that is the JAXB plugin for Maven2 and the sly way you can generate an xsd from an xml exemplar.

He had a lot of fun then he said: "how can I make the generated classes implement serializable?"

To which I responded "..."


Turns out, it is super easy! You can use an xjb file like so:

<jxb:bindings schemaLocation="myCool.xsd" node="/xs:schema">
<xjc:serializable uid="-6026937020915831338"/>

I ripped this off from here...

Just dump it in yer src/main/resources directory and modify yer pom.xml to look something like:


The end! Go, JAXB! Go, Maven!

Wednesday, November 19, 2008

jar-czar's cse is up!

Jar-Czar's Custom Search Engine is up and kicking!

Give it a shot!

Unfortunately... something changed on the google side and now always comes back with a 404... or it shows you the google home page...

So for now it's back to

Sigh... >.<

Before I had the CSE integrated so the results were displayed in the page... have to try to get that working again, but at least it is finally working!

Monday, November 17, 2008

haxe: bresenham's line drawing algorithm

Here is quick port I did of Bresenham's famous line drawing algorigthm I did in haxe

public function bresenhamInt(
bitmapData : BitmapData
, x0 : Int
, y0 : Int
, x1 : Int
, y1 : Int
, c : UInt
) {
var steep : Bool = Math.abs( y1 - y0 ) > Math.abs( x1 - x0 );
var tmp : Int;
if ( steep ) {
// swap x and y
tmp = x0; x0 = y0; y0 = tmp; // swap x0 and y0
tmp = x1; x1 = y1; y1 = tmp; // swap x1 and y1
if ( x0 > x1 ) {
// make sure x0 < x1
tmp = x0; x0 = x1; x1 = tmp; // swap x0 and x1
tmp = y0; y0 = y1; y1 = tmp; // swap y0 and y1
var deltax : Int = x1 - x0;
var deltay : Int = Math.floor( Math.abs( y1 - y0 ) );
var error : Int = Math.floor( deltax / 2 ); // this is a little hairy
var y : Int = y0;
var ystep : Int = if ( y0 < y1 ) 1 else -1;
for ( x in x0 ... x1 ) {
if ( steep ) {
bitmapData.setPixel( y, x, c ) ;
} else {
bitmapData.setPixel( x, y, c );
error -= deltay;
if ( error < 0 ) {
y = y + ystep;
error = error + deltax;

The pseudo code on wiki pedia made it pretty painless.

Here is a little demo comparing a really crappy floating point version I did, the above and a version like the one show, but using floating point.

It draws 20k lines, so it takes it a few seconds depending on yer rig.

You can find the source code here.

Sunday, November 16, 2008

is the neko vm too slow to be used?

So I've been having a lot of haxe fun lately, but mostly in the flash direction.

But of course, haxe has another face, the server / fat-client side which is neko vm (or php).

Since I think haxe is neat, and I have been playing with the idea of a small abstraction layer to write stuff to use flash apis or openGL I wanted to see what the neko vm was like.

Well... I was a little bummed that I couldn't find anything "official", but not really surprised since it's not exacty in the top 10 list.

I decided to try the olde "Sieve of Eratosthenes" test which is generally regarded as a very naive, worthless and very easy to implement benchmark.

At this point you probably see where this is going...

sieve.c 1.542s 2.899s
Sieve.hx to Flash 7.404s
Sieve.hx to Neko 20.039s
Sieve.hx to JS* 22.799s

Ouch! Of course, we can't expect the neko vm to really compete with the Java 6 JVM, but a 7x spanking really makes it look bad!

Getting spanked by Flash a 2.5x is not too impressive either... or barely beating out Javascript...

As blackdog points out, a path from haxe to the JVM may just make a lot more sense.

Unfortunately, at this point there isn't a way to get from haxe to the JVM and getting to the neko vm doesn't seem worth the bother...


BTW, I generated the php version, but couldn't get it to crank up... May add in the results later.

Thursday, November 13, 2008

Chambliss: just add swift kick to the rear

December 2nd, 2008 is a good day to give Saxby that early Christmas present he's been wanting: the firm application of the collective food of the good people of Georgia to his back side he's been wanting.

Frankly, I didn't really know much about Chambliss before the bailout that put a gun to my head and forced me to invest in the floundering mess that is AIG with some vague promises of "getting me back" someday.

Can't say I wanted to either.

I realize he's a professional politician which puts his soul about 3 rungs down from grave robber or folks who scam little olde ladies out of their pensions... oh, wait! He is in that last group too.

Well, if they could I'm sure they'd want to boot him out of their club if they could.

Hyberpole? Ok, maybe.

Why not decide for yourself?

Here is what this our darling "representative"responded when I told him not to give my money to those con artists in the financial "services" industry (my mods in brackets with italics):

We have been betrayed by many people [to whom I plan to give billions of dollars more, secure in the knowledge we can trust them now for some reason TBD] and by abuse of the system [which I have no intentions of changing since they pay for my yacht ...] The bill that I voted for is not a bailout [oh, wait... yeah it totally is, my bad! ...] this is not a popularity contest [so please shut up, get back on your tractor and let the smart guys get their graft-on ...] My first reaction was one of anger and frustration [realizing I didn't get my kick back on this fraud in advance (you try collecting from these slicksters on the back-end... oh, yeah... you will try! hahahaha I gave your hard earned dough to the worst kind of grafters who are now going to loan it back to your at 24% interest! bwhahahaha! I am pure evil! pay me, biatch!]

Now I admit, the above is somewhat colored by my own perspective on the ridiculous, wrong-headed pompous nonsense Saxby "YAWB" Chambliss had to offer up in exchange for my hard earned cash which he gave to his friends in big bidness.

So, you can read the rest here in it's original form.

The only modification I made was to remove some slight information specific to my secret identity and replace it with what I am reasonably sure was the original name in the template.

Now, I'm not advocating for Martin.

I'm not partisan because I'm not silly enough to believe that big bidness would be dumb enuff to only buy off only half of the politician.

Nor am I naive enuff to think these guys are really trying to help me.

In my experience when someone you don't know is trying to get into your bidness and help you with the contents of your wallet, it is not going to be to put more money in there.

If you follow me... you do, right? I think you do.

I would just like to encourage you at least rattle the bar of the cage a little.

Yeah, the warden isn't going to let us go for banging our collective metal cup on the bars. The guards aren't going to release us for throwing down rolls of toilet paper lit on fire.

But sometimes you have to do what you can to say "Hey! I'll rochambeau you for it!"

So please, do what you can to boot Chambliss out. And when Martin sends me the same letter in a couple of years, let's do the same for that turkey too.

Oh, btw:

However, history warns us against inaction by hard lessons learned. Delaying to act would be a repeat of the mistakes of the 1920s, when thousands of banks failed before significant confidence was restored to our financial markets.

For all the experts, politicians and geniuses who repeat this tired refrain. We have no reason to think that propping up this corrupt financial system with some temporary injection of cash is going to do anything other than make it crash down that much harder when it does crash.

You are not the little dutch boy putting his finger in the dike (I know... in the modern world that sounds really derty!)

Let's just hope 2009 doesn't come to be known as the "Greater Depression."

I'd like to conclude with...

When you are having trouble paying the bills, it's not the right time to invest in the stock market.

When you are concerned about having a job in 6 months, maybe the best use of money is to save up what you can when you can.

When you are uncertain if the bank is going to foreclose one you, don't go buy shares in a failed corporation.

Too bad Chambliss is too damned smart to know that. Or maybe just too rich.

Maybe he should ask Clark Howard what he thinks next time.

Or maybe he could listen to me: keep your hands off my cash your damned, dirty politician!

Here is the deal, I offer to one and all. It is not a new deal: mind your own bidness and I will mind mine ; the administration of the horns is predicated on the molestation the bull.

Oops! Almost forgot! Always leave off with a joke! Unfortunately, the jokes on us, but hey...