Tuesday, 26 February 2008
I had previously written an XMLTV grabber for Greece that had several shortcomings (problems with character encodings and scheduling of programmes after midnight), and left it there. Now, a from-scratch rewritten version is available: XMLTV grabber for Greece.
This version uses the improved XMLTV api, hence it should be available in applications that use tv_find_grabbers. Currently it extracts the following items from the Nova site:
- Program title
- Program description
- Start time
- Repeat status
- Rating
- Categories
Optionally, in slow mode it also extracts the following items if they are available:
- Synopsis
- Image
- Credits
- Year of production
- Duration
I would be interested in hearing from anyone that uses it in non-UTF8 environments (e.g. Windows users). Note that you may need to pass the results through tv_sort in some cases.
Many thanks to vrypan for providing the motive for completing this.
@ Tuesday, 26 February 2008, 12:39
in ( Software)
- 2 comments
Monday, 04 February 2008
Since before Java SE 6 came out, a discussion has been going on in the Java community future directions and extensions of the Java language, with the most energy directed on closures. There are currently two major camps on this issue, the BGGA proposal and the CICE proposal.
CICE
Concise Instance Creation Expressions by Bob Lee, Doug Lea, and Josh Bloch favor adding simple syntactic sugar for anonymous inner class creation, where
List ls = ... ; Collections.sort(ls, new Comparator() { public int compare(String s1, String s2) { return s1.length() - s2.length(); } });
can be written as
List ls = ... ; Collections.sort(ls, Comparator(String s1, String s2){ return s1.length() - s2.length(); });
Additionally, it allows capture of and access to the local variables of the enclosing block(s). In general it's a small proposal, with few warts, that simply provides for small gains in legibility.
BGGA
BGGA is the proposal by Gilad Bracha, Neal Gafter, James Gosling and Peter von der Ahé, which is much more heavyweight, providing for true closures, function types and user-defined control abstractions. The above example could be written as
List ls = ... ; Collections.sort(ls, {String s1, String s2 => int s1.length() - s2.length()});
However, this proposal leads to some weird interactions with expected behaviour:
... System.out.println("1"); {=>return;}.invoke(); System.out.println("2"); ...
The previous snippet will not print "2", as the return is interpreted as a return from the defining method, not the closure; a new type has been added (java.lang.Unreachable) so that the previous code should not compile. What happens tho if you store the closure and invoke it after the defining method has returned? See the Joshua Bloch presentation at JavaPolis 2007 for a recap of the present problems.
All in all, while BGGA adds new powerful concepts and new problems to the Java language, the community is still undecided on whether the inherent problems with closures are justified by the expressiveness they enable; several voices advocate leaving Java unmodified and switching over to JVM-based languages that have them built in, such as Scala.
Further Reading
@ Monday, 04 February 2008, 16:34
in ( Software)
- comment ?
Tuesday, 10 October 2006
I've recently had to use GWT to implement a module for a PostNuke installation. Two problems came up with that - first, the HTML head tag was in a static file somewhere, and I could not modify it and second, the URL that would call the module was not the URL for the files of the module.
To add a GWT module to a static page requires three things:
- A module specific element, which usually has a specific id attribute, where its contents will be replaced by the modules controls,
- A META tag in the HEAD of the page, specifying the modules that will be loaded,
- A SCRIPT tag linking to the gwt.js file.
Requirements (1) and (3) are easily met by modifying the actual HTML page, or in my case, emitting via PHP the HTML elements; however, requirement (2) is a bit harder to implement when one does not have access to the file that contains the HEAD element. Since we're doing AJAX anyway, a Javascript snippet will help us out a bit:
<script type="text/javascript">
var headTag = document.getElementsByTagName('head')[0];
var metaTag = document.createElement('meta');
metaTag.setAttribute('name','gwt:module');
metaTag.setAttribute('content','com.example.Module');
headTag.appendChild(metaTag);
headTag=null;
metaTag=null;
</script>
Inserting that code before the tag for (3) will ensure that our module appears at least in the DOM. However, we aren't done yet, as the files for each module are resolved by GWT relative to the current location of the browser - which isn't that useful when your URL is something along the lines of "http://example.com/index.php?module=this&q=that" but your GWT modules reside in "/gwt-modules/example".
Googling around did not give any insight on the issue, so I delved a bit into the innards of GWT, and found an undocumented feature that allows one to rebind the base URL for a GWT module: simply use
<meta name="gwt:module" content="http://example.com/gwt-modules/example=com.example.Module" />
instead of
<meta name="gwt:module" content="com.example.Module" />
Obviously, this also allows for modules in different locations.
@ Tuesday, 10 October 2006, 12:57
in ( Software)
- 3 comments
Thursday, 20 July 2006
Quick: how long is the shortest program to calculate the first prime number
after a given number? The answer might surprise you!
In perl, it's about 60 characters:
perl -e '$i=$ARGV[0]+1;$i++while("."x$i)=~/^(..+?)\1+$/;print"$i\n";'
90
Of course, I believe
APL will
win that contest hands down...
P.S: There's even a perl competition to produce the shortest code for a
given problem, with the name
Perl Golf...
@ Thursday, 20 July 2006, 15:22
in ( Self, Software)
- 9 comments
Monday, 12 December 2005
If you are a Java developer in a non-ISO8859-1 environment, you will have
encountered the character set problem when editing property files. The spec
says that they are in ISO8859-1, with Unicode escape sequences for characters
outside that set. While one can set up automatic translation, it is intrusive
and not suited to all cases. Being fed up with the problem and the inelegance
of all the available solutions, I wrote a custom character set provider which
handles the property file encoding as a multi-byte character set.
The source is
here,
and the prebuilt JAR is
here.
To use the property character set, drop the JAR file in the extension folder of
your JRE, usually $JAVA_HOME/lib/ext and restart (or start) your application.
Property files should be assigned the "X-PROP" character set, and all should be
ready.
If you are using Eclipse 3.1 or later, simply go to Window → Preferences →
General → Content Types → Text → Java Properties files, set the default
encoding to X-PROP and select
Update to apply the setting.
The code is in the public domain, and I'm not responsible if it munges your
files, destroys your computer or causes the next ice age, etc...
@ Monday, 12 December 2005, 23:58
in ( Eclipse, Software)
- comment ?
Tuesday, 30 August 2005
A recent slashdot
discussion that forked off to GUI vs CLI made me think that this split
looks artificial, and that a merger of the two would be at least worth
investigating.
My idea is to add an optional command-line to each Nautilus window, which
will be one text line high and would appear between the status bar and the
icon view. It would be a normal terminal running the user's shell, with a
number of interaction possible between the shell and the command line:
-
the current directory of the shell and the nautilus window would be
synchronized. The gnome-terminal in Ubuntu breezy at the time of writing
has an implementation of current directory detection based on escaped echos
at each prompt. Some problems here with the other way of synchronization,
as a command to the shell might not be parsed due to the user having typed
some text.
-
file selection on the icon view would result in the addition of the files
to the command line. Again, problems will exist if the user types some
text. Also, what happens if the use deselects some files?
-
a special command would take a list of files and show them in the iconic
view. Such lists of file scan be generated with find or grep.
-
a keyboard command would switch the view between the four different states:
no command line, 1 line high command line, 50% split between command line
and icons, only command line (effectively degenerates into a terminal)
@ Tuesday, 30 August 2005, 08:55
in ( Software)
- comment ?
Older Posts >>
|