Incredible 2D Images using NodeBox (Intel Binary!)

Recently, I’ve been busy exploring 2d graphics algorithms for generating great looking logos, wallpapers, and backgrounds. The article “Blog Redesign” drew my attention to a great tool on Mac OS X. NodeBox is an open-source application for programming 2-dimensional graphics and animation in the Python language. NodeBox lets the user focus on coding graphics without worrying about the underlying technology.

NodeBox ScreenshotIt is based on another open-source project, DrawBot, and is inspired by technologies like OpenGL and PostScript. This means NodeBox is based on vector graphics rather than pixels. As such it’s an excellent tool for generating 2D graphics intended for print, and in particular typographic experiments. NodeBox can generate PDF documents that can easily be used in Adobe Illustrator or any professional vector graphics package. NodeBox can also generate QuickTime movies for animations.

If you’re curious, the NodeBox Gallery shows off some good-looking sketches. Tom de Smedt, one of NodeBox’s authors, has published two good examples: Supercurly uses the modular font Superveloz by Andreu Balius to construct organic compositions, while Photobjects is a database of images which can be queried for images connected to certain keywords. These are then used to create randomized collages of images.
Prism is an algorithm for creating a color palette on any subject. It uses the internet as a semantic database.

NodeBox is available in version 1.0 release candidate 7, and is sophisticated enough to count as a real production tool. However, NodeBox is compiled only as a PowerPC binary for Mac OS X. As a proud owner of a new Intel-based Macbook, I’ve been looking for a way to compile the source (included in the download) as a binary for Intel-based Macs.

So read on for the required steps to compile and build it yourself, or just download my build, NodeBox 1.0rc7 Intel Binary for Mac OS 10.4.

Read the rest of this entry »

Comments (6)

DTrace comes to Mac OS X Leopard

The keynote of the much anticipated Apple WWDC 2006 is over and besides revealing the features of the upcoming Mac OS X Leopard, Apple has announced Xcode 3.0. This is the primary IDE and developer toolset for Mac OS X. The feature preview of Xcode 3.0 gives some information about a new tool named Xray. It visualizes metrics gathered from the instrumentation of applications, and possibly of the OS itself — I quote: "such Xray instruments leverage the open source DTrace, now built into Mac OS X Leopard". It seems Apple has ported the DTrace framework from Sun’s OpenSolaris or from FreeBSD to Mac OS X! Wow, this is really great news. I use DTrace regularly for tracking performance problems under Solaris and it’s a fantastic system.

Dtrace in XCodeDTrace enables performance tuning with applications and troubleshoot production systems — all with little or no performance impact. DTrace also provides improved visibility into kernel and application activity, giving the user operational insights with which they can make performance gains. Here are some examples to illustrate the power of DTrace for application and system diagnosis: Using DTrace to Profile and Debug A C++ Program, DTrace How To Guides, DTrace Tools and Top Ten DTrace Scripts. Did I mention the J2SE 6.0 built-in Dtrace Support? And for the seriously interested, the original Usenix paper about DTrace, "Dynamic Instrumentation of Production Systems" (2004), and the ACM Queue article "Hidden in Plain Sight" (2006) give valueable details on its motivation and concepts.

Update: $<blog in its entry DTrace on MacOS X at WWDC gives some more details on the DTrace integration into Mac OS X Leopard.

Leave a Comment

Scientific Plotting on Mac OS X (Intel) using Gnuplot and Plot

Gnuplot under AquaTermAfter having successfully moved my LaTeX publishing environment to the new Macbook, all that was left was a working Intel build of gnuplot 4.1.0 (which has some nice new features over 4.0). This was actually not quite easy, so I’m going to document my steps for producing a Universal Binary of Gnuplot 4.1 here for future reference.

You might also take a look at Plot. It’s a first-rate freeware plotting tool with some really great features (think ProFit or GRACE), AppleScript support, and a full-blown layout engine. All this is nicely integrated in a great looking Mac OS X GUI. I really love it.

Read the rest of this entry »

Comments (36)

PDFs available for JavaOne 2006 Sessions

Check out the JavaOne 2006 Conference Session Catalog. Presentation files available for download are indicated with a paperclip icon. After clicking on a paperclip, you will be prompted to enter the following Username “contentbuilder” and Password “doc789”.

Tip: Use a mass download tool like FlashGet, which can use the given username and password for all accesses — saves you a lot of typing.

Leave a Comment

How to Remove a PDF Signature (that disallows any document changes)

PDF documents may be secured by an initial signature/certificate for disallowing any changes. This is not to be confused with “password security” or “certificate security”.

I am speaking of the kind of restrictions you will get with “Menu>File>Save as Certified Document” and then selecting “Disallow any changes to the document” (which also implies “Lock the certifying signature so that it can’t be cleared or deleted by anyone”).

This action produces a document which you cannot modify (e.g. add bookmarks or comments), and you also cannot remove the restricting signature. No PDF password remover will help you here, since there is no password!

