Recently in Computers Category

signal versus sigaction

| No Comments | No TrackBacks
the use of the
signal(int signum, void (*handler)(int))
is a smidgin dangerous on various operating systems. Under Solaris, for example once the signal has been delivered to the process the signal handler is reset, so a typical piece of code that wants to reuse the signal handler repeatedly will typically set the signal handler again when receiving the signal. This leads to a minor race condition where upon receipt of the signal and the re-setting of the handler the process receives another copy of the same signal. Some of these signals cause Bad things to happen - such as the stopping of the process (SIGTSTP for example). Under Linux it keeps the signal handler in place, so you have no fear of the event triggering an unwanted event.
The manual page for
signal
under Linux makes it clear that the call is deprecated in favour of the much more functional
sigaction(int sig, const struct sigaction *restrict act, struct sigaction *restrict oact)
call, which keeps signal handlers in place when you don't pass the SA_RESETHAND parameter as part of the sa_flags parameter of the sigaction structure. So you get to explicitly choose to accept a signal once, and then have the system deal with it in the default manner afterwards.
Signals, are of course a real pain in the ass when dealing with sub-processes. For example the use of ptrace to perform profiling works well until you fork. If another SIGPROF signal arrives before you can create your signal handler then the child process is terminated as that's the default behaviour in that situation.
Under Solaris (and Leopard) you can make use of dtrace to perform profiling on a set of processes without needing to deal with vagaries of signal handling, making this a non-issue. For those of you stuck in LD_PRELOAD land, probably the only thing that can be done is to set the signal disposition to be ignored before execing the new process. you have a small window where the profiling is missing, but the overall increased stability of the application is improved by preventing it from accidentally being terminated due to a profiling signal being received too soon. I know the accuracy nuts would hate that, but it's part of the price of dealing with standards.
CreativeWhine Oh get over yourself! I do not need to install the music management software on my computer and not having it installed is not the end of the world. It's almost as bad as the apple updater suggesting you install Safari. Mind you, it's nowhere near as annoying about it, and it doesn't suggest that the world will end if you don't download it (but, you know, it just might...)
Vista's built in search box on the start menu is a boon for launching applications. The general accessibility of windows applications to users of the keyboard is a huge boon to those of us who try to keep our grubby little fingers on the keyboard.
This does not seem to be quite the case on the mac. I'm probably unaware of all the keyboard accelerators that are available - after all, I've been using Windows for a lot longer. A lot of my use of the keyboard was prompted by a long use of FVWM while in Sun, where practically everything was usable without having to stray to the mouse. Mind you on laptops, the location of the touchpad is a lot better in this regard - you just drag your claw-like thumb over the tracking surface.
#!/bin/bash -p

if [ $# -eq 0 ]; then
    echo "Usage: $(basename $0) " 1>&2
    exit 1
fi

while [ -d /proc/$1 ]; do sleep 0.5; done
If I implemented it using inotify, I presume I can get rid of the sleep, but that entails compiled code.
I like supporting Irish websites, so I tend to use url.ie for links. the algorithm for generating the link seems to be sequential, so I was happy yesterday when my link for the perfect coffee went to http://url.ie/pdc, or as Dale Cooper would (hopefully) say - perfect damn coffee.
I have to laugh when I see the great data recovery 'challenge'. Lets be honest here folks, businesses are in it to make some level of profit from their efforts. To that extent they have facilities in place to recover data from damaged drives due to a variety of problems from simple surface level damage all the way through to failed drive electronics (swapping out logic boards).
The price quoted is generally based on the amount of effort that needs to be gone thorough. Accidental erasure is probably the cheapest. Simple disk-level damage (e.g. a few dodgy sectors) can be resolved using tools like Steve Gibson's Spinrite; which is pretty much a good example of what these companies would be doing. Drive electronics failures would cost more - for example they may need to disassemble the drive in a protected atmosphere to replace something. Large scale physical damage to the drive may entail extracting it from the original housing and essentially replicating the internals of the drive in order to read the data from it. This would be very expensive, but would succeed in the face of quite significant damage.
The intentional erasure of the data using utilities like dd are pretty much a non-starter. For the first part, you need insanely expensive specialist equipment, the rate of data recovery is slow (we're probably talking in the order of bits per second) and the chances of actually recovering anything useful on a typical hard drive is nil.
For any typical person trying to wipe their data any of the secure erasure utilities available for purchase or for free are more than adequate to prevent the data being recovered by any agencies.

Not a lot of font choice

| No Comments | No TrackBacks
Adobe Buzzword Font List This is the list of typefaces available in Adobe's new Buzzword. It is really, really pretty; implemented in Flash, but when it comes to using it we discover that the two main fonts are missing - Times & Helvetica (or Times New Roman & Arial for 'softies).
All the online offerings from the Adobe Beta are pretty nice, and cover the most fundamental of things, and some of the more useful features - like change tracking in Buzzword. It's all flash; so I have the fear that it will crash my browser.
It's yet to happen me on the mac, though; even though I keep losing the browser on Linux
Chrome Incognito All the popular kids seem to be doing it. IE8 has the feature. Chrome seems nippy too.
Not really stated anywhere obvious, but apparently Xgl isn't the preferred mechanism for all the special effects in Xorg post 7.1, it's AIGLX that you should be using. It's integrated too :)
So after wasting a lot of time trying to get the nvidia driver working properly with XGL after the latest updates I just searched the docs here, there and everywhere and finally picked up on the 'just use AIGLX' vibe.
Maybe I should be reading the release notes... or are they in the release notes at all? I managed to survive gutsy and hardy without changing over to AIGLX and it still worked, so I may just have missed this in the notes somewhere.
Sitting in the Galway Hooker bar, having a pint waiting until my train starts boarding.
Using an Acer Aspire One laptop, running Ubuntu Intrepid Ibex and my USB 3g data dongle.
It's actually usable. It may be small, but it's cabable.
Oh, and it looks like my train is boarding. At least I have a seat reserved so I don't need to queue with the other folks.
I don't want to keep manually syncing my address book on Vodafone with that of my mac, so I use this script to pull out the phone numbers of people when I want to send them a text message using webtext (or my webtext script).
#!/bin/sh

search_for=name
return_val=phone

args=$(getopt s:r: $*)

set -- $args

while :; do
    case $1 in
        -s) search_for=$2; shift;;
        -r) return_val=$2; shift;;
        --) shift; break;;
    esac
    shift
