Lightly Seared On The Reality Grill

Random expat geekery from The Low Countries

Browsing Posts in Technology

Stellarium screenshot I’ve been playing around with Stellarium for most of the weekend and finding it utterly fascinating. The program is a free and open-source planetarium that runs under Linux, Windows or Mac OSX and it shows you a realistic 3D view of the night sky. This is impressive in itself and provides a useful tool for deciding which are the best nights to take your binoculars outside. But there is much more to it than this.

As well as allowing you to select any location on Earth, Stellarium also allows you to pick locations elsewhere in the Solar System. This is the closest I will ever get to standing on Mars and watching the Earth rise and, even virtually, it’s a stunning sight.

flattr this!

Screenshot As someone who is unable to resist a freebie, I have acquired a number of novels in various electronic formats over the past few years. When offered these books, I download them with every intention of reading them but not a great deal of thought as to how or when.

Obviously, I could read any or all of these on my PC but the reality is that sitting in front of a screen is not a comfortable position for ploughing through 400 pages of fiction. So I have finally taken the plunge and installed FBReader on my N810. It’s lovely.

As you can see from the screen shot, the display is nice and clear and when you go to full-screen mode you get a decent sized page of text which can be conveniently navigated by way of the + and – buttons on the top of the device. FBReader supports a variety of formats including Fictionbooks (FB2), ePub and Mobi (excluding DRM’ed files). One format that it doesn’t support, however, is PDF. Guess what format most of my downloads are in?

Luckily there is Calibre.

Calibre is an eBook library manager but it also includes a stack of conversion options – including PDF to FB2. The conversion is not always perfect and odd bits of extraneous data can end up in the FB2 file although it looks like the issue is down to poorly structured PDFs rather than a problem with Calibre. Since FB2 is an XML format, imperfect conversions can be very easily fixed using the find and replace options in your text editor of choice.

And just to expand my ever-growing pile of unread books even more, I have found a few sites that distribute eBooks for free, including ManyBooks.net (who have an RSS feed) and Fictionbook-lib.org.

I’m still not entirely convinced how well a small, backlit screen will work as a replacement to reading a full-sized ink on paper novel but being able to fit a small library in my pocket is certainly convenient. The real test will come when we next go away which is very likely to turn into a test of comfort versus convenience.

flattr this!

The IBM i includes several features which are – or can be – incredibly handy but which are not supported by industry standard tools. One example of this is physical files with multiple members. On the i, they provide a very effective mechanism for managing large amounts of similar data (transactions, for example). However, SQL doesn’t support multiple members and, therefore, can usually only access the first member in the table (which is usually the member with the same name as the file/table). This causes problems when people are trying to access i data from external applications and, as a consequence, far too many people end up not taking advantage of multiple members.

It’s a shame because there is a workaround and it’s painfully simple – all you need to do is create an alias.

In the, rather trivial, example below I want to delete transactions out of the INVALID member in file TRANSACTIONS based on various selection criteria provided by the business. So I create an alias, REJECTED. Now I can delete transactions out of the INVALID member by running the delete command over the alias REJECTED.

Set schema LIBRARY;

Create alias REJECTED for TRANSACTIONS(INVALID);

delete from REJECTED
where... ;

drop alias REJECTED;

Granted, this is a pretty basic example, but the general approach – Create Alias; Do Stuff; Drop Alias – will work in any case where you are accessing IBM i data from a non-i environment (such as PHP or Java JDBC).

One final note. It is, of course, possible to simply create a permanent alias and avoid the overhead of repeatedly creating and dropping the temporary one. You do have to be a little bit careful doing this, though, because if you rename a member in the file, the alias will no longer point to it and you would have to remember to either create a new alias or create a new member with the old member name.

My memory is terrible. This is why I prefer to create a temporary alias when I need it and then drop it when I’m done.

flattr this!

Why i?

No comments

Here’s Why. It’s a YouTube playlist in which Steve Will, IBM Chief Architect for IBM i describes the not inconsiderable value of the IBM i.

Via The Four Hundred.

flattr this!

I thought, until recently, that I was about to start missing out on my regular fix of System iNews magazine but a little poking around on their website reveals that most of the magazine is archived online. Which is why, at the end of May, I can start looking forward to IBM i 7.1, the next release of the IBM i.

There has been a lot of talk in the industry press over the past month about Rational Open Access which will enable RPG applications to easily reach new devices and new users with new interfaces, and this is certainly something that has been needed for a long time.

What really caught my attention, however, is the fact that DB2 for i now a whole lot more XML friendly. With this release, it will be possible to store data in its native XML format, easily split into relational database columns (the bit I really like the sound of) or created from existing database objects. On its own, this will really open up a whole slew of possibilities related to application integration and interface design, but there’s more.

The OmniFind Text Search Server now supports search in XML documents within DB2. There is a more detailed discussion of what this means, and how to get started, over here, but my immediate thought is: Oh my, this will make things even faster!

flattr this!