But I found out that you can do – quite simply – disable the restrictions and render the signature removable, i.e. after these changes, you can manually delete it with Adobe Acrobat Professional:

With the Perl scripting language, this hack is applied with the following script

# Usage: perl invalidate-signing-certs.pl <in.pdf >out.pdf
binmode(STDIN);
binmode(STDOUT);
$/ = "\0";
while(<>) {
  s#(/Perms<</DocMDP.*?>>)#' ' x length $1#ge;
  s#(/Ff 1)(?=.*?/Lock )#' ' x length $1#ge;
  s#(?<=/Lock)(.*?)(/Ff 1)#"$1" . ' ' x length $2#ge;
  s#(/Lock .*?)(?=/)#' ' x length $1#ge;
  print $_;
}

The next time you open the modified document with Acrobat you will still see the signature field. Just click on it with your right mouse button and from the menu popup select “Clear Signature Field”, then “Delete Signature Field”. Now safe it and everything is fine – no more restrictions. (Tip: Use “Save as” to clean up the document of any hidden signature objects.)

Note: Always make a backup of your PDF document before modifying it, since sometimes the hacks just don’t work and you end up with a document that Acrobat cannot repair.

Update August 2006: The procedure of unsigning is now available as a video (AVI, 2,4 mb). Or watch it at Youtube.com. It shows how to unsign a ebook (in PDF 1.6 format) with the batch script using Acrobat 7.0.

Update October 2006: I’ve updated the example code. The earlier version had problems due to platform-dependent handling of line endings. The current script version operates in binary mode and is tested under Window (ActiveState and Cygwin) and Mac OS X.

Download

The archive pdf-scripts.zip contains the script shown above, and some other useful scipts:

  • invalidate-signing-certs.pl: Invalidates all Signing Certificates, thus removing any restrictions imposed by them.
  • bookmarks-fitpage.pl: Change Bookmark display style to “Fit Page”.
  • bookmarks-close.pl: Close opened Bookmark Folders.
  • bookmarks-close-1.5.pl: Close opened Bookmark Folders (for documents in PDF version 1.0-1.5, i.e. Acrobat up to 6.x)

Comments (108)

Setting up Networking for PearPC 0.3.1/MaxOS X (10.3) on Windows

This procedure seems easy, but I did encounter some problems with networking. In the following, I will summarize the procedure for setting up networking under Windows XP (SP1).

First of all, here are some useful links you might visit for troubleshooting:

OK, now on to the steps for getting networking working:

Read the rest of this entry »

Comments (9)

EJB Container-Managed vs POJO Relationships

When moving from EJB 2.x CMP Entity Beans to O/R Mapping Frameworks like Hibernate or Toplink you should be aware of the fundamentally different approaches in dealing with relationships between persistent objects. Today, I had a look at the book “Hibernate in Action“; on page 106 in chapter 3.7.1, the authors discuss “managed associations” and this is very interesting and important:

If you’ve used CMP 2.0/2.1, you’re familiar with the concept of a managed association(or managed relationship). CMP associations are called container-managed relationships (CMRs) for a reason. Associations in CMP are inherently bidirectional:

A change made to one side of an association is instantly reflected at the other side. For example, if we call bid.setItem(item), the containe automatically calls item.getBids().add(item).

Transparent POJO-oriented persistence implementations such as Hibernate do not implement managed associations. Contrary to CMR, Hibernate associations are all inherently unidirectional. As far as Hibernate is concerned, the association from Bid to Item is a different association than the association from Item to Bid.

To some people, this seems strange; to others, it feels completely natural. After all, associations at the Java language level are always unidirectional – and Hibernate claims to implement persistence for plain Java objects. We’ll merely observe that this decision was made because Hibernate objects, unlike entity beans, are not assumed to be always under the control of a container. In Hibernate applications, the behavior of a non-persistent instance is the same as the behavior of a persistent instance.

For an example consider a manager entity with a (bidirectional) 1:N relationship to employees that work for him. Additionally, a manager is associated with projects (N:M relationship), for some of them, he is even a teamleader (unidirectional relationship of teamleader entity). Now, a certain manager, for some reason, moves to another department and is disassociated with his employees and his current projects (and vice versa) and is teamleader no more.

With EJB 2.x CMP Entity Beans and their Container-Manager Relationships (CMR) this is one line of code:

// Implicitly removes manager from its employees and projects
// and also removes him as any teamleader
manager.remove();

That’s it! The Persistence Manager handles all the details, because he has to enforce referential integrity and knows the entity model/relationships from the deployment descriptor. What details? Well, look at how this is achieved with Toplink (same with Hibernate):

Iterator iterator = (Vector)manager.getEmployees().iterator();
while(iterator.hasNext()){
    employee = (Employee)iterator.next();
    // For bi-directional relationships,
    // it is important to maintain both sides
    // of the relationship when changing it:
    employee.setManager(null);
}
manager.setEmployees( new Vector() );

