GNU coreutils funny

Just had a look at the basename man page and found this:
Written by FIXME unknown.
But they still claim to have the Copyright. Funny maybe the original author didn't approve with this.

Importance of dates

When browsing the web I don't want to look at old data, so when reading I try to find out when the page was last updated. Now blogging and wikis have become so popular there is normally a date associated with the post but otherwise you are normally left to guess based on version numbers of programs people used.
So if you are a web developer please never forget the date something was created.
Further I was looking for a tool which detects changes and dispays the last changed date. Google somtimes can display this but for about 80% of the pages this information is not available. Why has nobody written a tool that wgets pages and md5sums them to see it they have changed and displays this date. I know it is not always that easy, but a tool like that would be soo usefull. Maybe a firefox plugin could help.

A useful little bashrc addition

I really like checking if commands have executed successfully. This is something quite important if you are administering a machine. Normally I just echo $? but now I have added a new line to my .bashrc that will show me this in colour.

export PS1='\[\033[0;32m\]\u@\h \[\033[0;33m\]\w\[\033[${?/[^0]/31}m\]\$ \[\033[0;38m\]'

This will make the prompt green if everything went OK and red if the process didn't return 0. Nice little helper :)

CentOS help

Something people have asked me about is what to do when yum gives you the error
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
This is very simple

$ yum install yum-utils
$ /usr/sbin/yum-complete-transaction

Finished ;) Just a little cleanup of the completed transactions file

Howto reset your Windows Vista password

On my laptop I had forgotten my password because I always use the finger print reader. And I never really needed it because windows, once you are logged in, never really prompts you for it. But today I needed it and I didn't know it. So what do you do? Here are some simple steps.
  1. Create another user account with Admin rights
  2. Log in as that user
  3. Change your `real` user password
  4. Log in as your `real` user and delete the other account
Viola, password reset without knowing it. Thank you to Paul for this tip. Quite simple but I would have never thought about it.

detex for CentOS

So another little porting effort. This time it is detex
DeTeX is a filter program that removes the LaTeX (or TeX) control sequences from the input so that the real content can be passed to a spell or diction checker.
I am using this for my dissertation to count the words used
detex dissertation.tex | wc
Quite a useful little tool. When I get time I might rewrite it in perl to make it more portable.

Download the [RPM]

[SRPM] and spec file:

Summary: Strips Tex and LaTex commands from a file
Name: detex
Version: 2.8
Release: 1
License: BSD
Group: Applications/Text

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

Patch0: mallocandtroff.patch

BuildRequires: flex
BuildRequires: groff

DeTeX is a filter program that removes the LaTeX (or TeX)
control sequences from the input so that the real content can be
passed to a spell or diction checker

%patch -p0

%{__make} detex man-page prefix="%{_prefix}" CFLAGS="%{optflags} -DNO_MALLOC_DECL"

%{__rm} -rf %{buildroot}
#%{__make} install DESTDIR="%{buildroot}"
%{__install} -Dp -m0755 detex %{buildroot}%{_bindir}/detex
%{__install} -Dp -m0644 detex.1 %{buildroot}%{_mandir}/man1/detex.1

%{__rm} -rf %{buildroot}

%defattr(-, root, root, 0755)
%doc %{_mandir}/man1/detex.1*

* Tue Apr 21 2009 Hoffmann Geerd-Dietger - 2.8-1
- Initial package.

You will also need the little patch file
--- Makefile.orig 2009-04-21 01:50:44.735919044 +0100
+++ Makefile 2009-04-21 01:51:18.237692007 +0100
@@ -49,7 +49,7 @@
# Compile time flags, just uncomment the necessary lines
# Some say GNU make does not correctly handle += -- you may have to use :=
# Add -traditional for GNU cc on ISC 386/ix system and possibly others
# (reported by
@@ -116,7 +116,7 @@
mv detex.c lexout.c

- troff -man detex.1l
+ nroff -man detex.1l > detex.1

# If you want detex available as delatex, uncomment the last two lines of
# this target

My word was accepted

When talking about c (as in programming) you normally hear happyland for undefined memory. So I decided to submit one of my favorite terms to the urban dictionary.

Some people claim I came up with this term. Patent pending ;)

Using eval to use a string as comparison

I am just writing a little compiler and interpreter and I have a method to check if 2 values are equal, not equal greater and so on. My code looked something like this

if typeOfCompare == "==":
return firstVal == secondVal

elif typeOfCompare == "!=":
return firstVal != secondVal

elif typeOfCompare == "<=":
return firstVal <= secondVal

But this was quite inflexible and I didn't like all the returns. As the type of the comparison was already checked by the parser I came up with a simpler method
return eval(str(firstVal) + typeOfCompare  + str(secondVal))
This might be a performance hit and not as clear but its easier to code and more extensible. You got to love python enabling something like this using a string as comparison operator.

Some research into what other people have done

So I thought I might have a look at what other people on my course have done in previous years as a final year project and how they structured it. So I though quite a few people must have put their projects online as a pdf. So I wrote a little scrip that would query the online list and then Google search for the topic. Here is the script:
require "open-uri"
require 'rubygems'
require 'hpricot'

page = open("cit0708.html")
doc = Hpricot.parse(page)

(doc/"table.body_showcase").each do |link|
a = (link/"p")
puts "firefox \'\"" + a.first.inner_html + "\"\'"

And off I went to look at Google. But only one guy had put his dissertation online. Some people would conclude some stuff about Bournemouth uni students but I will restrain from this. But I still think the projects should be uploaded to somewhere. I know other Universities print books with all the projects in them so their students get publications.
On anther note: I really like the hpricot library, makes parsing HTML really easy. Even if you are not a big fan of ruby you might want to have a look at it.