Recently in Tips Category

Firefox 'dialog' The suggestion by Joel to not hide or disable menu items is a good one. There's only one issue. With the way it's worded you could end up with a swarm of dialogs. I would suggest some form of stackable notification item. The status bar isn't really suitable for this as there's no way to get stuff back from it historically.
The 'in frame' dialog that's becoming popular these days in such browsers as Firefox. This is a reasonable 'dialog', and you could remove them automatically after a period of time (say 30 seconds). as long as they are differentiated from the other items on the screen it would be reasonable.
How can you tell if your website is usable by anyone? Well one of the simplest ways is to use a text mode browser. It gives you a good idea as to how easy it is to navigate without having to spend the effort getting in a UI designer at infinity$/hour just to tell you that your links should be purple, and not help you in the least bit.
links is a pretty damned good text mode browser. It makes it obvious if you've made a mess of the UI for navigating, which is always a good thing. It makes it obvious when you've forgotten to put the bloody ALT tags into all your images - like a good designer should. Spacer gifs are evil and must be stopped :)
Need to convert from celcius to fahrenheit? From miles to kilometres? From yards to stadia? units will give you this.
You have: tempF(41)
You want: tempC
        5
What could be simpler?
Evolution doesn't really tell you that when you use a script to generate your signature you need to terminate the lines with a '<br/>', otherwise it pretends that there hasn't been one.
All to do with html mail composition. The only way I accidentally found this out was because of it's gconf entry containing this gem:
<?xml version="1.0"?>
<signature name="default" uid="XXX@XXX" auto="false" format="text/html">
<filename script="true">sig.work</filename>
</signature>
Strangely enough, I had actually thought of this before I made the post. Snapshots are a wonderful feature in zfs which allow you to take point in time images of a filesystem that are mutable and which themselves can be snapshotted.
Unfortunately, this leads an explosion of snapshots if we want to be able to arbitrarily remove any one application from the system.
Consider the following operation:
pkg(1) + pkg(2) + pkg(3)
Now remove pkg(2) without using anything other than snapshots.
snapshot before adding anything sn(0). snapshot after adding package 1 sn(1)(sn(0)). snapshot after adding package2 sn(2)(sn(0)) + sn(2)(sn(1)). snapshot after adding package3 sn(3)(sn(0)) + sn(3)(sn(2)) + sn(3)(sn(1)).
Repeat for arbitrary pkg(n).
Unless you're planning on creating a whole travelling salesmanOk, it's not quite the travelling salesman problem, but it gives you a good idea as to how much work is involved of snapshots, I think my mechanism is easier.
If you use windows then this is probably going to be very, very boring.
Every now and again you find yourself needing to install some piece of software on your computer from a source package. You tar xjf the package and descend into the subdirectory and type ./configure.
At this point I would yell stop! Rather than putting it into the default location of /usr/local, consider putting it in /usr/local/<package-version>.
How does this help I hear you ask. Well, using a simple script (in the extended entry), you create a set of symbolic links in the /usr/local directories which reference the files in the /usr/local/<package-version> directories.
If you decide to remove the package then simply remove the /usr/local/<package-version> directory and all the symlinks become broken. By using symlinks -rd /usr/local you clean the file system up and everything is peachy. If you don't have a copy of symlinks, it is available from the debian repository, where you should find the source package somewhere near the bottom.
#!/bin/bash -p

