"Old" Correct Files Should Never Be Future Bugs

There's nothing like a non-error intentionally programmed to be an error to cause a halt of one's work. 🙁 The non-error causing an error is from a well-intended(?) check in LaTeX:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! You are attempting to make a LaTeX format from a source file
! That is more than five years old.
!
! If you enter <return> to scroll past this message then the format
! will be built, but please consider obtaining newer source files
! before continuing to build LaTeX.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! LaTeX source files more than 5 years old!.

which causes LaTeX to fail (e.g., on Gentoo, Debian, and other systems). While no doubt this "feature" was intended to have people update their systems, it also causes other otherwise working systems to fail just because of a calendar date. There is nothing wrong with running old stuff especially if one is using old files! Moreover a working system configuration must remain so. Errors shouldn't arise simply because of a date check that otherwise is not an error –errors should be detected because there are real functionality issues!

Should you run into this, the easiest quick fix to be back up-and-running is to edit:

/usr/share/texmf-dist/tex/latex/base/latex.ltx

so that the if statement in the file (it is near the end):

\ifnum\count@>65
  \typeout{^^J%
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
!  You are attempting to make a LaTeX format from a source file^^J%

is changed to be more than 65 months, e.g., edit 65 to be a much larger number (e.g., "\ifnum\count@>10065").

Printing: Duplex & Margins

If you are using KDE4, you may discover that a number of applications that use GTK/GNOME (e.g., Firefox and Thunderbird) to print, their Print…|Page Setup screens will not let you select any Two-Sided options. Since there is no nice global KDE4 printer configuration tool yet, the fix is to:

  1. Access CUPS using a web browser via http://localhost:631/.
  2. Click on the Printers tab.
  3. For the desired printer, select Set Printer Options.
  4. Change the Duplexer Installed setting from Not Installed to Installed.
  5. Click Set Printer Options.

Also, if you are using HPLIP and are having issues with the print margins, then this may help:

  1. Upgrade to the latest stable CUPS, if you haven't already done so.
  2. Upgrade to the latest stable HPLIP, if you haven't already done so.
  3. Run the hp-toolbox tool.
  4. Delete all of the relevant HP printers.
    • This will delete all settings and PPD files for those printers.
  5. Recreate all of your HP printers.
    • This will recreate all default printer settings, PPD files, etc.

I recently encountered this issue on a computer which was only resolved by (i) ensuring the latest stable releases of CUPS and HPLIP were installed and then (ii) deleting all HP printers and recreating them. With hp-toolbox, deleting and recreating all HP printers is quick and easy: simply use the round "-" (to delete) and "+" (to create) buttons.

NOTE: If you do this for an HP printer supporting duplex printing, remember to follow the directions given earlier to set the Duplexer Installed setting to Installed! 🙂

Finally, avoid using "testing" or "unstable" versions of CUPS or HPLIP unless you have a newly released printer that was unsupported, or, there is a critical bug fix for your printer that must be fixed.

Zotero: A Great Research Tool

What Is Zotero?

If you're doing research for a high school project, a degree/diploma (especially thesis-related work), for journalistic purposes, etc., an excellent must-have and must-use tool is Zotero. Zotero is a Firefox Add-On helps you easily collect and organize on-line information you need to capture and remember details about (including the ability to properly cite it later) . Briefly, Zotero:

  • enables one to capture a web page as it looks at a certain point in time,
  • it allows one to highlight and annotate any captured (web) page,
  • it allows one to search any captured pages (web pages, PDFs with additional software installed, etc.),
  • it remembers all reference information (e.g., time & date of capture, URL, etc.),
  • it has the ability to capture information from Google Scholar and scholarly journal web sites complete with full bibliographical information,
  • it can copy-and-paste bibliographical information (in nearly any style: APA, Chicago, etc.), and,
  • it integrates with Microsoft Word and OpenOffice allowing one to drag-and-drop references.

Using Zotero

Some of the more commonly used features in Zotero that I like and use are:

  • The "My Library" View (first third of Zotero window):
    • the ability to create a directory structure, and,
    • the ability to drag-and-drop folders to new locations.
  • In the middle third of the Zotero screen:
    • In the green, circular "+" pull-down menu:
      • Store Copy of File…
    • Via the right-click menu for a stored item:
      • Add Attachment…
        • Attached Stored Copy of File…
      • Remove Selected Item
      • Delete Selected Item from Library
      • Create Bibliography from Selected Item
      • Retrieve Metadata for PDF
    • Advanced Search (via the Magnifying Glass icon)
  • In the far-right third of the Zotero screen…
    • The "Info", "Notes", "Tags", and "Related" tags are simply wonderful to tag items, etc. Such information can subsequently be used with searches etc.

Zotero is easy-to-use and documentation exists on the Zotero web site so I won't re-create that here. Instead, I will give some highlights of my experience using Zotero.

Attached Stored Copy of File

One of the nicest things that Zotero can do is attached other files to an entry you make or previously captured. For example, when performing surveys of the literature, you will often capture bibliographic reference information from scholarly journals and Google Scholar. Sometimes PDFs of the papers are automatically captured, but, usually they are not. Often however, such paper PDF files are available (e.g., via your university's web site proxies) for free –but you'll have to download the papers manually. Nicely, you'll want to associate the downloaded PDF with the captured bibliographical information. To do this, simply right-click on the captured bibliographical entry (in the middle section) and choose "Attached Stored Copy of File…", select the downloaded file, and Zotero will store a copy of that file in that entry.

Retrieve Metadata For PDF

This is a fantastic feature! Suppose you have a paper's PDF file but don't have the bibliographical information associated with it. Attach a stored copy of it into Zotero, right-click it, and choose "Retrieve Metadata for PDF". Zotero will then extract the full bibliographical data for nearly all PDFs for scholarly journals and conference proceedings papers. This is simply a must-have tool when you don't have the rest of the citation information.

NOTE: In cases where this did not work, I simply searched Google Scholar for an exact of the PDF's title. Once found, then I clicked the folder icon in the address bar to add the reference to Zotero. While this seems like more work, it often is much faster than typing it in yourself.

Removing & Deleting Items

Users should take care when using these features:

  • Remove Selected Item
  • Delete Selected Item from Library

Remove will delete the currently selected item instance ONLY. So, if you dragged-and-dropped that item elsewhere (e.g., you can do this with the "My Library" folders), then those items are NOT deleted –only the selected one is. This is the safest method of deleting an item. So, if in doubt, always use "Remove Selected Item" to delete something instead of "Deleted Selected Item from Library".

The "Delete Selected Item from Library" will delete all references to that item in the library even copies made of that item via drag-and-drop to other folders in the "My Library" section. Only use this feature if you are sure you want all references to that item removed from the entire library –regardless of where they are located.

It should be mentioned that if you capture two copies of a page independently and you use "Delete Selected Item from Library" then only those items copied from the one being deleted are destroyed. Independent captures of the same page will not be deleted. While this sounds confusing, you can do a small test to show how all of this removing and deleting works:

  • Create a "Test 1" folder in the "My Library" section.
  • Select the "Test 1" folder.
    • This must be done so Zotero knows where to save any captured pages.
  • Navigate to a web page (e.g., http://www.slashdot.org/).
  • Capture it using the cyan page icon in Zotero.
  • Create a "Test 2" folder in the "My Library" section.
  • Create a "Test 3" folder in the "My Library" section.
  • Click on the "Test 1" folder in the "My Library" section.
  • Click on and then drag-and-drop the Slashdot captured page to the "Test 2" folder. Do the same again but to the "Test 3" folder.
    • Notice that this does not move the captured page –but appears to make a copy of it.
    • This copy is by-reference. Which means if you use "Delete Selected Item from Library" then ALL by-reference copies are also deleted (and any annotations, etc. with such). Try it!
    • If you instead use the cyan page icon to make multiple independent captures, then those will still remain after a "Delete Selected Item from Library" –it is only those that were copied by-reference that are deleted. Again try it –before you use it for something critical!
  • When done trying the above out, delete the items you captured (from Library) and remove the library folders created.

Create Bibliography from Selected Item

At some point you want to get the information out of Zotero and into a real document/paper you are working on. Even if you don't have Microsoft Word or OpenOffice integration configured, you can easily put any selected reference into a paper, web page, etc. using Zotero. Simply right-click on the entry (in the middle third of the Zotero screen) and choose "Create Bibliography from Selected Item", choose the Citation Style (e.g., APA), and I find that "Copy to Clipboard" is the most useful since you only will need to paste the reference into your document.

NOTE: If you have Microsoft Word or OpenOffice integration, then there are more features including auto-updating the bibliographical information using Zotero.

Closing Comments

If you are doing any type of research using on-line resources, Zotero makes it very easy to track and maintain lots of references while allowing you to organize and search the referenced content. Truly, using Zotero to conduct on-line research is much easier than doing the same by hand!

Using CMake to Build C++ Boost Python Libraries

Overview

The Boost Project has a Python library that makes it easy to seamlessly integrate C++ and Python code. Unfortunately, the documentation recommends using bjam. If you build Boost from source, then this is largely a non-issue. If, however, you are using Boost from preinstalled binaries or from a Gentoo ebuild, then you don't want to use bjam at all!

CMake is an excellent, cross-platform build system tool (e.g., like make but much better). CMake has the ability to determine platform-specific options required to build code. This saves one from having to specify each and every compiler, linker, etc. option including specific system paths, etc. In short, CMake makes is a lot easier to compile and run programs from source.

This post details how to build a minimal C++ library with its code compiled as a module capable of being loaded by Python (version 2.6 or higher) using CMake (version 2.8) and Boost (version 1.45.0). The text below assumes:

  • you are using a BASH shell on a Linux / Unix system,
  • you are using GCC's g++,
  • you already have CMake installed,
  • you already have Boost installed, and,
  • you already have Python installed.

Steps

Step 1: Create Your Development Directory & Set Your PATH

You'll want to create a new directory (e.g., "src") with a "build" subdirectory in it:

$ mkdir -p src/build

and change your current working directory to the new directory:

$ cd src

In order to run the Python code later, also ensure that "." appears in your PATH environment variable:

$ PATH=.:$PATH
$ export PATH

This will permit Python to load the module that is built. You may want to add these two lines to your ~/.bashrc script to avoid having to always set this in any new shells.

Step 2: Create CMakeLists.txt

Now, you can write the file that CMake will use to build the C++ code into a Python module. This module will be compiled as a Shared Object Library file (i.e., a .so file).

NOTE: In Windows, shared objects are Dynamically Linked Libraries (DLLs). Please note that under Linux / Unix, libraries are typically named with a "lib" prefix and a ".so" suffix. Under Windows, libraries simply have a ".dll" suffix. The instructions below are for Linux / Unix and so the "yay" library that is built will be called "libyay.so", whereas, under Windows it would be called "yay.dll". Thus, if you are using Windows, you may have to make some minor adjustments to the files below.

Your CMakeLists.txt file should contain:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
IF(NOT CMAKE_BUILD_TYPE)
  SET(CMAKE_BUILD_TYPE "DEBUG")
  #SET(CMAKE_BUILD_TYPE "RELEASE")
  #SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO")
  #SET(CMAKE_BUILD_TYPE "MINSIZEREL")
ENDIF()

FIND_PACKAGE(Boost 1.45.0)
IF(Boost_FOUND)
  INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}" "/usr/include/python2.6")
  SET(Boost_USE_STATIC_LIBS OFF)
  SET(Boost_USE_MULTITHREADED ON)
  SET(Boost_USE_STATIC_RUNTIME OFF)
  FIND_PACKAGE(Boost 1.45.0 COMPONENTS python)

  ADD_LIBRARY(yay SHARED yay.cxx)
  TARGET_LINK_LIBRARIES(yay ${Boost_LIBRARIES})
ELSEIF(NOT Boost_FOUND)
  MESSAGE(FATAL_ERROR "Unable to find correct Boost version. Did you set BOOST_ROOT?")
ENDIF()

IF(CMAKE_COMPILER_IS_GNUCXX)
  ADD_DEFINITIONS("-Wall")
ELSE()
  MESSAGE(FATAL_ERROR "CMakeLists.txt has not been tested/written for your compiler.")
ENDIF()

Notice that the output will be a shared library file called "yay". It is important to specify both the Boost include path as well as the Python include path with INCLUDE_DIRECTORIES in order for the code to compile properly.

Step 3: Create yay.cxx

Now create yay.cxx:

#include <boost/python.hpp>

char const* yay()
{
  return "Yay!";
}

BOOST_PYTHON_MODULE(libyay)
{
  using namespace boost::python;
  def("yay", yay);
}

It is very important that "libyay" in BOOST_PYTHON_MODULE(libyay) matches the name of the library you're generating in CMakeLists.txt (without the extension).

NOTE: On Linux / Unix systems you will need to prefix the name with "lib" as CMake defaults to prepending the file with "lib" as per convention on Linux / Unix systems.

Essentially, the BOOST_PYTHON_MODULE clause exports the "yay" function as the Python symbol name "yay". This will allow you to call the "yay" function from Python later.

Step 4: Build The Python Module

The best way to invoke CMake is to invoke it in a special build directory. This is why Step 1 mentioned to create a build directory as well. Before you can make the library, you need to have cmake generate the neccessary files to perform the build:

$ cd build
$ cmake ..

(You only need to run "cmake .." after changes are made to CMakeLists.txt.) Now, you can build the program by running make:

$ make

If all went well, you will see a libyay.so file in the current directory! If you need to clean up files, then run "make clean". If the build directory is a complete mess and you want to start over, then remove all of its contents, run "cmake ..", and then "make".

Step 5: Create A Python Script To Call yay()

Now you can test your efforts by writing the following python script:

#!/usr/bin/python
import libyay
print libyay.yay()

When you run it, it should output "Yay" (assuming the library file is somewhere in PATH, or, in the standard location for your system's Python libraries).

Step 6: Have Fun!

That's it! More information on how to export more symbols and call functions (either way) is available in the Boost Python library documentation.

Upgrading from Moodle 1.9 to 2.0

As is now apparent on the eTeach page (accessible via the menu bar above), I have installed a new eTeach web site running Moodle 2.0. Moodle 2.0 has a number of new and cool features which I look forward to using (some now and others later).

I have found Moodle's installation is one of the nicest open source web application-based installations as long as I have been using it (i.e., since approximately version 1.6) and now one can also install it via the command line too! Unfortunately, upgrading from the latest 1.9 release to version 2.0 was not as smooth as past upgrades. The main issues I experienced involved the database upgrade which were a series of table transformations. The most common issue I experienced was the NOT NULL constraint being added to columns. Those were easy fixes: I was able to add reasonable data to the NULL fields violating such or I could safely remove the record. Where I ran into a brick wall concerning the Wiki tables: there were apparently illegal UTF-8 characters. I tried all sorts of things including dumping the database, running iconv on it, and restoring it. Nothing worked.

Having spent too much time trying to fix the wiki tables, I decided to make the old eTeach site URI map to "eteach1" and install Moodle 2.0 as a new install to "eteach2". If there is anything that I need from the old one, I can copy-and-paste, or, backup and then restore the course. This is much simpler, practical and far less time-consuming! The installation of Moodle 2.0 as a new install was flawless except for one issue: $CFG->dbfamily was not in the config.php file and had to be manually added for the cron.php script to fully work.

I suspect the problems I experienced migrating from 1.9 to 2.0 were due to past database upgrades. Originally, the database was not UTF-8 and bugs/errors may have given rise to the NULL entries in records. This is not surprising since I've being using this copy since version 1.6.

Why upgrade? The features in Moodle 2.0 far outweigh what is version 1.9, especially with the improved wiki and the ability to make activities dependent. I look forward to using it and should you be in one of my courses, I hope you enjoy using it! If so and you have ideas/suggestions, feel free to do so!

OSSTF Tools and Toys Conference Presentations

On October 28th and 29th, I gave two presentations at the OSSTF Tools and Toys: Technology in Education conference held in Toronto, Ontario. The first presentation I made (on Workshop Session B, Oct. 28th) was:

Understanding Internet Identity, Safety, and Privacy Issues Workshop
The Internet is a wonderful medium enabling students, teachers, and society to interact with one another around the world in real-time. However, there are real dangers that the Internet poses for everyone, especially for teachers using such within his/her lessons plans. This Workshop is designed to inform teachers, using non-technical language, what a number of these dangers are, how they operate, and what can be done to avoid these issues in order to keep such exercises safe.

In this presentation I explained the well-known issues, but, I also focused a lot of attention concerning these two issues: (i) the perils of blocking content and the fact that many students (and some teachers!) use proxies and/or tunnels to bypass such; and (ii) how to determine whether or not a teacher should use Internet web sites (versus controlled-for-education web sites, e.g., school-board-hosted sites). Despite the details in the talk being necessarily somewhat heavy, the talk was very well-received and understood.

The second presentation I made was (Workshop D, Oct. 29th):

Augmenting the Classroom Experience Outside the Classroom With E-Learning Workshop
As a teacher, there are times when one would like to have the ability to do something available outside the classroom for students and possibly their parents, e.g., schools where students cannot stay after school due to catching a bus. This presentation will show how this can be done incrementally using a Learning Management System (LMS) called Moodle.

During this talk networking (e.g., servers running on my laptop) and Internet issues prevented me from demonstrating the things I was presenting. (Networking connectivity in the presentation areas was an issue at the conference. Unfortunately, my own laptop configuration with servers, etc. had an issue which prevented me from demonstrating it without a network.)

Should you wish, feel free to contact me concerning either of the above presentations.

Technical Support

If you've ever wondered the kinds of experiences computer science/engineering/IT people can experience when they contact their ISP's Technical Support line, then look at this xkcd comic. A typical call means going through a checklist of items, which is expected and understood. When the problem is explained in detail, often one is asked to go through the checklist again and again instead of forwarding the problem to a higher level capable of diagnosing and fixing the problem. This occurs because, in all likelihood, the Level 1 Technical Support person one is speaking with has no or an insufficient IT background to understand the relevance of the described symptoms and the problem. (To be fair, not all ISPs are guilty of this.)

Office Printer Versus Photo Printer Prints

I had the opportunity to examine the differences between two excellent printers: an HP OfficeJet 8500 Wireless and an HP Photosmart C8180. Both are All-In-One InkJet printers made by Hewlett-Packard. The OfficeJet is a printer, scanner, copier, and fax machine with a number of features and the Photosmart is a printer, scanner, and copier machine.

I was curious as to how much of a difference there would be between the 4-colour OfficeJet printer and the six-colour Photosmart printer using the high-end 8.5"x11" HP Premuim Plus High-Gloss photo paper. The test picture I used was a high-resolution version of this picture of a wasp and an ant on a trumpet vine that my Dad took a couple of days ago:

Wasp and ant on a trumpet vine.To avoid any issues with computer printer drivers, I placed the picture on a USB memory stick, inserted it directly into both printers, and used each printer's touchscreen to output the 8.5"x11" borderless print.

The results were very interesting. Both printers outputted correct, excellent colours with at their respective highest resolutions. However, as I predicted, the 4-colour print lacked the depth and vibrancy of the six-colour print. While many would not notice too of a difference, the difference is dramatically best described as the 6-colour print looks real (i.e., its appearance is best described as fantastic) and the 4-colour print is best described as a very good print. Put another way, the 4-colour version looks flat –almost matte, even though it is on glossy paper.

After seeing the 4-colour glossy print looking almost matte, I was curious to see how it would look on matte paper. So, I printed it again on HP Premium Plus matte paper to compare. The 4-colour matte print looked completely matte (as expected) as compared to the glossy print (which was only about 50% glossy). As a result, the 4-colour matte print looked better than the 4-colour glossy print since the latter was only partially glossy in appearance. On the other hand, the 6-colour Photosmart printer's glossy print was beautifully 100% glossy and its matte print was completely matte (both as expected).

While not surprising, the Photosmart printer is the device of choice to output photographs, but, it was nice to see the differences between a standard, office-style printer and a photo printer. Certainly, for lesser pictures or if one could not afford to get an office and a photo printer, one would enjoy prints from the office printer. That said, for pictures that look real, have vibrant colours, and are worthy of framing, the photo printer with high quality photo paper is a must-have to output digital photographs.

KDE4 and Music Streams…

When running the KDE (version 4) windowing system, I've been looking for a nice plasmoid widget that does one thing very well: play music streams while being compact and very easy to use. I have found one: SimpleStream. SimpleStream is v0.2 and it is either a play or stop icon. It is best to place it in the Task Manager bar. Right-clicking allows one to choose a stream or enter the configuration dialog to add/remove streams. The only issue I had when I installed it was that I had to install the

python-qt4-phonon

was installed.

SimpleStream is just perfect when one wishes to listen to a music stream and does not want to control anything other than stopping/starting the stream. This is ideal for SqueezeBox server server software (which can stream audio to computers as well as the SqueezeBox hardware Logitech sells) as well as Internet streams.

Frankly, when one wants more than SimpleStream in KDE, one can simply stop the stream from playing and run Amarok or some other music playing program. Also, Amarok and other programs consume more resources and can be screen-space bulky.

Welcome!

I've had a wonderful Canada Day and I hope you did too (even if you're not Canadian)!! 🙂

Now that the wonderful WordPress blogging software is getting to be very nice, I thought the time is right to start my own blog. The primary purpose of my blog will be to write about various thoughts and perspectives that actively or passively come to mind from time-to-time. I will also write about topics involving things such as computers, technology, ethics, science, teaching and/or education from time-to-time as well.