John's Computer Journal

Wednesday, May 28, 2008

Ctrl - Alt - H to Show and Hide Hidden Files

Hidden files can quickly be shown and hidden again using the the following VBScript. The script has only been tested in Windows Vista, but should work in other versions of Windows.


Dim WSHShell, n, p, itemtype, MyBox
Set WSHShell = WScript.CreateObject("WScript.Shell")

p = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden"

itemtype = "REG_DWORD"

n = WSHShell.RegRead (p)
errnum = Err.Number

if errnum <> 1 then

WSHShell.RegWrite p, 2, itemtype
End If

If n = 2 Then ' currently hidden

down = 9

'   WshShell.RegWrite p, 1, itemtype

End If

If n = 1 Then ' currently shown

down = 8

'   WshShell.Regwrite p, 2, itemtype

End If

WshShell.Run "RunDll32.exe shell32.dll,Options_RunDLL 7"
WScript.Sleep 500

WshShell.SendKeys "{TAB}"

'8 to hide
'9 to show
For i=1 to down

WshShell.SendKeys "{DOWN}"


WshShell.SendKeys " {TAB}{TAB}{ENTER}"

Set WshShell = Nothing

After saving the VBScript, create a shortcut to the script someplace in your start menu. Right click the shortcut and assign the shortcut keys Ctrl - Alt - H.

Open up a folder and press Ctrl - Alt - H to show hidden files. Press Ctrl - Alt - H again to hide the files.

Simple Tomboy like Notes in Windows

Until Tomboy is properly ported to Windows, similar functionality can be achieved with tools already provided by windows.

  1. Open up your Documents folder and create a folder called Quick Notes.
  2. Create a shortcut to Notepad (or similar text editor application) in the Quick Notes folder.
  3. Right click the shortcut to Notepad and select Properties. Put the full path to the Quick Notes folder in the Start in: field.
  4. Right click on your task bar and go to Toolbars > New Toolbar ... and select the Quick Notes folder.
Voila! Quick and easy access to your notes.

Thursday, March 27, 2008

RIFE framework analysis

The RIFE framework is a fully featured web application framework.

  • Key Components: RIFE handles content management, database, meta data, templating, web, life-cycle management, external interfaces (like web services), and common services.
  • Request Routing: Requests are routed through RIFE's web engine. The web engine handles data and logic flow and ties together the components. The web engine is also features what it calls 'continuations' which are capable of ensuring idempotent and navagatable form submissions.
  • View Handling: RIFE has a template component that handles displaying dynamic web content. RIFE's template code does not include commands for anything more than presentation.
  • Model Handling: RIFE has support for several databases through JDBC and a content management system for handling binary files, e.g, images. RIFE can automatically initiate a database structure based plain old java objects, i.e, pojos and ensure they are used correctly via constraint meta data.


  • Robustness: The framework forces developers to develop a well structured application that is maintainable and easy to understand.
  • Scalability: RIFE should easily scale for high-volume data and traffic. The developers of RIFE have used it to build an IRC bot capable of tracking, recording, and displaying IRC channel conversations from multiple channels.

Framework Type

The RIFE application framework uses elements of both request-based and component-based models. The RIFE framework may be the current top hybrid framework that provides request-based control. A quick search on google for 'request based framework' returns RIFE as the first result.

  • Request-based usage: RIFE uses a request-based model to handle the entire data and logic flow. By handling the data and logic flow in a request-based method developers are able to have full control over URLs, forms, parameters, cookies and pathinfos. The request-based model is very close to the original CGI specification.
  • Component-based usage: RIFE uses a component-based approach to map actions and controllers to requests. The abstract, higher level approach provided by the component model allows consistent behavior among individual pages, forwarded pages, and integrable content, e.g., widgets and page fragments. Components can be easily distributed and re-used and embeded in other RIFE applications.

