Nothing to see here, move along please. This blog is only used to allow me to communicate between my tablets and my PCs.

Friday, November 16, 2007

OS2006 redux

Well, my experiences with OS2007HE were less than good so lets try Os2006 again.

First, flash from Windows using the Nokia wizard then, before enabling wifi, install fanoush's hot fix from the mmc card (Kingston). Power down and restart before enabling wifi.

Mike Saunby's x11vnc for Nokia 770 and N800 from: http://mike.saunby.googlepages.com/x11vncfornokia7702
This is a .deb file and does the actual install.

oss0-xterm-advanced:

For it2006 you can grab your copy with the application installer: Launch up application manager (tools/application manager). From the menu, choose tools/application catalogue and press new button, then fill in the following:

Web address http://maemo-hackers.org/apt
Distribution mistral
Components main

Then close the catalogs dialog and press ok to refresh the list of packages. Now you are ready to install, choose install new applications from the main view and osso-xterm should appear under Applications. If you already have a version of osso-xterm installed, use "check for updates" instead.

becomeroot:
Eko One then App Mgr install becomeroot. To use sudo gainroot.

osso-status-bar: should be able to just install from App Manager.

GPE File Manager: Cobb and install.

Leafpad: Maemo Garage (new gregale)

still to do: ssh access, Python

Tuesday, November 13, 2007

Using Google Docs to create Blogger Entries


The Blogger editor is not as rich as the Google Doc editor - it is OK for simple text but it restricts inserted images to reduced, low-resolution images that you have to click on to to see the original. I guess this is OK for photographs, but I want to include in-line screens-shots and diagrams in my Blog entries. Blogger also has problems rendering code fragments accurately.
I am using the Google Docs to edit Blogger entries and then publishing them to my Blog.

Screen-shots and Diagrams

You can store your images on another external web-server (e.g. Photobucket) and copy references back into a Blogger entry, but this adds extra steps into the work-flow.

Google Docs documents can have in-line images and their sizes and resolutions are not as severely restricted as they are in Blogger. For example, the following wide screen-shot renders faithfully:


Some of the Blogger templates truncate wide images, but others do not - I have not discovered the magic formula yet but the 'Simple II' template works OK.


Code Fragments

I was initially put off using Blogger because I have seen several Blogs where code fragments are shown that have all leading spaces removed. This makes the code hard to read, but for Python it also makes the code unusable because leading spaces are syntactically significant and it is not always possible to re-construct the original code by simply inserting new spaces. For example, the following:
function goodbyeornot(){
if (confirm("Do you want to exit?"))
{
alert("Thanks for Visiting!");
}
else
{
location.reload();
}
}
renders as:

function goodbyeornot(){
if (confirm("Do you want to exit?"))
{
alert("Thanks for Visiting!");
}
else
{
location.reload();
}
}

in Blogger.

This turned out to be a common complaint about Blogger and the only way around it is to edit the code in the HTML editor. A kind soul has made available a simple tool to format source code for inclusion in Blogger entries: formatmysourcecode.

However, if you want to use Google Docs to create and edit Blogger entries then, unless your are prepared to re-create the source code segments every time that you update your entry, then formatmysourcecode cannot help you.

Google Docs does allow you to type in/paste source code fragments into a document and they will retain leading spaces correctly. Fine. Unhappily, when you publish your document to Blogger the spaces get nuked. Grrrr....

The solution is to enclose your code fragments inside some html tags in Google Docs HTML editor. You need:

<blockquote><pre>
Your code here...
</pre><blockquote>
<HTML>
<TITLE>OnUnLoad example</TITLE>
<HEAD>
<SCRIPT LANGUGE="JavaScript">
function goodbyeornot(){
if (confirm("Do you want to exit?"))
{
alert("Thanks for Visiting!");
}
else
{
location.reload();
// I also tried: location = "trap2.html";
}
}
</SCRIPT>
</HEAD>
<BODY onUnLoad="goodbyeornot()">
<H3>Example of onUnload event handler</H3>
Look what happens when you try to leave this page...
</BODY>
</HTML>
I find that inserting the above three lines using the HTML editor and then switching to the GUI editor to actually enter/past the code works best - especially if you want to show some html code.