iterator = (Vector)employee.getProjects().iterator();
while(iterator.hasNext()){
    project = (Project)iterator.next();
    if(project.getTeamLeader() == manager){
        project.setTeamLeader(null);
    };
}
manager.setProjects( new Vector() );

unitOfWork.deleteObject(manager); 

Why I am mentioning this? Because EJB 2.x Container-Managed Relationships (CMR) are really easy to use, quite fool-proof. POJO persistence, on the other hand, requires a lot of involvement and understanding of the entity relationship model from you. Actually, you manually express the logic which is already expressed in the mapping descriptor in your source code, a somehow redundant work. I think this approach lacks scalability w.r.t. the model complexity and coding errors quickly lead to an inconsistent database (or to SQL exceptions in case of foreign key constraints).

Comments (3)

Useful Mozilla/Firefox Extensions

After having playing around with extensions for some while, here’s my list of extensions I consider “huge usability improvers”:

  • DictionarySearch: Looks up selected word in an online dictionary by context menu. Hint: You can add custom dictionaries, e.g. “http://dict.leo.org/?search=$&#8221;.
  • Diggler: Adds a button next to the location bar that can clear the location bar (much like the one in Konqueror) and also drop down a menu with more actions.
  • Download Manager Tweak: A modification of the Firefox download manager that changes its appearance and allows it to be opened in a separate window, a new tab, or the sidebar.
  • Googlebar: An unofficial Google toolbar for Firefox. Note: There is also GooglebarL10N, which gives you localized version.
  • LiveHTTPHeaders: View HTTP headers of a page and while browsing.
  • Mouse Gestures: Allows you to execute common commands using mouse gestures.
  • ReloadEvery: Reloads webpages every so many seconds or minutes.
  • SuperScroll: Override the default keyscroll and mousewheel settings.
  • Tabbrowser Extensions: Improves tabbed browsing a lot. Note: This extensions seems to seriously slow-down Firefox.
  • Web Search Plus: Uses the current Search Bar engine for context-menu Web Searches.

These two come pre-installed with Firefox:

  • Web Developer: Adds a menu and a toolbar with various web developer tools.
  • Dom Inspector: You’ll need to enable this when you install Firefox – choose the ‘Custom install’ and check the box for ‘Developer tools’. The DOM inspector allows you to view the ‘Document Object Model’ for a web page. See here for more information. Also note that the extension manager of Firefox 0.9.2 seems to have a problem with it (search Google).

Note: This list of extensions is an update of my earlier posting A look at Web Browsers and File Managers.

Leave a Comment

Generating .dll files for JNI under Windows/Cygwin/GCC

In Windows you can use the Cygwin GCC compiler/linker to produce the .dll files needed for JNI (Java Native Interface) applications. Take for example the JNI HelloWorld example from Sun.

But there seem to be several obstacles. First I got compiler errors (concerning undefined jlong type) and after resolving this I wondered how to produce a Win32 native .dll file.

The solution is as follows (my environment is J2SE 1.4.2-b4, Cygwin GCC 3.3.1):

Changes to JDK headers needed for GCC

(Take from here) GCC doesn’t have a __int64 built-in, and this patch basically uses “long long” instead.

  1. Edit the file /include/win32/jni_md.h, Where   is the installation root (eg., c:/jdk1.4.2).

  2. Replace the segment:

    typedef long jint;
    typedef __int64 jlong;
    typedef signed char jbyte;

    with:

    typedef long jint;
    #ifdef __GNUC__typedef long long jlong;
    #else
    typedef __int64 jlong;
    #endif
    typedef signed char jbyte;

Modify the GCC spec file

This modification is only important if the next step (compiling and linking) produces an linker error “dllcrt2.o not found”.

(Take from here) In the Cygwin shell edit the file “/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs” (replace 3.3.1 with your GCC version). Find the text “dllcrt2” and replace it with the absolute (Cygwin) path to dllcrt2.o, e.g. “/lib/mingw/dllcrt2”.

Compile and Link the .dll file

(Take from here) Call the compiler:

gcc -L /lib/mingw -Wl,--kill-at -mno-cygwin -shared -I /include/ -I /include/win32/ HelloWorldImpl.c -o hello.dll

Replace with the Cygwin path to your J2SE, e.g. “/cygdrive/c/Java/jdk1.4.2”.

That’s it. Now I get “Hello World!”. Fine.

Comments (11)

Opera Wiki and Web Developer Toolbar

Opera is such a wonderful Web browser and its most important feature is customization. The Opera7Wiki shows tricks you wouldn’t dare to dream about.

My favorite is the customization collection Web Developer Toolbar which enhances toolbars, menus with most useful entries, and adds a toolbar with quick access to dozens of Web development-related bookmarklets. A must-have!

Leave a Comment

« Newer Posts · Older Posts »