08:02 Fri, 17 Feb 2012
Vim has support for a built-in thesaurus. However, it consumes a
lot of memory, which you may not want for a feature you do not use much, and its
auto-complete selection has issues. Here is how to set up an on-line thesaurus query that is light weight.
Summary
This is the first post of two about a light weight way to implement a thesaurus. It is
great for what I need, which is the occasional use of a thesaurus for writing text such
as this article. Once it is set up, you can forget about it and just use K
whenever you want to look up a word.
A nice bonus or synergy is that the website also returns a definition for the word, so
it functions as a simple dictionary as well.
The second post will deal with how to use Vim's built in syntax rule sets to provide
highlighting and nice colours.
There are two or three simple steps:
- a vim script that passes the cursor word to an external shell script.
- a shell script that looks up the word using an online thesaurus, then parses
[continued...]
09:17 Sun, 05 Feb 2012
Slackware, like other Linuxes and BSDs, uses pm-utils to manage
sleep and resume, including managing the cpu frequency governors. The standard scripts
restore the governor after the machine has woken from sleep mode, but they don't restore
the governor's frequency. Here is how to fix it.
I run Slackware on my laptop, as I've mentioned here before, and about the only issue I
have with it instead of the natively installed Vista Home is that it runs a bit hot.
From what I can tell (because Vista does not give you a lot of tools to investigate),
Vista does two things more aggressively: it slows down the CPU frequency, and it changes
the fan speed sooner. However, the benefits of have a unix-y environment more
than make up for that so I am happy with running Slackware.
However, that does not mean I can't tweak things a bit, such as setting up a CPU
frequency governor and scaling the frequency, which I wrote
about previously.
Pm-utils
Slackware uses pm-utils, a suite of scripts from
freedesktop.org, to manage suspend and
[continued...]
15:21 Fri, 13 Jan 2012
Calcc is a useful command line calculator for programmers, with a
full range of bit and byte operators.
I have been going through James Malloy's tutorial on writing your own operating system1 , which involves some assembly and
quite a bit of bit twiddling with shifts and masks in C.
I haven't written any assembly or done any serious bit manipulation for years. I can do
simple (i.e. 1 byte) hexadecimal addition in my head, but nothing more complex than that, so I
needed a quick calculator that showed me the results from doing things like bit shifts,
rotates, masking, and so on.
A bit of googling found one contributor to
Stackoverflow recommending calcc by Luigi Auriemma. A quick download
of a small zip file and there it was, GPL'ed source code and pre-built binaries for
unix and MS Windows.
It is quick and simple to use and has the usual unary and binary
[continued...]
11:15 Sun, 18 Dec 2011
Slackware's cron daemon has some new features that make it
especially good for laptops.
As long as I can remember, Slackware has used Dillon's cron dcron as its cron
daemon. Dcron is a lightweight cron with an emphasis on a solid secure codebase which,
while missing a few esoteric features found in bigger cron daemons, is great for most users.
Since 13.1 and continuing with 13.37, Slackware has had an updated version of dcron that
introduced some very handy features that make it especially suitable for laptops, or
indeed any machine that spends much of its time in sleep mode. The features give dcron
some of the characteristics of anacron.
Somehow I managed to miss the changes until now, almost two years later. (I must have
been in a personal sleep mode.) Here I am going to explain the features and why they
are great for laptops, and give a couple of examples.
Sleep
Over the years you have probably picked up several handy scripts that you run from a
cron job. Some of them might run every day, some of them every week. For example, I
have a weather script that grabs the local weather forecast from the Bureau of
[continued...]
11:41 Sat, 03 Dec 2011
I very much dislike GNU Mailman. Mailman is touted as an easy-to-administer quality
email list manager. It is written in Python and is used by a large number of sites,
especially open source projects.
Yet, despite that, its ineffable charm escapes me. For one simple reason. You cannot
search the list.
Imagine you are trying to debug a problem with a new piece of software you have
installed. What is the first thing to do? Go to the mailing list to see what other
users have done. And there you find this:
Where's the search? Surely the author does not expect me to read through the entire
archive month by month? But yes, that is exactly what they expect.
This is an epic fail from the most important perspective, that of the user.
[continued...]
10:27 Mon, 21 Nov 2011
I wrote
previously about a small script to extract the Google-chrome's version number from
its deb file. To recap, Google provides either a deb (a deb file is a Debian package) or an rpm
(for Redhat and its kin, such as Ubuntu) file only. Other unixes and Linux
distributions need to create their own packages, and Slackware provides a script to pull the deb
file apart and repackage it into a Slackware package.
I wrote a small script based on the Slackware script that extracts the google-chrome
version number from the deb file so you can see if you have the latest version or not.
(None of this would be necessary if Google would name their deb file to include the
version number. I don't know why they don't do this.)
I noticed the script is not particularly efficient so I rewrote the section that
actually gets the version number. Here it is (first the original, then the update):
[continued...]
08:08 Wed, 09 Nov 2011
Here is a quick script to pull out google-chrome's version number from the deb file that
you download from Google's website. I call it getversion.sh. I find it
useful when you want to see if the google-chrome version is newer than the one you have
installed on your Slackware system without having to go through the whole build process.
The method is pulled from Slackware's build script which itself thanks Fred Richards.
To use it: ./getversion.sh [ -h | filename ] If you don't provide a
filename, it will look in the current directory for the default-named stable deb file.
It will print this: google-chrome-stable_current_i386.deb file's version is:
15.0.874.106.
Because the output is separated by a ":", in other words into tokens, you can use it in
a script to get just the version number. ./getversion.sh | awk -F: '{print $2} will output just the
number like this: 15.0.874.106.
You could put that functionality within the script and signal it with a command line
flag, but I haven't bothered. I leave it as an exercise for the reader.
[continued...]
10:52 Sat, 29 Oct 2011
How to get XEphem and Scrotwm to work together nicely, so that popup dialogs and windows float naturally.
XEphem is a well known astronomy and ephemeris program for unix and Mac (and Windows
on Cygwin or an emulator), and scrotwm
is a dynamic tiling window manager for the same set of operating systems, including
Cygwin/Windows.
Since scrotwm is a tiling window manager, its default behaviour is to open new windows
in a full size tile. XEphem opens quite a few new windows; almost any task opens a
dialog window so you can specify parameters or choose various options. This means that
using XEphem and scrotwm together results in a bunch of open tiles, some of which are
clearly meant to be small dialog windows and others which are meant to be quite large,
such as the view of the sky. We want to change this so that the windows open as they
were designed to open (and which they would if they were on a normal desktop).
Scrotwm lets you override the default behaviour of any window by using its quirks mode.
You specify the window class and name and the behaviour you want. This is clearly
demonstrated in its man page. Unfortunately, you can't use a wildcard, so you can't say
[continued...]
10:50 Tue, 25 Oct 2011
There must be something in the water. First Steve Jobs, then Dennis Ritchie, and now we
have received word that John
McCarthy has died. He was 84.
McCarthy was the inventor of Lisp, the concept of garbage collection, and coined the
term "Artificial Intelligence". He even (unbeknowingly) forecast cloud computing through his notion of
computing as a general public utility. Although probably not recognised by the general public, he
was very much one of the pioneers of computer science. He received one of the very early
Turing Awards, in 1971.
At 84, we can't be too sad at his passing. Instead, we can celebrate his pioneering ideas.
12:11 Sun, 16 Oct 2011
Sad to read today that
Dennis
Ritchie died a few days ago. His death did not make the popular press, unlike Steve
Jobs', and, in a way, that is an indicator of his life. He was the archetypal quiet
achiever.
Ritchie was the co-author of the C programming language and the UNIX operating system.
Both were hugely influential on the development of almost every computing device we use today.
Ritchie had a great influence on me. I had bought my first real computer, an Amiga 1000
(after having a System-80, the local equivalent of the TRS-80), and it was written in C.
I knew nothing about C and set out to learn. The first book I bought was K&R (otherwise
known as The C Programming Language), and the rest is history.
The Guardian has two nice articles,
a eulogy, and a good historical piece.