Category: Software

As you might have noticed I’ve replaced the code formatting plugin that I use on the blog. I had trouble with the Geshi-based plugin I used before, so I replaced it with Alex Gorbatchev’s SyntaxHighlighter. This produces lovely formatting and works well - mostly.

SyntaxHighlighter hiccups when encountering the < character unless there is a blank space directly following it, most likely due to it being interpreted as the start of a HTML tag. Also, the "copy to clipboard function produces incorrect code because the text copied has < and > characters converted into the HTML entities &lt; and &gt;. However, I’m not sure if this is a problem with SyntaxHighlighter or with WordPress, since WordPress sometimes messes with formatting by automagically trying to provide good HTML substitutes for certain character combinations.

Most frustrating of all, WordPress has started replacing the ’s in “it’s” with a triple ellipsis character, as well as some other strangeness. Any tips for fool-proof plugins for posting properly formatted code would be most appreciated!

No Comments »

080205_rhinoscript.jpg

Rhinoscript sketch, extruding a revolution surface along random curves. Good cheesy fun.

I had a chance to see a bit more of the impressive tool Rhino 4 during the Generator.x 2.0 workshop, and so I thought I’d have a go at making a simple sketch in Rhinoscript. As it turns out, the fact that Rhinoscript is based on VBScript makes coding feel horrible at first. Seriously, who would want to use syntax like that? It might be easy for beginners to pick up, but it quickly gets painful once you’re dealing with complex API calls and 100+ lines of code.

Nevertheless, frustration soon gives way to amazement at the built-in Rhino library and its vast array of heavy-duty functions for creating and manipulating curves, meshes and NURBS surfaces. In comparison, mesh generation in Processing is enough to give anyone a headache, and I seriously doubt anyone would even attempt to implement NURBS. Even Boolean mesh operations is a staggering task, with no good Java libraries readily available.

While Rhinoscript is firmly a non-realtime tool, its power for pure geometry is amazing. I would definitely use Rhino as a creative tool for digital fabrication projects, where animation is not the goal. There are some excellent RhinoScript resources online, for starters look at RhinoScript 101 and David Rutten’s tutorial. I would also definitely recommend using the Monkey Script editor instead of the built-in editor, it’s more powerful and has a very useful documentation feature.

The script below gives a basic idea of the Rhino syntax, and while it is a basic sketch suffering from 3D clichées, it shows the power and versatility of Rhinoscript. I just wish it wasn’t Visual Basic.

Code: RandRail.rvb

Read the rest of this entry »

6 Comments »

JDIC embedded browser engine

Screenshot of IE running integrated with Processing and other AWT components.

For a while I’ve been wondering if it couldn’t be useful to be able to render proper HTML from inside Processing. While Processing is excellent for realtime graphics, the typographic support is a little basic when faced with the task of designing a more complex layout. Rather than write a new library, why not just use a fast HTML engine?

While there are quite a few HTML rendering engines out there, not all are very complete or indeed very fast. This might be one of the cases where using native code makes sense. Both Internet Explorer and Mozilla offer ways of embedding their rendering engines through native bindings, and after a little googling I was able to find JDIC - the JDesktop Integration Components project.

JDIC aims to bring Java applications closer to feeling like “real” desktop apps. I’m not sure if that’s a battle I would have taken on myself, but in any case they have exactly what I needed: A simplified web browser ready for embedding, able to use either IE or Mozilla as engines. A little coding later and I had a hybrid Processing / AWT application running a web browser. It will even support Flash and Java content, provided that you’ve installed the proper plugins.

The WebBrowser.setContent() function is perfect for loading your own machine-generated content, and events can be captured and processed appropriately. It would even be possible to have a hybrid application, with part of the interface being straight Processing and the rest AWT. I’m keen to try using this to create more complex on-screen layouts. HTML and CSS will always look much better than anything one could create using Swing.

See Flickr for some screenshots.

Code - JDICsample.pde

Read the rest of this entry »

2 Comments »

I’ve recently been playing with the excellent Meta-Markets.com site set up by the talented Burak Arikan. Essentially Meta-Markets is a virtual stock market for trading socially networked capital. If you have a hot blog, a popular Flickr stream or were the first poster of an essential del.icio.us bookmark you can offer it for trade through an IPO, just as if it were a company.

Each user starts out with a capital of 25 “buraks”, which can be used to buy shares in traded commodities in any of the 6 given “markets”: Flickr, Facebook, del.icio.us, Feedburner, Digg and YouTube. By offer an IPO of your own social capital you accumulate value that can be used for further trade. Ultimately the system will also include auctions and payment of dividends to stock holders.

You can make an IPO of any del.icio.us bookmarks of which you were the first poster. Finding out exactly which these are can be a drag, since del.icio.us does not provide an overview of this info. Even using the del.icio.us API won’t give you the needed information, the only way is to use the del.icio.us URL history feature. Needless to say, this can get tedious when done manually.

