Tag: download

Buffy/Angel Episode Guide

spooky tree

I decided it was time for me to rewatch Buffy and Angel and I wanted to do so in the right order. I found this blog post that gives a recommended order and what episodes are especially important to sync up because they reference the other series.

But the episodes are just listed with consecutive number. That in combination with Disney+ insisting to show me the German titles for the episodes made it necessary to keep counting to know when to jump over etc.

So I made myself another version of the list that shows the common season/episode codes for the episodes.

Links

Darkly, free

I was looking for a good looking dark theme for one of my toy projects and came across a bootstrap theme called “darkly” which looks nice but as so often, comes with a one of those snoopy Google fonts that can/do track you etc pp.

In this case it is even more annoying, because the actual font “Lato” is an open font.

So here it is: a version of the darkly bootstrap 4 theme with the font files to serve from the same server. The CSS uses relative addressing, i.e. the “css” and “webfonts” folder must be siblings on your server

Thrust 2010

Thrust 2010 gameplay screenshot

Those of you who playtested it know it already, for all the others, I’d like to announce the first release of Thrust 2010. It’s a HTML5/canvas game inspired by the old C64 classic, redone for mouse-driven interface. So far it contains 6 levels of agility / shooting fun. Don’t give up if you are having a hard time controlling the ship at first. Just keep trying, don’t speed and keep it under control. People keep telling me it’s difficult to control and I guess that’s true and to some degree even intended, but I’m also sure that you get much better at it over time.

Links:

Annotating DOM nodes with JSON, Part 2

It’s been a while since I wrote Annotating DOM nodes with JSON and in retrospective I can say that I never really used the method described in a real life project. Now I’d like to present another method of decorating DOM nodes with JSON based on classes. This one I actually implemented in OpenSAGA to have arbitrary metadata from some of the OpenSAGA Widgets.

I didn’t really like the idea of misusing onclick for the purpose of meta-data and thought about a better way of doing it. Browsing the w3 HTML specs I came upon the fact that classes can be any character separated by spaces. So for use-cases where I only needed one meta-data value I used classes like

<div class="refId:id-1234">
    DIV content
</div>

A use-case specific prefix is used to mark a class as meta-data container containing the string after the prefix. The code to evaluate this in javascript is very easy

/**
 * Returns the class value with the given prefix using the giving separator
 * @param {DOMElement} elem DOM element to fetch metadata from
 * @param {String} name of the classval value
 * @param {String} separator to use between name and value. Default is ":"
 */
function classval(elem, name, separator)
{
    var match = new RegExp("\\b" + name + (separator || ":") + "([^ ]*)($| )")
                          .exec(elem.className);
    if (match)
    {
        return match[1];
    }
    return null;
}
…
// assume divElement to be DOM element of the div
var refId = classval(divElement, "refId");

I thought about going for a more elaborate prefix scheme to support nested metadata but in the end decided against it because I already have a nicely supported format for exchanging data between server and client: JSON. So I tried to come up with a scheme of using arbitrary JSON for the metadata decoration.

Only problem: Spaces are not valid inside classes, so I needed a method to encode and decode JSON into valid classes. The method should not totally mangle the JSON to keep readability and maybe write the encoded variant by hand for simple cases.

Solution:

  • HTML encode the JSON-String
  • Replace spaces with underlines and underlines with \u005f

The replacement of underlines is valid because underlines can only occur inside quoted JSON strings so they can just be replaced by their escaped unicode value \u005f.

Here is the java code to do the escaping. Since it’s basically a combination of string replacement and HTML encoding this should be easily doable in any server-side language:

    public String escapeDecoration(String s)
    {
        String escaped = StringEscapeUtils.escapeHtml(s);

        StringBuilder sb = new StringBuilder(escaped.length());
        sb.append("deco:");
        for (int i = 0; i < escaped.length() ; i++)
        {
            char c = escaped.charAt(i);
            switch(c)
            {
                case '_':
                    sb.append("\\u005F");
                    break;
                case ' ':
                    sb.append('_');
                    break;
                default:
                    sb.append(c);
                    break;
            }
        }

        return sb.toString();
    }

The escape method uses the escapeHTML method from Apache commons-lang's StringEscapeUtil. Going the other way in javascript is not that complicated either:

/**
 * Decodes the given string containing HTML entities.
 */
function htmlDecode(s)
{
    var helper = document.createElement("SPAN");
    helper.innerHTML = s;
    return helper.innerHTML;
}

/**
 * Returns the JSON decoration of the given element.
 * @param {DOMElement} DOM element
 * @param {String} decorator classval name, default is "deco".
 */
function decoration(elem, name)
{
    var value, data, result;

    value = classval(elem, name || "deco");
    if (value)
    {
       // get raw data from DOM element
       data = value.replace(/_/g, " ");
       // replace HTML entities with the original characters
       data = htmlDecode(data);
       // evaluate JSON
       result = eval("("+data+")");
    }
    return result || {};
}

In order to achieve a better readability of escaped JSON, I also used svenson's ability to deviate from the JSON standard by using single quotes instead of double quotes. Just comparing

<div id="tst2" class="deco:{'foo':'xxx\u005f_yyy','baz':[1,3,5,7,9]}">
JSON annotation
</div>

to

<div id="tst2" class="deco:{&quot;foo&quot;:&quot;xxx\u005f_yyy&quot;,&quot;baz&quot;:[1,3,5,7,9]}">
JSON annotation
</div>