done

if [ $# -lt 1 ]; then
    echo 1>&2 "usage: $(basename $0) -s <search> -r <return> YOUR_SEARCH"
    exit 127
fi

search=
for i in $@; do
    if [[ -z $search ]]; then
        search="($search_for contains \"$i\")"
    else
        search="$search and ($search_for contains \"$i\")"
    fi
done

scriptcode="tell app \"Address Book\" to get (value of $return_val) of every person where $search"

osascript -s "s" -e "$scriptcode"

exit 0


You can get it Here.

Trust me...

| No Comments | No TrackBacks
Plaxo Assistant Cert It tells me to trust it. After all, it's a certificate that's signed by a CA that isn't in the list of known certificate authorities.
I don't trust certificates. There is a list of certificate authorities a mile long stored on my computer of groups who are to be trusted when a certificate is presented. I don't know them from adam, and the certs from the Hong Kong post office are about as trusted as the ones from the Apple Root CA - get real people this is not security, this is just posturing. I trust them about as much as I trust the digital quicksand upon which they are based.
I've stopped caring anymore. The only thing that these certificates establish is a temporary private channel between me and the web server. The rest; it's just smoke and mirrors.
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.
Flash Update Message Apparently, it needed to install a security update. I don't believe I'm using any flash applications that would keep the player in use, so why the pathetic dialog on the left after I installed it? This is one of those cases where pushing through the update makes more sense. As it is this only tells me that I need to reboot my computer to be safe from 'flash viruses'.
Is it that the flash component is so embedded in the operating system that updating it requires a reboot? If that's the case then why? it's only a little thing for displaying animations; not the end of the fricking world.
Busybox is pretty much essential if you're using a small, embedded linux. It's small footprint and complete replication of most of coreutils (and a bunch of other packages) makes it great. All you end up with are a bunch of symlinks.
The problem is, though, that pretty much all the commands are 'slightly different'. They don't take long options. Help is not helpful (I've regularly had to look at the source to tell what's the problem).
The real problem comes when you decide you want to rip it out of your system. All those minor things that had to be changed to work under the busybox system now have to be re-checked under coreutils and family.
Fun for all the family.
It's great. simply prettier and a lot more usable than Firefox 2. The awesome bar (the address bar) kicks ass. Much easier to use than the previous one. Bookmark management has been improved. The look and feel is nicer. I even 'kind of' prefer the subtle dialog box improvement which turns up at the top of the form, which is like a wide series of websites that perform the same thing themselves.
This definitely has replaced my web browsers in Windows and Linux. There's a very high chance that it will replace Safari on the Mac. The only niggle I have is that it doesn't store your passwords in the Mac keychain, which I still feel is the better place to have them.
Damn the electric fence...
Defeating the laughing octopus this time round was significantly easier, simply due to knowing all the patterns already. I do like the leaking the color out of the scene effect that is used at certain sections. Very artsy and very well done.
Then I played for at least an hour after that and remembered to save.
Why can't these folks auto-save upon zone transitions (like half-life 2). I was saving every time I could simply to be on the safe side.

gravatar URIs

| No Comments | No TrackBacks
Short and simple: http://en.gravatar.com/avatar/<md5 hash of email address>?.
e.g. echo -e 'bob@email.com' | md5sum gives: c961431faea38ed65bfd982cf2e31bd0. Optional add-ons are size (s=<Number of pixels>), content rating (r=<g, pg, r, or x>), and default (d=<escape encoded URI of an image or one of identicon, monsterid or wavatar>).
great place to do something akin to the 'imitate a lotus notes password entry trick'.
And when you get to the end of the first act there's another 3 minute hard-drive install while the game chastises you for staying up too late. Nice of it to do that.
This is a simple perl script that checks if the passed in input data is binary or not by checking if, within the first 8k the number of non-ascii characters exceeds the number of non-ascii characters by a factor of 2. It's fundamental in that it doesn't check for unicode files, so is probably broken in that case.
#!/usr/bin/perl -w

use strict;

my $buffer;
my $nread;
$nread = sysread(STDIN, $buffer, 8192);
my $nchars = 0;
my $nbinchars = 0;

foreach (split(/ */, $buffer)) {
        my $value = ord;
        if ($value < 32 || $value >= 127) {
                $nbinchars++;
        } else {
                $nchars++;
        }
}

exit ($nbinchars * 2 > $nchars);

Installers

| No Comments | No TrackBacks
I like the general way of installing applications on the apple. Drag program into Applications folder, and you're done!
The only problem comes in when you actually have to use installers, as they want to put things in various locations in system-protected locations. 9 times out of 10 they don't come with an uninstaller, so removing them can be a bit of a difficult task, especially if they spew themselves everywhere.
Another issue with the mac installers is that they're shell scripts. People keep forgetting that the mac file system hierarchy contains loads of spaces. Don't forget to trap filenames with quote marks "$foo"! It's broken quite a few systems as a result of forgetting this fact.
Nerd commentary really.

If you heart unicode too, pass it on

Toolbox essentials

| No Comments | No TrackBacks
Well, I was reading '5 more essentials for your programming toolbox' and the first entry has my favourite - unfolded linked lists. It's just that it's broken in at least one way. You should embed the list of 'void *' pointers at the end of the entry using the magic of the zero length array at the end.
struct unrolled_listitem {
    int num_elements;
    struct unrolled_listitem *next;
    void *pointers[0];
}
You get the size of a struct item from (sizeof(struct unrolled_listitem) + num_elements * sizeof(void *)). You need to min/max it to the size of a cache line.
The issue is that if you want to embed this structure in another one, you need to add padding after it to the max of the size of the structure that you are planning on allocating.

Several GSODs later...

| No Comments | No TrackBacks
Well, the mac doesn't get BSODs it gets a slightly differently colored grey screen of death. Thankfully I had saved before yanking out the plug for the external monitor. It greyscreened on me with the multi-lingual press the power button for a few seconds message on-screen.
I mean really guys, this is grade-A simple stuff, people should be expected to plug these things in and out on a regular basis so it shouldn't be a kernel panic level issue when something goes wrong in that case.
At least you get a 'graceful' video driver restart when things go horribly messy on that platform (unlike XP where you just have a brick).
Ok, I ponied up a wodge of cash for a ps3 and a few games (and paid the tax for a few movies too). I got Uncharted:Drake's Fortune and Assassins Creed (grammar note: this is a creed that covers all Assassins, so I think the apostrophe should come after the s).
Well, Uncharted is just fun. I'm still a newbie to controller based gaming, but over all, I am impressed. The puzzles and combat just seem to work well; mind you I'd be hard pressed to find that many mercs on any one island. You would need to pay them a hell of a lot of money to stay once they start getting killed with any degree of regularity. Reality aside, it just works as a game. The visuals are great and the game play is well paced and just combines to give us a good experience
Not so Assassins Creed. Booooring is probably the best expression for it. Boring in the same way that performing the same, repetitive missions time and time again gets really damned boring. You get to the city, save the person in distress and then sneak in in the company of a bunch of monks. That's the only way in. Then once you get in you have to perform a minimal set of a handful of styles of missions in order to get to the real mission.
You can go everywhere.... so bloody what, it doesn't help in the complete absence of variety in the missions.
The visuals are great... No, they're good, put a few more pixels on Outcast and it would probably beat Assassins Creed hands down.
For a company like Ubisoft who have produced an excellent run of 3D games in the Prince of Persia series (which got boring, but made up for it in the puzzles) I am stunned that they could produce such a band title. I'm left wondering if they were just scared to produce something that had a bit of excitement in it due to the fact that they set it in a contentious time period (which even then is a huge cop-out, god how I have another rant stored about that).
Oh for another Beyond Good And Evil, Damn, that game is a milestone that needs to be shown to people as an example of how to make a game that reaches out to the player.

Where's the SDK, huh?

| No Comments | No TrackBacks
I'm just wondering when Apple will be shipping the SDK for the ipod touch/iphone. Just being nosey really. I've veered away from jailbreaking it simply because I don't want to end up with an expensive brick next firmware update.
They say February, but of course remembering that the Leopard launch being the end of the month it could be anywhere up to the 29th.
Another thing I'd like to see is the UI guidelines. I'm a bit of a nerd when it comes to reading design guidelines, simply because there are a lot of good points in them. Mind yo, you should not be slavishly obeying them, as, after all, they are only guidelines, and not commandments.
On guidelines, I'm get miffed with applications that require the use of the mouse to accomplish things. Vista's keyboard usable everywhere is a charm to use, even while it's gobbling up all those cpu and disk resources with the indexer.

Stolen from SVGL

| No Comments | No TrackBacks
I enjoy reading SVGL, and the current article is no exception. Considering that I went and pre-ordered Devil May Cry 4, when I read this it made me almost want to cancel the pre-order (not!).
Devil May Cry 4 also has a part where these evil naked snow chicks make out with each other and kiss each other all over. Okay, okay, that was kind of awesome. But I also sternly raised my eyebrows! I did!
To replace my motherboard, graphics card, CPU, heatsinks, fans.... pretty much everything except the actual case the machine comes in.
Apple have obviously made some significant backwards compatibility errors. Firstly, there's the firewall - altering the on-disk content of applications to make them signed when you accept them. Its an interesting approach, but it's complete pants. You don't go around altering binaries on disk. You create a detached signature! It's not really bloody difficult.
On Vista, you can see *every* rule that exists for the firewall. On Leopard, you only get to see the exceptions you created yourself.
I've been having random application crashes. They seem to be related to drag and drop operations that went wrong.
the calendar application does not want to talk to my instance of davical properly (all the calendars disappear after restarting, and I get an error every time I create a calendar). Then there's the 'the application terminated unexpectedly' - no, it didn't, I used the <Apple>Q menu item to quit the application.
Context sensitivity on the mail application is kinda limited - It doesn't detect URL links properly - I have a site that's called http://foo4/..., and all the link comes up with is http://foo. As I said, a bit limited.
Overall, though, the experience is positive. I would have preferred if apple had simply spent some more time testing the damned thing against anything other than their own applications and services.
And, as soon as they allow a replacement for .mac that can be replaced with an external, non-proprietary service I'll be a happier person

Plucking dell battery!

| 1 Comment | No TrackBacks
Aargh, I just saved my laptop from exploding/catching fire. Literally minutes/seconds away from a potential disaster (losing my hard drive - time to do a backup today).
A dell laptop, with a battery model of C5447 - one larger than the number listed in the dell battery recall program. The battery was really really hot - I mean pretty much frying-pan hot heat on the battery. I've contacted dell support. I wonder what's going to happen with this
I was reading the 'Basics on how shims work', and all I could think about was the old linux/unix trick of using LD_PRELOAD to intercept library calls in dynamically linked applications (used to great effect to bypass timebombed applications).
It is one of the reasons why I think that static linking is just horrible - after all, it breaks things, and makes you have to use terribly complicated tricks like disassembling and binary patching to fix problems because you don't have the source code. You don't get the advantages of page sharing, which is kind of important when you consider how many libraries are loaded by the typical gnome application (last check on nautilus was 117 libraries, excluding VDSO and the binary itself, firefox has 151, excluding fonts and other pango related nonsense). Yes, indeed, winners don't use static linking.
As a tangent, it's one of the reasons for not using application compression tools on binaries - after all, the only thing you save is on the distribution size, not on the run-time. The binary itself acts like a static linked blob, and doesn't share the text segment (program code) amongst the other instances, like other binaries, so every instance can use a lot of private memory, leaving less physical memory on the machine for other things like playing high resolution video.
Every time you reinstall vmware it seems to recreate your network interfaces, and at the same time reassigns the ip addresses that you had set up. If you want to move them then you need to edit a file and a couple of registry entries.
The first file is %APPDATA%\VMware\vmnetdhcp.conf. On XP it's normally C:\Documents and Settings\All Users\Application Data, Under Vista that's C:\ProgramData. Note, however that when UAC is enabled, this folder experiences redirection on write by unprivileged users, so editing this file as an ordinary user will have no effect, so make sure that you use a privileged editor when altering this file.
The content you want to change are the Subnet and Range entries to match your original subnet entries you had. You can also put in entries for the domain-name and router. When you add this information it gives you the ability to mark a the subnet as identified under Vista, so you can be in an identified network, and thus be discoverable. Please note that doing this and then putting an insecure OS on the client vm is your own fault.
The other entries that need to be altered are in the registry. The first one is HKLM\Software\VMware, Inc.\VMnetLib\VMnetConfig\vmnet? entries - the IPSubnetAddress entry needs to be changed to match the entries that you set in the .conf file. The next one is a little bit tricky - it's HKLM\SYSTEM\CurrentControlSet\Services\VMnetDHCP\Parameters\VirtualEthernetSegments\?, the value is HostIpAddress - and it needs to be mapped. The value is a endian-reversed representation of your address so if your ip address is 192.168.22.1 the value would be 0x0116A8C0, C0==192, a8==168, 16=22, 01=01. Use Calc to get the values that you should put in there.
Restart the service "vmware dhcp service", and then you should be OK.

vmnetnat.conf musings

| No Comments | No TrackBacks
I wonder does the 'allowAnyOUI = 1' option that's commented out allows me to pick an oui from a previously created virtual machine that's part of the pre-allocated set.
The network interfaces that get configured by vmware always fall into the 'unidentified realm'. The reason seems to be tied to the lack of a router or default gateway entry for the address.
So we cheat, and add in a router entry for the networks that is the same as the IP address of the connection and bingo, you get the option to put it into another network and give it a label! So I put both the VMware network interfaces and the Microsoft loopback interface into a group called 'local only', and providing I don't use any grotty windows virtual machines, it should service me well. Of course, this is all purely academic for those who don't use vista
It strikes me as a little odd that a company got a patent in 1991 covering parallel processing of a form that seems to look suspiciously like the Inmos Transputer hardware from the 80's. They are now suing Sony for their cell architecture (hey, try suing IBM instead; they designed the damned thing). The patent in question is 5,056,000, Synchronized parallel processing with shared memory.
I'm replaying network traffic at 1000 packets per second into a vmware client that's hosted on a vista machine. It's losing quite a few packets. the Vista OS does not appear to be losing the packets, they are simple missing on the guest operating system. This is a lot like crap, really.
Let's see. I have copernic desktop search, which injects itself into pretty much every process that's running on my desktop.
then we have the nvidia nview desktop manager, which is pretty useful in a multi-monitor setting. It also insinuates itself into every process that runs on the desktop.
The end result ... they keep hitting each other over the back of the head.
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?

The more we build

| No Comments | No TrackBacks
The more things stay the same. I am a 100% pass person. Any deviation from that is considered failure.
Steam is a great idea. You get to download your games and you can play anywhere that you can log in to steam. The problem is that the prices of the games are a bit on the high side. For example today Eidos have announced a load of their games are now on steam. Hitman: blood money is $35.95. It's cheaper to walk into your local game store and get it there.
For some reason the re-release on steam pumps the price up over what you can get in the stores. And then it stays there. You get the occasional reduction in price, but overall the price of each game remains reasonably static for it's life on the system. Which is frustrating.

it's a tomato

| No Comments | No TrackBacks
Well, having had enough of the dd-wrt firmware for the linksys router. It was annoying, slow and irritating and every time we enabled QOS it lost the connection to the WAN I upgraded to the tomato firmware. So far it works. It successfully QOSes the p2p stuff down to the lowest category. It has pretty graphs! Whoopee!
Apparently the PS3 has this new thing called 'home'. It's basically second life for all those people who bought a PS3. Or there, or something equally as silly. The benefit of it is that sony don't have to program for every GPU on the planet - they only need to get it working for the PS3 and they're golden. Everyone on the site has at least one thing in common, and they don't need to congratulate each other again and again. Based on the sweet graphics, I'm presuming that just about everything on it is small-c configurable, rather than big-c configurable (involving lots of downloading).
Someone is bound to rat me out for this one. I've resorted to using a sun type 6 USB keyboard when typing on the small laptop. For those times when I couldn't be bothered dragging the XPS out of the backpack I just need to reach over to the keyboard and plug it in. Dayamm, but it makes a huge difference. The response is just right. The laptop's keys are just that little bit too wussy.

It's a clip from idolm@ster, a bit like dungeon master except with your own idol group. it is so kawaii.
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/{}