package=$1
destdir=${2:-/usr/local}
me=${0##*/}

[[ -z $package ]] && {
        echo "Usage: $me <package> [destination = /usr/local]"
        exit 2
}

cd $destdir/$package || {
        echo "$me: package $package does not seem to be installed"
        exit 1
}

# build the directory structure - this is a weakness
find . -type d | cpio -o | (cd $destdir; cpio -id)

find . -type f -exec $echo ln -s $destdir/$package/{} ../{} \;

Oh, and for solaris, as I'm using the file in various locations surrounded by symbols you will have to just pass it into a sub-program to execute the link command. Apparently solaris doesn't just substitute the name of the target for the link; instead it will only substitute the name of the target when it is isolated (i.e. you would need to use the {} on their own without anything surrounding them - which explains the space between the closing brace and the backslashed semicolon - old habits). I supposed I could throw a bit of perl at this problem but... it works on my box so frell the rest of you :).
Meh, the entire problem is annoying; generally I would always have to create a program to process the {} operation anyway to prevent space characters from getting in the way but as we say in the trade 99% is better than 0%. If you want a 100% solution you need to add a script that performs the link - one per line produced from the find.
FeatureBourne ShellBusybox ShellBash
Subprocess Execution`` (the backtick)`` or $()As Busybox
Math Evaluationuse expr (not builtin)$(( ))As Busybox; adds ((var=math))
ConstantsNoneNonetypeset -r
IntegersNoneNonetypeset -i
Evaluation[[[
Extended Evaluation/bin/[[ (1)/bin/[[ (1)[[

(1) The [[ operator is not the same as the program /bin/[[ as a program you need to still use double quotes around the variables to be expanded; thus defeating the reason for having them in the first place.

For Example:

	# file="/tmp/let me go"
	# touch "$file"
	# [[ -e $file ]] && echo "There"

Yields [Busybox]:

	[[: me: unknown operand
- as $file is word split before handing it to the command [[

Yields [bash]:

	There
- due to $file not being split when passed to the test -e.
When buying something from the internet I appreciate being informed of things during the process. When ordering something that requires the dispatching of a physical item, then you need to ensure that the customer can safely determine what the state of their order is at any point.
There are two normal mechanisms to support this. The first is an order status page. This page contains information about the state of the order. For example, when a company accepts the order it is flagged as 'Accepted'. Once someone is taking the item and putting it into a box it should be placed in the 'Processing' state. When it has been given to the delivery company a state of 'In transit' would be appropriate. When the delivery reaches the destination and has been signed for, then a state of 'delivered' would be appropriate. This covers the company, who can be happy that the order has been satisfied, and the customer who can see what state their order is in.
Some companies would combine the Processing and Dispatch state, some companies don't have confirmed delivery. These things need to be factored into the equation.
For companies that don't maintain separate account pages, you have the status email. This is sent out once the item has been dispatched from the company. This allows the customer to feel some connection to the order that they have made without needing to confirm the location of their item with a customer service representative.
A few simple steps and you can help your customers feel happier with your service, and as a result more confident in their feeling that you are not some fly-by-night operation.
As the tag says, communication is the key to a successful relationship, be it business or personal.

Least Significant 1 Bit

| No Comments

This can be useful for extracting the lowest numbered element of a bit set. Given a 2's complement binary integer value x, (x&-x) is the least significant 1 bit. The reason this works is that it is equivalent to (x & ((~x) + 1)); any trailing zero bits in x become ones in ~x, adding 1 to that carries into the following bit, and AND with x yields only the flipped bit... the original position of the least significant 1 bit.

Alternatively, since (x&(x-1)) is actually x stripped of its least significant 1 bit, the least significant 1 bit is also (x^(x&(x-1))).

Integer Selection

| No Comments

A branchless, lookup-free, alternative to code like if (a<b) x=c; else x=d; is ((((a-b) >> (WORDBITS-1)) & (c^d)) ^ d). This code assumes that the shift is signed, which, of course, C does not promise.

Integer Minimum or Maximum

| No Comments

Given 2's complement integer values x and y, the minimum can be computed without any branches as x+(((y-x)>>(WORDBITS-1))&(y-x)). Logically, this works because the shift by (WORDBITS-1) replicates the sign bit to create a mask -- be aware, however, that the C language does not require that shifts are signed even if their operands are signed, so there is a potential portability problem. Additionally, one might think that a shift by any number greater than or equal to WORDBITS would have the same effect, but many instruction sets have shifts that behave strangely when such shift distances are specified.

Of course, maximum can be computed using the same trick: x-(((x-y)>>(WORDBITS-1))&(x-y)).

[Listening to: Queen Bitch (live) - David Bowie - RarestOneBowie (3:15)]

Normally, a dual-linked circular list would contain both previous and next pointer fields and the current position in the list would be identified by a single pointer. By using two current pointers, one to the node in question and the other to the one just before/after it, it becomes possible to store only a single pointer value in each node. The value stored in each node is the XOR of the next and previous pointers that normally would have been stored in each node. Decoding is obvious.

Unfortunately, using this trick in C is awkward because the XOR operation is not defined for pointers.

[Listening to: Space Oddity - David Bowie - Changesbowie (5:17)]

Cheap at twice the price

| 3 Comments
Well, I was performing the usual 'tech geek' duty this afternoon. I was fixing up a friend's computer. It was a real mess. It had originally been split into 4 FAT partitions (that's not FAT32), with a lot of wasted space on the disk. Using partition magic, I upgraded them to two partitions - one for the Windows 98, and the other for Windows 2000. Then I fixed the modem so it would work in Windows 2000 - it needed a driver download from the Gateway web site. Once that was completed I installed Zone Alarm (personal edition). That fixed an immediate problem - there was a computer somewhere on the Eircom network that was just barraging the machine with SMB packets - virus or hacker I don't know, but it was causing 100% processor utilization and was killing the machine while it was connected to the internet. Mairt was of the impression that the fan was internet noise. That confirms my opinion - firewall first, the rest is just ornamentation.
What was my charge for all this work? An Indian meal, complete with a bottle of beer! I really am cheap tech support.
Internet noise... what next?

I can't connect to the internet

A hint for all you windows users out there who can't connect to the internet... don't forget that the number they ask you to dial in the dialer box is not your own phone number of your house, but instead is the service providers telephone number. I just spent 20 minutes on the phone trying to tech-support my sister through the dialup effort. She was repeatedly getting number in use errors. It turns out that she put her own number in the dnumber to connect button. At least she wasn't using call waiting, otherwise it would have kept disconnecting here every time she rang.
The fix is as always to use the real phone number of your ISP. I spent 10 minutes trying to get her to the eircom.net phone number, but accidentally gave her a pay-use number. The eircom number is 1892150150. It takes any username ans password, which makes it really easy to use.
Well she's sorted and I'm off home now.

Disable Compressed Folders (Windows Me/XP)
Windows Me and XP include a built-in feature to manage compressed ZIP files and folders. This tweak allows you to disable it and install a third-party application.

To disable the compressed folder feature click on Start -> Run and enter the following command:

regsvr32 /u zipfldr.dll

To enable ZIP folder support run this command:

regsvr32 zipfldr.dll

About this Archive

This page is a archive of recent entries in the Tips category.

Stuff is the previous category.

Usability is the next category.

Find recent content on the main index or look in the archives to find all content.