should demonstrate that single quotes are not only much better readable, but also shorter. If you use eval() evaluate the JSON string, the single quotes are no problem at all. If you want json2.js / native JSON-parsing, you might have to replace the quote chars before parsing.

Links:

HTML test page with both metadata strategies

Playing around with RaphaelJS

Recently I stumbled across what I later found out is known as Morley’s trisector theorem.


“Trisect the angles of any triangle and you’ll find an equilateral triangle at its heart.”

A Better Nature

This inspired me to do some javascript coding with the help of RaphaelJS (a very nice crossbrowser graphics library) . It’s been a while since I last wrote any real geometry stuff but I got it in the end.

Start interactive demo for Morley’s trisector theorem.

Links:

Scripting JSON

Doing a lot of web stuff and fiddling around with CouchDB, I really got to like JSON as versatile format for things. Installing the JSONView extension for firefox really helps with working with JSON in the browser, but what I’ve been missing so far is an easy way to deal with JSON from bash scripts. Fiddling around with the very interesting NodeJS, I came up with a small node js script that makes JSON handling much easier, the JSON command: It reads a JSON object from stdin and feeds it to a javascript function body with “v” and NodeJS’ “sys” as parameters. The return value of the function is written to stdout. If it was a string, it is written as-is, if it is another object it will be pretty-JSONified.

Simple Example

$ curl -s http://localhost:5984/test | json "return v;"
{
 "db_name": "test",
 "doc_count": 0,
 "doc_del_count": 0,
 "update_seq": 0,
 "purge_seq": 0,
 "compact_running": false,
 "disk_size": 79,
 "instance_start_time": "1274021449672284",
 "disk_format_version": 5
}

Use curl to fetch the status of CouchDB database “test” from the local CouchDB node and then just pretty print it by returning the implicit value v.

$ curl -s http://localhost:5984/test | json "return v.disk_size;"
79

Just print the disk_size of CouchDB database “test”. You can use all the modern JavaScript functions v8 offers plus the implicit “sys” object that lets you log stuff to stderr or inspect objects. A little script that I find highly useful:

#!/bin/bash
# Delete all jcouchdb test databases
DBS=$(curl -s http://localhost:5984/_all_dbs | \
json 'return v.filter( function(db) { return db.indexOf("jcouchdb") == 0; }).join("\n");')

for i in $DBS
do
 curl -X DELETE http://localhost:5984/$i
done

Filter the list of database to only contain those that start with “jcouchdb”, then loop over them to delete.

Links:

Update: Added “return v;” as default function. now also supports “-h” and “–help”.

Hood Beta 2

After fixing a pretty serious bug in the combination of svenson and jcouchdb and releasing svenson 1.3.4 and jcouchdb 0.9.1-4 and jcouchdb 0.10.0-2, I got around to release a new, improved version of Hood, too. It’s called “Beta 2” and still lacks some features but the documentation is a lot better and the application design is basically what I think will be the final layout of things.

Head over to google code and grab yourself a copy.

Links:

Hood: example application for jcouchdb 0.10.0-1

On the occasion of presenting CouchDB and jcouchdb at my place of work, I got around to finally create a small example application that is now downloadable as sneak preview. There need to be bugs fixed, features implemented and lots of documentation to be added, but it kind of works.

It’s called “Hood” for neighbourhood and allows you to mark places or people around a place of activity of yours, called hood. it is meant to foster collaboration / tips on local places etc.

It’s Spring Web Application demonstrating some techniques of working with jcouchdb. It’s an eclipse WTP/Spring IDE project with all dependencies you need besides couchdb and tomcat or another servlet container.

Stay tuned for hood to grow into a fullblown app.

Links:

Twitter/IRC integration with boticelli

I have been planning to release my IRC bot project as open source for quite a while now and the recently added twitter integration gave me the final push to actually do it. So now I am proud to announce the inital release of boticelli, a java / spring IRC bot/web application based on the martyr IRC library. Its mean to be easily configurable and extendable and ships with lots of plugins already included.

Available Plugins:

  • Logging – log channel conversation and provide a web interface to browse and search them
  • Seen – Remembers when a user last spoke in the channel
  • FAQ – Manages a keyword list of FAQ keywords that are matched to a description. Useful to provide answers for reoccuring topics in the channel.
  • AccountCreator?/Revoke/Grant – commands to automatically create accounts for the webapplication and to revoke / grant web app access rights (for ops)
  • ServerPing? – plugin that detects broken connections and makes the bot reconnect.
  • Say – plugin to let the bot say something or make it do something (a CTCP Action)
  • Twitter – two way integration into twitter over a bot specific twitter account.

So if you’re into old-school IRC fun, head over to google code and grab yourself a copy.

Links:

YUIZilla Compressor

After again spending time to fix issues resulting from a collision of the yuicompressor jar and the normal rhino jar in one of my projects, I came up with a more radical solution:

  1. Download the source codes from yuicompressor and the corresponding rhino release
  2. Replace every occurance of “mozilla” with “yuizilla”
  3. PROFIT!

 So now I have a version of the yuicompressor that works fine and does not conflict with the rhino version I also have in my project. And I don’t need any stupid jar class loaders or have to write stdin/stdout handling for some terribly slow external yuicompressor process. I can just use the classes

  • com.yahoo.platform.yui.compressor.CssCompressor
  • com.yahoo.platform.yui.compressor.JavaScriptCompressor 

and be done with it. Hurray for fast dynamic server-side script and style compression!

© 2024 fforw.de

Theme by Anders NorénUp ↑