I have found, after I’ve been using Firefox for an extended period of time, that it slows right down and starts to become quite a bad memory hog.

This can be resolved by compacting your SQLite database. Close down Firefox first and then past this command into a terminal window:

for f in ~/.mozilla/firefox/*/*.sqlite; do sqlite3 $f 'VACUUM;'; done

Voila! Your Firefox is as good as new

flattr this!

Dear programmer who was here before me,

You may be proud of the fact that you have managed to cram no less than eight unrelated bits of functionality into a single application, even if you did need to resort to an unreadably bizarre collection of flags and logical inanities to control the flow of your program.

However, when I look at the great steaming pile of spaghetti you have left behind, I find myself unable to avoid the conclusion that you are a moron.

flattr this!

When you compile a SQLRPGLE program, the default Commitment Control option is *CHG. This indicates that tables you update will be locked until the changes are committed or rolled back. This is all well and good, but you do need to have journaling switched on for the tables for it to work.

The compiler doesn’t check this so, by default, a program to update an unjournaled table will compile and can be executed. It just won’t make any updates and you will need to dig through the job log to track this down.

The Right Way

What you should do is journal everything and take full advantage of commitment control.

In order to do this, you would need to create a journal receiver and a journal…

CRTJRNRCV JRNRCV(MYLIB/MYRECV) TEXT('My Journal Receiver')
CRTJRN JRN(MYLIB/MYJRN) JRNRCV(MYLIB/MYRECV) TEXT('My Journal')

And start journaling your files…

STRJRNPF FILE(FILEA, FILEB, FILEC, …) JRN(MYLIB/MYJRN) IMAGES(*BOTH) OMTJRNE(*OPNCLO)

When you want to stop journaling a file, you can do this:

ENDJRNPF FILE(*ALL | FILEA, FILEB, FILEC, …) JRN(MYJRN)

Bear in mind that the journal receivers can get pretty big pretty quickly so you will need to talk to your operations folks about disconnecting and purging these on a regular basis.

The Other Way

Of course, you may well be working with a third party application which is not taking advantage of commitment control and, for which, you can’t justify implementing a whole set of journals. This leaves you needing to turn off commitment control for your SQLRPGLE program. There are two ways of doing this:

What you can do, every time you come to compile this program, is ensure that you compile it with COMMIT(*NONE).

This approach works but it does rely on you, and every developer that follows you, remembering to change the COMMIT parameter. To me, this is a guarantee that sooner or later someone will forget and a trivial change will suddenly break a previously reliable program.

It is much better to explicitly turn off commitment control in the program itself, ideally in the header spec. Unfortunately, I’m on release 6.1 and this doesn’t include a compiler option for commitment control in the h-spec, so I am left with the following workaround.

Put this line of code at the start of you program:

exec sql Set Option Commit = *NONE;

Commitment control is now switched off and your SQLRPGLE program will happily update your horrible, unjournaled, third-party table.

flattr this!

So the application I mentioned on Monday was finally approved late yesterday and, today, it’s written and working. There were, inevitably enough, some changes to the spec. The application that has been approved can be executed once an outage has been started and will send a break message to any session still signed on that shouldn’t be, and generate a simple report so the operations folks can visit the offending users with a baseball bat.

This, in itself, wouldn’t be enough for me to bother reposting the code but since I also took the opportunity to develop the application in RPG (or Free Format ILE RPG if you want to be search engine friendly). Doing this gave me a great deal more flexibility over the earlier CL code and also allowed me to prototype the API names into something a lot more readable. You’ll see what I mean if you take a look at the code.

Again, I have filed off the serial numbers and you can take a look at the code here: Lockout.RPGLE

Feel free to copy it, compile it and modify it if it is of any use to you. And if you have any comments or observations, I’d love to hear them.

I do mean it about the baseball bat, though.

flattr this!

There are times (month end, for example) when you need to know which users of an application are signed on so you can respond accordingly. Reliably enough, the iSeries provides all the APIs you need to achieve this.

There are two APIs you need to know about:
QUSLJOB – List Job, generates a list of some or all jobs on the system. This information can be pushed into a user space.
QUSRTVUS – Retrieve User Space, pulls the information out of the user space.

The CL program, below the fold, shows these APIs in action. It does work, although it won’t make any changes – I’m still waiting for final approval to go ahead and write this – and I have filed off a few serial numbers to avoid copyright problems. Feel free to copy it, compile it and modify it according to your own needs. If you have any comments, feedback is always appreciated.

What the program does is read through a table of application users (USERTABLE) and, for each USERID, lists all active jobs for that user in a user space. A nested loop (at Label STEP01A) loops through each job found to retrieve the essential data.

What you do with this retrieved job information is up to you, but I’m thinking in terms of disabling the profile and ending the job.

Update: I’ve just noticed that copying and pasting the code into WordPress causes more than a few oddities in the rendering. So I’ve moved the code into a text file which you can download here: RtvActJob.CLLE

flattr this!