Ramblings of a
Semi-Retired Programmer

14/11/2013 - A Mess.

This page is a mess. The links in the menu and right side bar are probably OK, but otherwise it needs a complete overhaul.

You would probably do better to visit the articles page.

07/07/2012 - A PHP Site Mapper.

First I should be honest, and mention that his page was originally written a year or so ago. I post it again here now because I am trying to regularise the structure of my software pages, and because I have given it a small makeover, giving it a CSS file of its own, and some initialization variables in the PHP to tailor it to your site.

My initial ambitions were grandiose. I would offer a page that would let anyone create a site map of their own web site, or of anybody else's. At the same time I would be able to generate my own site map in a way that I could verify. The site map would include page addresses, titles, and the content of the description and keywords meta tags.

The final result did not meet all these objectives, but it does provide a customizable component that you can use on your site to create a site map with links to all your pages - more here.

04/07/2012 - Distributed Image Loading for Slow Connections.

The Internet connection that I have here in Arusha, Tanzania, is not exactly what you could call broadband. This makes me very sensitive about the time it takes for some of my pages to load. In particular I've always been bothered about the time it took the page for my wife's guest house to load. On the main page there are three picture galleries that the user can navigate, a total of 28 600x450 jpegs. I used to display an apologetic message for users with slow connections like mine, which dissappeared when loading was complete.

This was not very satisfactory, so I decided to try a different approach, whereby the first image in each gallery was loaded normally, but the subsequent images were loaded after the initial window load was complete - (more).

02/07/2012 - Yet Another Attempt at Modal Dialogs in CSS/jQuery.

I was noodling with CSS and Javascript while our Internet connection happened to be down, trying to come up with a scheme that would improve the pseudo-modal dialogs that I was using in my current project.

The result seems quite robust, and looks decent on IE8, and the current (or close to) versions of Firefox, Chrome, and Opera. So as usual I thought I had better make some notes so I would continue to understand how it works. You can find my notes here.

27/06/2012 - Implementation notes for persistent logins.

To finish off (well almost) the simple newsfeed system I've been working on, I needed to implement the 'Remember' checkbox that was present, but did not do anything. I was delighted to find what I think is an excellent 'Best Practice' article by Charles Miller. There was no implementation example there, so I thought I'd just sketch out what I ended up using. This only represents a partial implementation, since my page does not really do anything that requires the higher level of security. (more)

24/06/2012 - A Lightweight News-Feed System for LAMP/jQuery.

I wanted a simple news-feed system for my web page so that users could post input, and I or other users could comment on their posts. The target was that it should look rather like a Facebook news feed so that many users would be comfortable with the interface.

I looked at the available social networking solutions, but they all seemed like using a sledgehammer to crack a nut, and were often rather fussy about server settings, versions, etc. So I decided to make something simpler. The result works with a LAMP (Linux-Apache-MySQL5-PHP5) server, and uses jQuery client side. It gets by with very ordinary PHP settings.

Both the dynamic and static contents of the page come from a database, so it is quite amenable to customization. Everything else can be changed by tweaking a CSS file.

It should be possible to install it by running an SQL query to create the required database tables on the server, and then uploading a single directory containing mostly PHP files, with a Javascript file, a css file and an HTML help file. I will be putting together a download package and instructions shortly, and will then need a volunteer to try it out. If you would be interested, please reply via this live demo. There are some things that I still need to change to make it fully customizable. For instance I see I have an image button that says 'BEV Login' - soon fixed I would think.

The demo has a help link that will tell you more about what the system does.

23/06/2012 - Bleats About Facebook Connect/OpenID/Oauth.

I just asked the following question on stackoverflow.com.

******
A user authenticates to my web page via Facebook. I get an access token that appears to cover posting to her wall. I can successfully do that. However the post is differentiated from something added to the wall by the user directly using the regular Facebook page.