Ease of Use

  • Getting started: RIFE/Jumpstart contains source code for developers to quickly get started using RIFE. RIFE/Jumpstart supports many common development environments including Eclipse and NewBeans and comes with a Jetty servlet container and other components.
  • Learning Curve: RIFE requires certain declarations to be implemented in a handful of configuration files before an application can function correctly. RIFE's developers claim that the declarations increase productivity and reduce maintenance issues. Overall the learning curve isn't too difficult, but still uses slightly different terminology than other frameworks any may be difficult to quickly pick up and understand. Documentation, examples, and a user guide can all be found on RIFE's official website.
  • Support: RIFE's official website and wiki site provides a few good examples and tutorials of how to use RIFE. The examples and tutorials don't seem to be updated too frequently. Sources of public support outside of RIFE's official and affiliated sites are difficult to locate if they exist at all.


RIFE's official site lists a few high-traffic sites. However, none of the sites listed were familiar to me. A few blogs mention developers that have chosen to develop using the RIFE framework, but I couldn't find many in the 'wild' that use the framework.


RIFE provides all the tools needed to quickly develop and maintain a Java web application. The feature set is impressive and the ability to integrate with other frameworks, libraries, tools, and APIs allow RIFE to be a great base for application development.

The difficulty in finding websites that use RIFE and the few blog posts discussing RIFE lead me to believe RIFE is being overlooked by many web developers in favor of other frameworks. I was not able to indicate any particular drawback of using RIFE over another framework.

The last update to RIFE code was sometime last summer. It may be possible that the infrequent updates to supporting documentation and core RIFE code development are causing some developers to shy away from using the framework.

Monday, June 4, 2007

Dynamic Image Sizing (Zoom) for Firefox

The following javascript code will setup a HTML document so that in Firefox when the fontsize is increased or decreased, the images will increase or decrease in size as well. The code can be appended to the end of any HTML document you wish or possibly made into a Firefox extension.


After appending the following code to any HTML document use the Ctrl+Mouse Wheel, the View -> Text Size, Ctrl++, Ctrl+-, or Ctrl+0 menus and or accelerators in Firefox to zoom the page in or out. Internet Explorer and Opera already have the ability to zoom text and images and as far as I know are unaffected by the code.


The code does not resize images that are displayed as part of the CSS style.

Javascript Code