<HTML>
<TITLE>OnUnLoad example</TITLE>
<HEAD>
<SCRIPT LANGUGE="JavaScript">
function goodbyeornot(){
if (confirm("Do you want to exit?"))
{
alert("Thanks for Visiting!");
}
else
{
location.reload();
// I also tried: location = "trap2.html";
}
}
</SCRIPT>
</HEAD>
<BODY onUnLoad="goodbyeornot()">
<H3>Example of onUnload event handler</H3>
Look what happens when you try to leave this page...
</BODY>
</HTML>
This is test 2
function goodbyeornot(){
if (confirm("Do you want to exit?"))
{
alert("Thanks for Visiting!");
}
else
{
location.reload();
}
}

End pf Test 2

function goodbyeornot(){
if (confirm("Do you want to exit?"))
{
alert("Thanks for Visiting!");
}
else
{
location.reload();
}
}

Monday, November 12, 2007


WebDesk

(provisional title)

Introduction

blah-blah

Tasks (in no particular order)

1. 'Deskify' Karrigell


The idea is to be able to run a web application just like running a Windows application. A 'deskified' Karrigell application should start from a Windows shortcut and it should shut down just like a windows application when it exits or is closed from within the browser.

Write a wrapper for Karrigell that starts a Karrigell server and then opens a web-page in the default browser that loads a specified page from the just started server. The wrapper also needs to specify a dedicated port number (not 80) for use by the server. All pages loaded will have to use that port number.

The wrapper is also responsible for terminating the Karrigell server when it receives notification from the web application that it is shutting down.

The lifetime of the Karrigell server is the lifetime of underlying application. Multiple applications can be run, but each will have their own dedicated Karrigell server - think of Karrigell as part of the application's run-time rather than as a traditional web server.

2. Termination trap


Write some JavaScript that can intercept an attempt by the user to close a page's tab or the browser displaying the page.





Ans: This is html. There is an event handler "onunload" containing JavaScript as an attribute in the <body> tag.

Put this in a file called trap1.html, then open it with a browser:

<html>
<head>
<title>
The lone arranger
</title>
</head>
<body onUnLoad="alert('this is a wrap!')">
This is a wrap.
</body>
</html>

Display a dialog box that asks the user if they really want to close this page or to continue.

We can intercept the unload event, but we cannot seem to stop it happening. There must be some way of doing this...
We can call more JavaScript to save things etc. and perhaps open a new browser tab/window with the old page
Ans: save this as trap2.html

<HTML>
<TITLE>OnUnLoad example</TITLE>
<HEAD>
<SCRIPT LANGUGE="JavaScript">
function goodbyeornot(){
if (confirm("Do you want to exit?"))
{
alert("Thanks for Visiting!");
}
else
{
location.reload();
// I also tried: location = "trap2.html";
}
}
</SCRIPT>
</HEAD>
<BODY onUnLoad="goodbyeornot()">
<H3>Example of onUnload event handler</H3>
Look what happens when you try to leave this page...
</BODY>
</HTML>




Redo the same code in GWT Java. This probably means wrapping up the JavaScript from above into a Java package that probably uses JSNI.

The termination trap is used to prevent inadvertent loss of application data should the user close a tab or a browser instance without saving changes and exiting the application. It might be more interesting to use the idea of saving the application state periodically so that re-opening a browser on that application can recover the application state exactly as it was when the browser was closed.

Google Docs and Spreadsheets seems to do both: if you try to close a tab that contains an unsaved document then you get the warning pop-up, but if the document has been saved or auto-saved then it lets you go ahead silently. The back button also works to restore the tab to its former state. So does the re-open closed tab in Firefox. Pretty nice.

3. Sample GWT application

Write a simple GWT 'applet' and 'servlet' that:

  • Displays a form that requests a 'name' from the user, sends that name to the servlet packaged up initially in a GWT RPC call.
  • The servlet responds with telephone number for that name, or xxx-xxx-xxxx if the name is unknown. Only a couple of names are required.
  • Intercepts any attempt to shutdown the applet by closing the browser window/tab with an 'are you sure?' dialog box. If confirmed then the applet makes an RPC call to the servlet and tells the servlet that the applet has shutdown. The servlet logs this event to the console.

