30 January 2009

Caching problem with MediaWiki Sidebar component

We've got an internal MediaWiki installed and are using it as our intranet. One issue we ran into: When we updated the wiki's sidebar, the changes weren't showing up. Why? Because the Sidebar is a PHP file all its own -- the wiki has caching capabilities and unless the page containing the sidebar was "touched" or changed, you wouldn't see the modifications to the sidebar.

One brute-force way to see the changes: Clear the browser cache and reload. A cleaner solution is to use this command while logged on as root:
touch localsettings.php

This page talks more about the MediaWiki file caching.

Collection of articles on emerging tech and education

Emerging tech provides a dizzying array of new ways to do some old tasks; here's an article on how it relates to education.

28 January 2009

Free vector resources

Find a huge collection of free vector resources on this blog post.

27 January 2009

Annoying bug in MS Word

I do a lot of documentation using Microsoft Word 2003, including dropping in screen captures with captions. Well, one annoying problem with Word is that captions can become incorrect if you add new images. This great article pointed to a simple solution: Do a Print Preview and return to the document; this updates all the cross-reference fields.

26 January 2009

Fix for fuzzy/distorted images in IE

On some Dell laptops, you may experience blurry images in Internet Explorer. This is caused by the automatic scaling in IE6+. The fix is to change the following registry key from 1 to 0:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\UseHR

Note that on some systems, you'll have to search the registry for the UseHR key.

23 January 2009

Create a zip archive in Java

Here's a Java class to zip up files in a directory. Thanks to the Java forum for their help in fixing some bugs.

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import java.io.File;

public class Zipper
{
private String _zipFilePath = "";
private String _imageFolderPath = "";
private String _zipFileName = "";
private static final int BUFFER = 20480;
private String _error = "";

public Zipper()
{
}

public void setZipFilePath(String path)
{
_zipFilePath = path;
}

public void setImageFolderPath(String path)
{
_imageFolderPath = path;
}

public String getError()
{
return _error;
}

public void zipEm()
{
File directory = new File(_imageFolderPath);

File files[] = directory.listFiles();

try {
BufferedInputStream origin = null;
FileOutputStream dest = new FileOutputStream(_zipFilePath);
ZipOutputStream zip = new ZipOutputStream(new BufferedOutputStream(dest));

byte data[] = new byte[BUFFER];

File f = null;
ZipEntry entry = null;
FileInputStream fi = null;
int count;

// Iterate over the file list and add them to the zip file.
for (int i=0; i <files.length; i++)
{
fi = new FileInputStream(files[i]);
origin = new BufferedInputStream(fi, BUFFER);
entry = new ZipEntry(files[i].getName());
zip.putNextEntry(entry);

while((count = origin.read(data,0,BUFFER)) != -1)
{
zip.write(data,0,count);
}
count = 0;
origin.close();
}
zip.close();
}
catch (Exception e)
{
// handle exception
_error = e.getMessage();
}
}
}

22 January 2009

Free SQL Server training

Here are some great videos for SQL Server developers.

20 January 2009

Flex explorers

This article lists a lot of great Flex explorers. More here.

Building cross-platform web apps for smartphones

CSS and JavaScript provide one of the best ways to build web apps that play nicely across platforms and devices. As this article explains, you don't need to get tied down with a proprietary language or SDK; just build HTML and use CSS/JavaScript to smoothly port apps over to any device.

15 January 2009

Powerful image editing in Java

The Java Advanced Imaging (JAI) API provides a very powerful way of manipulating images on the server. For a current app under development, we needed to receive an image file (JPG, PNG, or GIF) and resize it to a set width (letting the height adjust to maintain aspect ratio). JAI came to the rescue when the built-in image processing packages in Java were too slow.

The following code demonstrates the image resizing capabilities of JAI; for maximum image quality, we use the "SubsampleAverage". Thanks to this article.

BufferedImage resizedImage = null;

try {
SeekableStream stream = SeekableStream.wrapInputStream(is, true);
RenderedOp newImage = JAI.create("stream",stream);
((OpImage)newImage.getRendering()).setTileCache(null);

double scale = targetWidth / newImage.getWidth();

ParameterBlock pb = new ParameterBlock();
pb.addSource(newImage);
pb.add(scale);
pb.add(scale);

/*
* For best results, must use the following rendering hints.
*/
RenderingHints qualityHints =
new RenderingHints(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);

resizedImage = (JAI.create("SubsampleAverage",
pb,qualityHints)).getAsBufferedImage();
}
catch (Exception e)
{
this.error = e.getMessage();
}

14 January 2009

Free PS and EPS file viewing/printing

If you need to view and print PostScript and Encapsulated PostScript files, the GhostScript and GhostViewer combo can't be beat. Install GhostScript first; then install GhostViewer as the GUI front end.

09 January 2009

Extracting contents of *.jar file

A quick and painless method: Rename the file's extension to .zip and double-click it in Windows Explorer. We're using Java 1.4.2_12, which doesn't have the jar.exe built-in. Otherwise, if your path environment variable is set correctly, you can just type jar xf jar-file at the command line to extract contents.

08 January 2009

Better UI

Great article on building good UI.

05 January 2009

Powerful defrag tool

IObit.com offers a very powerful defrag tool for Windows.

Create Flex + AIR apps from the same codebase

This great article from Todd Prekaski details how you can create Flex and AIR apps from the same code. It includes some very neat techniques.

Update: The original article has disappeared but it's still available on the Web Archive here.