Runtime.exec() slight weirdness

Posted by Simes at 5:13 pm
Oct 042007

Change working directory of java code to location of batch file before code is launched, call rt.exec("batchfile.bat"), batch file runs.
Leave working directory alone, call

File dir = new File("C:\\path\\to\\batch\\file");
rt.exec("batchfile.bat", null, dir);

Batch file does not run, giving a file not found error.

Change second line to rt.exec("cmd /c batchfile.bat", null, dir); – batch file runs.

I’m not sure why this is, but I thought the information might be useful to someone.

Sep 202007

In this particular case, about an hour and a half.

I’m sure there’s a moral in there somewhere, but other than “you apparently need to know more about how the APIs work internally than should be necessary” I can’t seem to find it.

Hey ho. Ever forward.

PhotoShock

Posted by Simes at 1:59 pm
Sep 182007

Every so often I get a small surge of creativity which enables me to dismantle someone else’s work and twist it to my own nefarious purpose. In the latest of this irregular series, I present: the Bioshock gamercard sig.

Bioshock image

Uses my gamercard parser thing to dynamically update the score, and stuff. Nothing particularly special, perhaps, but I like it.

Aug 302007

Lotus Domino. Making some stuff easy, and some fairly obvious stuff stupidly convoluted.

I have a subform which has a version number in it. It’s in the subform so it only needs to be changed in once place to show up in all of the site design where it needs to be, and it’s not in a document because they don’t travel with the design. So far so good, you might think.

Pages do not support subforms. Or shared fields. Or any other way of incorporating reusable design elements. So I’d be better off using a form. But I can’t use a form, because you can’t specify a form as the default element to open when the application is opened, and short of reconfiguring every other bit of the intranet which links to all the deployed instances of this app, the only thing I can think of to do is put a redirect into the onload event of the page so that it redirects to the form version, which has the subform on it. This is a nasty hacky icky brittle way of doing it but I cannot think of any other way.

Sometimes being a programmer can be immensely rewarding. This is a million miles away from being one of those times.

EDIT: Thanks to Matt for pointing me in the right direction for the Notesy workaround for this. It’s still a bit of a hack but less so than redirecting via javascript in the browser. I feel slightly happier now.

Domino ReadViewEntries agent

Posted by Simes at 1:57 pm
Mar 092007

Sometimes when you’re working on a Domino web app, you need a NAB picker to help your users fill in name fields. At such times, you scour the web because you know that clever people like Scott Good and Matt White are out there and have probably done it already. And you find that they have, and you grab that code and use it. And it’s all fine for intranet sites.

And then, as happened to me this week, you find that you need to use your name picker with a NAB that normal users are not allowed to read, such as corporate sites which face the Internet. The picker I’m using, Scott’s, based on Matt’s, uses ReadViewEntries to get its data. Without user-level access to the NAB, it doesn’t work.

So, ideally, in this situation, what you need is an agent which can be run from the web and does essentially the same thing as a call to ReadViewEntries, because that way you can use the same name picker at the front end. And that, dear reader, is what I present to you today.

Again, the first thing you do in this kind of situation is hit Google to see if anyone’s done it already. And so this code is mostly from an agent at Vince Dimascio’s site which presents Full-Text Search results in a ReadViewEntries-like form. All I did was pull out the FTSearch stuff and put in support for start, count and startkey values. I’m quite pleased with the end result, though – it’s pretty nippy, certainly still fast enough for the typeahead lookup to work.

Source is here. Enjoy!

Project Shoehorn, Part II

Posted by Simes at 3:47 pm
Feb 262007

After a helpful response from Charles to my last post on the subject, I pulled the 0.9.3 JRuby build and ran my test against it. On the way I ran into a few other things and tidied up a few more as a result.

Firstly, the jars are now in the jre/lib/ext folder of my Notes client install, rather than putting them in another folder and adding them to JavaUserClasses.

Secondly, something about the new build causes a SecurityException to fire when running the test code again. I’m guessing it’s something to do with the new bytecode manipulation stuff in JRuby, but I don’t know for certain. Granting

permission java.lang.reflect.ReflectPermission "suppressAccessChecks", "true";

sorts that out.

And so, we run the test code again. A substantial improvement, knocking the run time down to about 6 seconds – still not really usable as such, but certainly better than before. It might be worth looking into a more real-world sort of test, one which actually opens real documents from real views and manipulates them. I shall also, as requested, be posting the details to the JRuby mailing list to see if anyone there can help.

Project Shoehorn

Posted by Simes at 3:29 pm
Feb 222007

As many of you may know, I have something of a love/hate relationship with Lotus Domino. I love it for some of the things you can do with it, and I hate it for some of the hoops it makes you jump through when you try and do something slightly different. Also I hate LotusScript, but that’s only because I still hang on to a few shreds of my sanity. However, Domino is what I do for a living, so I’m kind of stuck with it.

Anyway. I’ve recently become interested in Ruby, and so set to wondering if it would be possible to in some way use Ruby’s elegant and succinct syntax in my neverending quest to be able to do the same amount of work only with less typing. Thus I came upon the notion of trying to run Ruby scripts from a Notes agent.

Continue reading »

iTunes playlist exporter

Posted by Simes at 5:07 am
Oct 292006

A new entry on the Code and Stuff page – exports iTunes playlists to .M3U equivalents. Handy for XBox 360 owners who use Media Connect but want to manage their custom playlists in iTunes on their PC.

Me, in other words.

CSS monkeyage

Posted by Simes at 1:41 pm
Jun 182005

Our app has kind of a portal-y front-end on it, which means we have a frame set with between two and four frames, all of which use basically the same CSS. The CSS is not cacheable because we’re running over https, so it adds a substantial amount to the payload for any given portal page.

The solution? Load the CSS into the frameset, and use this bit of code right here in the onLoad() of each of the in-frame documents:

function loadStylesFromRootWindow()
{
    var sheets = window.top.document.styleSheets;
    for (var i = 0; i < sheets.length; i ++)
    {
        var sheet = document.createStyleSheet();
        sheet.cssText = sheets[i].cssText;
    }

}

I should probably mention that there's almost certainly no chance of this working with anything other than IE, but in a closed environment such as this I don't care. :)

© 2011 simes dot org Suffusion theme by Sayontan Sinha