To address the issue I’ve hacked up a tool I call deliciousChecker. It downloads your bookmarks and then proceeds to check their posting history using HTTP calls to the history page. del.icio.us will block offensive applications that make repeated API calls, so deliciousChecker only downloads the bookmarks when there’s been an update. There is also a 15 second default delay between HTTP calls, it’s not recommended to go lower than this since Yahoo will think you’re a denial-of-service attack.

The code is written in Processing using the delicious-java and Apache Commons HttpClient libraries. The source is included, but for non-Processing users I’ve also provided precompiled applications for Mac, Windows and Linux. You must edit the “delicious.conf” config file to add your username and password.

The application can be exited safely by pressing the escape key. It also auto-saves the database with regular intervals. Upon exit (whether from interruption or upon completion) the application writes a HTML file with your bookmarks, indicating which ones were first posted by you as well as how many other users have saved them.

Downloads

7 Comments »

Following up on my post a few days ago about online storage: I just rechecked the Box.net web site only to discover that they have increased their prices rather than drop them. 5 GB is now $7.95/month or $79.95/year. 15 GB is $19.95/month or $199.95 per year. I might be willing to pay that - if we were talking about 100 GB of storage.

I’ve looked around at other solutions, but haven’t found any that seem really appealing. I’d be happy to hear suggestions or any feedback about your own experiences.

6 Comments »

The idea of storing data online is sexy. It means easy sharing of files, pseudo-backup and access-everywhere all rolled into one. I’ve been using Box.net for a year now, with mostly good experiences. It’s got a well-designed dynamic interface, it makes sharing extremely easy and the service is very stable. I do have a few complaints though:

  • The space you get is small. 5 GB for $5/month is not a lot. They have a bigger plan at 15 GB at $15/month (== $180/year), which hardly seems like a bargain.
  • The interface looks great, but is sometimes a little tricky for complex file operations such as moving lots of files around. It’s got a great search function though.
  • Most importantly: Uploading can sometimes be painful, requiring the use of either a popup applet or a built-in Flash tool. Navigating the file structure from these tools seems like it’s harder than it should be, with slow GUI response times.

Essentially, I’ve been wanting a file browser-like interface for uploading, with immediate folder navigation. Box.net has promised for a long time that they would release an uploading app that works outside the web browser, but has not delivered so far. I like their service and I’m not looking to switch, but I just wish it’d be easier to use…

To the rescue: Fire Uploader, a Firefox extension that supports FTP-style uploading to Box.net, Flickr, Picasa and YouTube. Browsing my Box.net account, creating a new folder and uploading a bunch of images was a snap. It supports downloading as well, but unfortunately not moving files.

It remains to be seen how stable Fire Uploader is in dealing with huge files and broken uploads, but so far it’s looking really good. Upcoming versions might add site-specific functions such as setting permissions, as well as new services to upload to. If it supported moving files it could almost be a complete Box.net GUI replacement.

For Flickr uploading, Fireflix is useful, but a little clunky. For FTP transfers, I like FireFTP, another great Firefox extension. It allowed me to finally do away with clunky FTP software, and do it all inside the browser. I love that that the browser becomes an environment for getting things done.

No Comments »

As mentioned previously, I’ve been working on developing a visual piece for a Nokia phone. After trying Mobile Processing, I came to the conclusion I’d be better off going the old school way: Pure J2ME development in Eclipse. It makes me appreciate just how easy developing in Processing really is compared to going back to the bare bones.

Seeing as my target is a Nokia phone, I figured using Nokia’s own Carbide.j tool for J2ME development. Now it looks like that was a mistake. Nokia has just announced that they’re discontinuing development of Carbide.j. Instead, they suggest two Open Source alternatives, Eclipse with the EclipseME plugin or NetBeans IDE with the NetBeans Mobility Pack.

I found out about the announcement while trying to repair my apparently broken install of Carbide.j, so I’ve now made the jump to EclipseME and dumped Carbide.j altogether. EclipseME feels much better integrated with the IDE, running a MIDLet in a given emulator is as easy as running a regular app. Carbide.j forced you to use a series of clumsy steps just to get the emulator up and running.

Right now everything’s running flawlessly except when I try to use Nokia’s S60 3rd Edition (FP 1) emulator. It barfs at the step of creating the JAR file for some reason. I guess I’ll just stick to Sun's WT5 2.5 emulator and forget about using any fancy Nokia-specific stuff like transparency. The upside is that my final app will theoretically run on any MIDP 2.0 phone.

Update: When trying to install my MIDP application generated with EclipseME on the Nokia phone I kept getting “Invalid JAR” errors. According to a post on eclipseme-users, this is due to EclipseME not including a vital piece of information in the JAD file. To fix it, simply open the generated JAD file with a text editor and add the following:

MIDlet-1: Classname,,packagename.Classname

“Classname” should be the name of your MIDlet class, “packagename” should be the name of the package it’s in. After I added this line to the JAD it installed just fine.