<!-- dynamic image sizing - set image size according to font size {{{
     Copyright (C) 2007 John Elkins


     This program is free software; you can redistribute it and/or modify it
     under the terms of the GNU General Public License as published by the
     Free Software Foundation; either version 2 of the License, or (at your
     option) any later version.

     This program is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     Public License for more details.

     You should have received a copy of the GNU General Public License along
     with this program; if not, write to the Free Software Foundation, Inc.,
     51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 

            Firefox web browser.  IE and Opera already have an image zoom


            Place the following code at the END of the document.  After all
            images have finished loading.

            Images defined by CSS styles are not resized

     Version 1
     4 June 2007
<style type="text/css">
    .em_test_hidden {
<script type="text/javascript">

// Create the test image
var element = document.createElement('img');
element.setAttribute("src", "");



// Use the test image to determine the pixels per em
var px_per_em = document.getElementById("em_test_element").height;

// Set all image heights to change relative to the em
var image = document.getElementsByTagName("img");
for (var i=0; i<image.length; i++) {

    var dynamic_em_height=image[i].height/px_per_em;
    var dynamic_em_width=image[i].width/px_per_em;

    image[i].style.height = dynamic_em_height+"em";
    image[i].style.width  = dynamic_em_width+"em";


// change the document so it also resizes accordingly = document.width/px_per_em+"em";

</script> <!--}}}-->

Monday, May 28, 2007

Summarize and TOC Blogger Widget

The following widget uses javascript to automatically summarize an article and provide a table of contents when not summarized. During summarization the widget will remove all HTML tags and display by default up to 255 characters or a new line (whichever comes first). When creating a table of contents the widget will search for header tags, add the appropriate anchors, and generate a table of contents with links to the headers in the article.


  • Blogger (Beta) Blog
  • Using the layouts templates
  • Javascript
  • Use H1 - H6 to denote section headings


By default the summarize widget will display up to 255 characters or a new line (whichever comes first). To adjust the amount of characters shown in the summary, change the summarize_length variable to the desired length. The summarize_length variable can be accessed through the widget settings screen.
Table of Contents (TOC)
The table of contents is displayed only if there are heading tags within the article. By default headings H1 - H3 are used by blogger to display the article title, date, and comments headings. So, I use H4 - H6 in articles to make things a little easier to read; however H1 - H3 could be use too depending on the style you want.

To change the way the table of contents is displayed edit the .tocH* CSS classes found within the widget settings.


The summarize and table of contents widget was built for use on John's Computer Journal. You can take a look around and see the widget doing its thing.
Check out a non-article page for an example of summarize in action. The index (main) and search pages will summarize all post content.
Table of Contents
Check out the top of this page for an example of the table of contents in action. The table of contents at the top of this page has been dynamically created by the widget's javascript code without having to be hardcoded into the page.



  • Since the summarize function removes HTML tags when summarizing, images and formatted text will not appear. To ensure an image shows up for a post when its summarized, use an img tag within the title of the post.
  • The summarize function will mess up google's beta translations.
  • There will be a delay until the page has completely loaded before the summarize or toc functions load and display the results. The delay can be fixed by ensuring the widget is placed after the posts and removing window.onload and just calling the functions directly.
  • The summarize function fails to engage when older posts are viewed through blogger's pagination.


Sunday, May 27, 2007

Blogger Widget Generator

If you have a blogger widget you would like to share. Fill in the forms below and click Generate! to build a web form that will allow others to easily add your widget to their own blog.

Widget Information

  • widget.title - (Optional) The title you specify will display in the user's Page Elements tab when they edit their layout. It will also be shown as part of the default widget template. The title can be up to 100 characters long, and may contain well-formed HTML.
  • infoURL - (Optional) You can use this to specify a page on your site that describes your widget or gives other information about it. It will be used as a "more info" link on the setup page people see when adding your widget.
  • logoURL - (Optional) You can add an image URL here, and the image will be displayed next to the "more info" link. It should be thumbnail sized (i.e. less than 100x100 pixels).

  • widget.content - (Required) This is the actual content of your widget, which will be displayed on the user's blog. It can include almost any well-formed code that you want, except for <html> and <body> tags. The widget generator will escape all >'s and <'s and encode scripts.

    Script encoding is a work around that will keep blogger from choking on scripts during form transfer. To disable script encoding, put a space before the script keyword in the script tag; for example: < script> will disable script encoding, <script> will enable script encoding

  • widget.template - (Optional) This should follow the widget tag guidelines. You can also use any of the globally available data tags. If no template is specified, it uses <data:title/> <data:content/> as a default. The template is also escaped and script encoded (see widget.content above).


Saturday, May 19, 2007

Batch function library loader

I've put together a few functions that I find useful when doing batch scripting. I've attached the library of functions bellow. Included in the library are functions for multi-line out, file-prepending, and unsetting environment variables.


call function :[function_name] [function_parameters]

[function_name]       - name of the function.
[function_parameters] - arguments to pass to the function.

Read the function documentation within the function.bat file for further information on variables specific to each function. Examples of each function included with the attached file are provided below.


call function :unset path temp tmp username

The above example executes the function unset with the parameters: path, temp, tmp, and username. After executing the unset function each of the environment variables path, temp, tmp, and username will no longer exist.

call function :prepend history 1st I did this
call function :prepend history 2nd I did this

The above example executes the function prepend twice with two parameters: history and a string. After executing the prepend function the file named history will have the line: "2nd I did this" (without the quotes) as the first line of the file and the line: "1st I did this" (without the quotes) as the second line of the file.

goto output

Hello %username%,
Do you know the ^%TIME^%?


call function :out %0 output  

The above example builds a multi-line output and executes the function out with two parameters: the current filename and the target output. Notice the % symbols are escaped for TIME to prevent out from expanding the %TIME% variable. After executing the out function the following will appear on the display:

Hello John,
Do you know the %TIME%? 

Note: the results of the out function can also be redirected to a file by appending the > operator.

Adding Functions

New functions can be added to the function library by adding a label and goto :EOF pair where the label is the name of the new function. For example the following code will add the hello function which will simply display Hello %1 where %1 is the first argument passed to hello.

    echo Hello %1
goto :EOF

After adding the above code to the function.bat file and typing:

call function :hello World!
call function :hello %username%!

will display:

Hello World!
Hello John!
A good collection of functions ready to be copied and pasted directly into the function file can be found at Ritchie Lawrence's Batch Function Library.