A post of the latter kind appears in the user's news feed, and the news feeds of the user's friends. A post of the former kind does not appear in news feeds. Also it is qualified on the wall as having been written by my app, and there is an option to share it. It seems that it is regarded as something the app wrote, rather than something it wrote on behalf of the user. The user must share it to make it visible. This defeats the point of the action on my page. I want a user there to be able to decide that a post they have made on my page is one that they also want to make on Facebook, without having to visit both pages.

I set permission value:EVERYONE (and I've tried ALL_FRIENDS and PUBLIC).

Is there any way around this, like to get an access token that enables the app to post on behalf of the user, rather than with the permission of the user - after all the user is logged in at that point both to my page and to Facebook.
******

This is symptomatic of the ways that the big players have approached OpenID/OpenAuth. They want you not only to have their name in your face, but also to be logged on to their site as often as possible. But this creates many problems.

In a simple-minded view of OpenID, your web page or application should be able to ask "Is this user OK as far as you are concerned?". If the OpenID provider said "yes", then you'd allow them to use your page/app. The user's status vis-a-vis the provider's page/app should not be changed. But no, in the cases I've looked at - Facebook and Google - the latter is not so. In each of these cases, after you've asked and got the affirmative answer, the user is logged in to the provider's page/app. This has numerous tacky consequences.

Probably the worst is the case of a shared machine, maybe in an Internet cafe. User A uses the machine, and logs in to my page using Facebook Connect. As is often the case, user A neglects to log out. User B - who has never even heard of my page, but lives in the same community - then uses the machine and goes to the Facebook page, where she finds she is mysteriously logged in as user A, and can do all sorts of malicious things.

Of much less consequence, it leads to my problem. I knew about the login to the provider, and foolishly assumed that the short-lived access token that I would receive would allow my page to act on the user's behalf. I then spent a significant amount of time and effort trying to get something to work.

My other gripe is that at least in the Facebook case, the 'API' is not an API as I understand the term. In the latter, you make some call, and either it works, or you get, or are able to get, some sort of error message or number. In the Facebook case, it works when it feels like it, and you get no explanation as to why it failed when it doesn't work.

If it said "You've made too many erroneous, repeated and frequent calls lately, so you're banned for 72 hours!", then you could get by - work on something else for three days. But with no error information, you presume that you have screwed up, and waste hours trying to track down what's wrong in your code when in fact the code is fine.

Vent, vent ....... I'm sure I'm not the only one! If you have a view on this please hit the 'Discussion' link in the menu at the top of this page.

07/06/2012 - Very Simple CSS/Javascript Tooltips.

I had adopted some rather nifty pure CSS tooltips as described at blogohblog.com. Sadly I discovered that in Google's Chrome browser (I have 19.0.1084.46), these made a real mess, with the tooltip text all over the place and visible all the time. With other browsers it was fine, so I hope Chrome catches up soon. (It could of course have been something dumb I was doing.)

So I had to come up with a different way of displaying the same result that was OK in Chrome. I assumed this would be best done by mixing the CSS approach with some Javascript. I came up with something quite simple to use - more.

06/06/2012 - A pitfall in jQuery/Javascript closures.

In the course of fixing a broken menu system on one of my pages, when tired, I hit a problem that I chased around for ages. I got the page working again using an awful kludge. Today, in the cool light of dawn I thought about it again with my computer-science head on, worked out what had gone wrong, and wrote a test program to check out my conclusions in my head. When I got up I typed it in, and tested it. The kludge was then quickly removed.

I have reduced the thing to something pretty minimal in the hope that it may save some panic elsewhere.

For the example we will generate, on-the-fly, a page that simply shows a sequence of sister/brother words. When you click on the sister, the brother turns red. The problem was that whichever sister I clicked on, the same brother turned read ;=(

The Javascript is the important point, but I will use jQuery because it is convenient and widely understood. To illustrate how I got myself into the trap, we'll assume that the first pair of words are a special case (though in the example they are not.) - more.

31/05/2012 Getting Started with Facebook Connect login - PHP.

I considered using Facebook Connect PHP API to provide login capabilities for one of my pages recently, but as is often the case I was disappointed with both the documentation and the example provided.

The example is confusing because it does not address any particular use case, and it features user information and the profile picture of the owner of the associated Facebook App. The latter has little or nothing to to with the context.

It is also confusing because if you press its 'Logout' link, nothing much happens, and it is not clear how to get back to the login state so that, for instance, you can log in as someone else.

What I wanted was just an example that would allow you to log in, log out, and collect some minimal information about the user along the way - more.

01/01/2012 - Time For a Reset

There are two previous pages covering 2009 - 2010 and 2010 - 2011. But the files were getting cumbersome, so I've started a new selection for 2012.

If you can see this, you probably have JavaScript disabled, and BEV will not work as designed."

Squash This List

What is BEV?

Brits Eye View is an Englishman's personal blog, started in January 2003. It's currently about life in Arusha (Tanzania), and previously in Bangalore, Manhattan, and the Bronx. It deals with life in general, building a house, food and drink, computer programming, opinion on current affairs, 20th century history, and so on. It may give you some insight into what life is like in 'the third world', or encourage you to visit Tanzania.

There is also a retrospective view of the latter half of the 20th century, currently spanning 1942 - 1975 so far.

My wife and I run a small but very pleasant guest house in Arusha - Adia's Place - check it out!

To list the posts available on this blog, click the next list item to expand it.

Software Blog Postings List.

There are postings on two older pages,
2009 - 2010, and 2010 - 2011. Below is the current list:

Why a Software Page?

Well, I was involved with computer programming from the late 60s onward, spanning early FORTRAN to D.

I retired in 2007, but somehow I can't get out of the habit, and still get occasional flashes of "I wonder what would happen if?", or "How do they do that?", or libraries that don't work and I have to fix for myself.

DCat Summary.

For a long time I had this idea of writing a web application server in a compiled language that would be in the same general class to its language as TomCat is to Java. It's additional feature was that a web application, or set of applications would have the inter-page logic defined entirely in XML.

I tried it years ago in C++, using FastCGI, and got quite a long way, but nobody was interested. Then when I got into the D programming language, I thought I would have another go, this time with a D implementation of the AJP13 protocol between the web server and the application engine.

I got quite a long way with that too, but was stymied by the lack of capability of D to produce and dynamically load DLLs or shared libraries, or to dynamically load object files.

DCat has a set of associated D utility classes for things like logging, Windows event logging, property files, parsing XML, creating a Windows service, and so on.

You can read more about it here, see its (now somewhat outdated) changelog, or download a zip file for the Windows version.

Hits'n Stats Summary.

I used to use a third party hit counting service on the BEV pages, but it did not really do what I wanted. So I rolled my own

Hits'n Stats has less focus on hit counting, and more on discovering who your readers are, and presenting that information in a simple and convenient form.

It's written for the classic PHP/MySQL combination, so it's easy to install on most shared hosting systems.

You can read more about it here. Using the pages referenced here, you can sign yourself up to try out the system on your own site. If you want to use it, get in touch, I have not put together a distribution of it yet.

MySqlD.

This is the DDocs generated documentation for a set of classes in the D programming language that constitute a wrapper around the MySql C library.

You can get the source code and the other bits you need to build and set up MySqlD here.

Publicity Summary.

At the beginning of the 90s, the only Windows application that specialized in printing labels, business cards and such, was one called Avery Labelpro. I did not think that it was particularly good, so I tried to do better

A lot of people thought I succeeded, but I failed to sell enough copies to stay in business with it - didn't have the financing for advertising etc. So eventually it became freeware. It is definitely legacy software, and I don't support it any more, but is still quite good at what it does. You can read more about it here, view its user documentation, or download a setup executable.