No Comments »

I’ve just learned some handy tricks about packaging Processing-based applications with OpenGL for deployment on Mac OS X. As it turns out, it’s remarkably easy to do on a PC if you use Processing’s own application export as a template. My thanks to Ben Fry for the tip (and also for all the other hard work he’s put into Processing…)

Create a sketch called “Dummy” in the Processing GUI. If your final application will use OpenGL, make sure that “Dummy” does as well. Export using “Export as application”. This produces several folders, of which only “application.macosx” is of interest. This has a “Dummy.app” subfolder which is the actual MacOS application. It’s not a single file, but rather a folder structure that on a Mac shows up as a clickable application. Change the name of “Dummy.app” to whatever name you want, keeping the magic “.app” extension.

In “Contents” you will find a file called “Info.plist”. This contains various parameters controlling your Java application, bundled as pairs of <key> and <string>. Make sure that “MainClass” string is the full name of your main class (including package name if any). Change all instances of “Dummy” to the name of your application. You can also tweak a bunch of other options at will.

If you have JAR files that you need to add, place them in the subfolder “Contents\Resources\Java”. It should already contain core.jar as well as the OpenGL-related JARs and jnilib libraries if you exported Dummy with OpenGL imported. You will need to include the new JARs in the “ClassPath” string found in “Info.plist”.

If all changes have been done correctly, you should now have a runnable application. Copy it to a Mac for testing.

For some icing on the cake (and as an alternative to present mode), you can hide the dock and menu bar on application start. Add the following lines to the <dict> section of “Info.plist”:

LSUIPresentationMode
4

Thanks to Vitaflo for his post on the Processing Forums for this tip.

If you compile your code including the Processing source in an IDE like Eclipse, you can simply replace core.jar with your own as long as it contains all the usual Processing class files. I’ve made a few small changes to the PApplet class, so I prefer this option to the standard JAR file.

This is particularly pertinent if you want your OpenGL apps to be anti-aliased on Mac OS, since smooth() does not always turn it on. The solution is to make an alteration to PGraphicsOpenGL using the GLCapabilities class. Read Mike Creighton's post on the Processing forums for the details.

1 Comment »

I’m currently writing a monster application doing indexing of feeds from blogs, del.icio.us, Flickr, Digg etc. It’s been a bit of a learning curve, but using the excellent and comprehensive Rome library has made it a great deal easier than it might otherwise have been. Rome handles Atom feeds as well as the various confusing RSS variants.

Making sense of feeds is often tricky, as different publishers can use various tags in different ways, or even add their own by introducing custom namespaces. The use of namespaces (which Rome supports through a plugin system) is a promising way of adding custom information, but not without its problems.

Having completed indexing of Flickr, del.icio.us and plain vanilla feeds, I turned to Digg feeds. Imagine my surprise to find out that not only is their advertised namespace (http://digg.com/docs/diggrss/) in fact offline, but they don’t even use it properly in their main RSS feeds.

http://digg.com/rss/containerscience.xml correctly specifies xmlns:digg=”http://digg.com/docs/diggrss/”, but http://digg.com/rss/index.xml specifies xmlns:digg=”docs/diggrss/”. And that just happens to be their main RSS feed. I know it seems niggling to complain, but it messes with the Module I’ve written to handle their tags and seems a tad careless. Oh well, guess I’ll just skip that feed.

More information about Rome, Digg etc:

2 Comments »

Creating PDFs in Processing and post-processing them in Adobe Illustrator, I frequently find myself wanting to do things like adjust global transparency levels, colors etc. So far that’s been frustrated by the rather poor color adjustment options built into Illustrator, but today I finally got impatient enough to look into a scripting solution.

Illustrator has had Javascript support since CS 1, exposing the document object model to anyone with a bit of scripting savvy. Adobe is good about publishing technical documents, perhaps a holdover from the days when they relied on PostScript to build their empire. So anyone can go to the online scripting documentation and download a complete PDF with a description of the Illustrator API.

As might be expected, coding Javascript is not without its troubles, and I found myself having dotcom flashbacks to the days when I would do client-side scripting. In particular, debugging is always been a pain with Javascript, especially when one is not intimate with the DOM and API. Fortunately, the ExtendScript Toolkit provided by Adobe functions both as a IDE and a debugger. Still, I find myself wanting a few nice details, like the possibility of displaying a progress bar when a script is executing.

To give you an idea of the oddities of coding for Illustrator, I am posting a script that allows the user to input a multiplier, which is then used to adjust the opacity of all path items in the active document. This covers for the lack of such a function in Illustrator proper. To be honest I was surprised at the speed with which I was able to accomplish my goal. I would seriously consider this as a way to do brute-force post-processing of vector files.

That said, I doubt it will ever be as fun and quirky as Scriptographer

Source code - OpacityAdj.js

Read the rest of this entry »

No Comments »