Once this is running OK, then the applet needs to be changed to use XMLHTTPRequest and JSON instead of the standard GWT RPC protocol. Build a version of the servlet that responds to these requests instead of the RPC calls.

JSON is the 'payload' protocol discussed in the above link. You will need to find a JSON decoder (parser) for Java - which should not be too difficult.

I will probably want to use JSON-RPC in Python so take a look at this and see if you can get this going in Java.


4. Sample Python Servlet

Recreate the Java servlet from 3. using Python running under Karrigel.

Setting up MoinMoin as a Server under Windows

N. B. not Desktop MoinMoin

There is a general introduction to installing MoinMoin here: HelpOnInstalling. Scan this document but don't worry about it too much. We are going to install the Personal Wiki - StandaloneServer.

The standalone server is especially made for local wikis because it does not need a web server installed. Only Python and Moin are necessary!

To install and run the standalone server:

  1. If MoinMoin is not installed yet, perform ../BasicInstallationForWindows

  2. Create a wiki instance as described in ../WikiInstanceCreationForWindows

  3. Copy moin.py to your wiki directory, where your wikiconfig.py is (I copied C:\Python25\share\moin\server\moin.py to D:\MoinWikiLocation\SueDon)

  4. Edit D:\MoinWikiLocation\SueDon\moin.py. I made the following changes:

    # Path of the directory where wikiconfig.py is located.
    # YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP.
    sys.path.insert(0, 'D:\MoinWikiLocation\SueDon')
    •     # Path to moin shared files (default '/usr/share/moin/wiki/htdocs')
      # If you installed with --prefix=PREFIX, use 'PREFIX/share/moin/wiki/htdocs'
      docs = 'C:\Python25\share\moin\htdocs'
        # Port (default 8000)
    # To serve privileged port under 1024 you will have to run as root.
    port = 8000
    # Interface (default 'localhost')
    # The default will listen only to localhost.
    # '' will listen to any interface
    interface = ''
  5. Run moin.py from D:\MoinWikiLocation\SueDon

  6. Access your wiki at http://localhost:8000/

You will have to edit D:\MoinWikiLocation\SueDon\wikiconfig.py to make other tweaks as you need.

Running MoinMoin as a Windows Service

Download and install the Windows Server 2003 Resource Kit. You need to use two utilities (InstSrv.exe and SrvAny.exe) from the Windows Server 2003 Resource Kit (this kit applies to XP too, 2003 Server is a newer version of XP). If you do not have these programs then you can download and install the Window 2003 Resource Kit from: http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

Installation instructions are near the bottom of the page at this link.

The idea is to use InstSrv.exe to install SrvAny.exe as a service with a name of your choice, e.g. "moinmoin" and then to configure the moinmoin service to actually start the moin.py program from SrvAny.exe.]

You might need to read the Windows Resource Kit Help file entries for InstSrv.exe and SrvAny.exe if things go wobbly later on.

Install SrvAny.exe as the 'moinmoin' service

(Sorry about the trailing " being chopped off in the picture.)

Set up the login authorization for the moinmoin service.

Settings->Control Panel->Administrative Tools->Services->moinmoin->Log On->This account

Enter your account info and click OK.

Edit the Registry entry for the moinmoin service.

We need to set up the moinmoin service so that it's executable SrvAny.exe invokes Python.exe with moin.py as a parameter.

First go into Regedit and export a backup copy of your registry - just in case ...

Now go to HKEY_LOCAL_MACHINE->SYSTEM->Current Control Set->Services->moinmoin and edit its entry to look like this:

The following are Parameters to SrvAny.exe:

  • AppDirectory is the working directory

  • Application is the actual .exe file that will be called by SrvAny

  • AppParameters are the parameters (the moin.py file) passed to the `Application' (i.e. Python.exe)

Start the moinmoin service.

Settings->Control Panel->Administrative Tools->Services->moinmoin->Start

If it starts and runs then it will start automatically from now on.