One of Those Things You Don't Know If You Should Post in Your Blog Or on TheDailyWTF

From Rails, or more specifically, ActiveSupport's json.rb:

# When +true+, Hash#to_json will omit quoting string or symbol keys
# if the keys are valid JavaScript identifiers.  Note that this is
# technically improper JSON (all object keys must be quoted), so if
# you need strict JSON compliance, set this option to +false+.
mattr_accessor :unquote_hash_key_identifiers
@@unquote_hash_key_identifiers = true

AudioFormat 0.4 released

After a longish break, released a new AudioFormat when I noticed how aggravating the current version was :-)

The new version, 0.4, allows you to add files to the list of files to convert via a file selector or by dragging. It also should handle and report errors a bit better. And maybe it'll even recognize Vorbis files? Although I suspect it'll get very confused if it encounters something like Ogg Tarkin files. Will have to work on that a bit more.


Unit conversion in Java

JUGC is a Java library for unit conversions. It allows you to define a set of units and their relationships (a kilogram is a thousand grams, a tonne is a thousand kilograms, etc), translations for those units (gramma is fi_FI for gram), generate a Java library from those units (well, most of the library won't be generated, but the unit definitions will be) and then deploy that library in a project.

So basically you'll go from unit definitions like this:

                    <from>9 5 / * 32 +</from>
                    <to>32 - 9 5 / /</to>

                    <from>459.67 +</from>

to converting units like this:

    ConverterFactory.getConverter("celsius", "rankine").convert(42);

And the translation support is pretty simple, too:


                    <from>1000 /</from>



And then in your code:

    ConverterFactory.getConverter("gramma", "kilogramma", "fi_FI").convert(42);

The conversion expressions are in RPN.

I have yet to make a release and it's not totally finished — it should be possible to ask for the conversions to be done with arbitrary precision math, for instance — but I believe it's pretty usable already.

License: BSD sans advertising clause.

© Juri Pakaste 2022