Thursday, December 31, 2009

PH61153 video selector switch disassembly

Disassembly Instructions
  1. Remove the silver front. It is only held by clips. Push inwards on the black part near the silver while pulling the silver part away. Start where it's easiest and go from there. You can put folded up paper in the gap to keep it open. The front will remain attached by cables.
  2. Separate the black parts of the case. Once the front is off, these clips are obvious.
  3. Unplug the cables going to the front from the main circuit board.
  4. Unscrew the small circuit board for the front input, and unplug its cable from the main board.
  5. Unscrew the screws holding the main board and the screws holding RCA connectors to the back. Remove the main board


The top of the main board shows the through-hole components and the back of the RCA jack circuit board. The socketed chip is a EM78P156EL microcontroller.

The bottom shows the surface mount components. The chips are 4000-series CMOS. The three along the bottom are 4052L. Each contains two four-channel analog multiplexers. The chip above them is an HEF4053B. It contains three two-channel analog multiplexers.

Here is the rest of the device. Note how except for the RF modulator, there's no shielding. Even the video signal from the front panel connects via ordinary wires. Nevertheless, the switch does not seem to degrade video quality.

The Story

I just got a PH61153 video selector switch. It has four inputs, supports composite and S-video and stereo audio and has an RF modulator. The best part is that it can automatically switch to the highest priority input which has a video signal, and so I can basically hide it and forget about it.

I got it from XSCargo. They were the only local store that had it in stock, and they certainly had what seemed like a good price ($19.95). Unfortunately, the low price only reflected the low quality. First I noticed that that Philips wasn't mentioned anywhere. Then I noticed that most of the them were badly scratched and scuffed, and one had something rattling around inside. Finally, when I bought one and brought it home, I found that one of the inputs didn't work. The switch never auto-switched to the first input, and if I manually switched to it I got no composite video or audio.

I didn't like the idea of going back to XSCargo. It was a long drive, and the replacement could again have some issue. At this point, I didn't want to open up the switch and so I first measured resistance at the inputs. Unlike the other inputs, the broken input had an open circuit on all three RCA jacks. Based on this, I concluded that the problem was probably a bad connection, and not a burned out part. So, I decided to open up the device.

The problem turned out to be a crack on the back circuit board. The RCA connectors on the back are all mounted the back circuit board, and the S-video connectors are mounted on the main board. The back circuit board has large square holes for the S-video connectors. As a result, it is only connected to the main board via four fingers. One of these fingers had cracked. That's not surprising when you consider how some RCA connectors can be very tight and hard to fully seat or unplug. It was an easy fix.

Saturday, December 26, 2009

Old Avant Browser user agent causes sites to redirect to mobile versions in IE

Avant Browser (an Internet Explorer shell) can come back to haunt you. When uninstalling, it leaves behind its addition to the Internet Explorer User-agent (in this case "Avant Browser []"). That addition causes some sites to redirect to the mobile versions in Internet Explorer 8. In some cases, it is impossible to view the normal version of the websites because even deep links redirect to the mobile homepage. To fix the problem, remove the User-agent addition. You can search for "Avant" in regedit.

Thursday, December 24, 2009

Cygwin 1.7 upgrade breaks Perl due to missing libssp0 dependency

After upgrading Cygwin to version 1.7, Perl failed with the following error message:

/usr/bin/perl.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory

Then I ran "cygcheck /usr/bin/perl" and saw a bunch of these errors:

cygcheck: track_down: could not find cygssp-0.dll

I then installed libssp0 (current version 4.3.4-3), and Perl worked properly.

Wednesday, December 23, 2009

I saw the Torch today

I used to think that the Olympics are a part of human cultural heritage and that they're meant to be an expression of certain ideals. Starting with the 2008 Beijing Olympics I learned more about the business aspects of the Olympics. What I learned looked bad. I saw that the Olympics were being run like a corporation. Ideals, individuals or even athletes seemed to be less important than sponsors and branding. Basically, free speech and other freedoms are restricted to please the sponsors and control what people see. This is not acceptable, and it's especially disappointing to see this happening in Canada.

At first, I was planning to not see the Torch this year. What changed my mind was the thought that very many things are seriously messed up, and that I should focus more on recognizing the good parts and less on rejecting things because of bad parts.

At first I contemplated seeing the Torch at Point Pelee National Park, but I scheduled something else and I couldn't make it to Pt. Pelee on time. So I ended up seeing the 2008 Vancouver Torch in Kingsville, Ontario, and that turned out quite well. Plenty of people lined the streets in Kingsville, but it wasn't too crowded and everyone could get a close view of the Torch. Before and afterwards, the entertainment was children singing Christmas songs, which was quite nice.

This was the third Olympic Torch Relay I saw. The other two were the 1984 Sarajevo and 1988 Calgary Relays. It's interesting how they keep getting bigger. In late 1983, there was just the torchbearer and one or two cars, the 1988 Relay involved more vehicles, and finally in 2010 there was a whole mini-parade of vehicles for officials, sponsor displays and security. Maybe that's another illustration of how the Olympics have strayed from what is really important, or maybe not. I can't really complain about what I saw today.

Sunday, December 20, 2009

Enabling UAC Virtualization so old plugins can save settings

Originally, Windows had no filesystem security, and applications could write data wherever they wanted. Because of that old software often stores settings in the Windows directory or the application directory. For example, old Winamp plugins store their settings into the plugin directory (typically C:\Program Files\Winamp\Plugins). Starting with Vista, writing to those directories requires administrative privileges. To allow old software to function correctly, Windows can redirect such accesses to a place within the user's profile folder (%userprofile%\AppData\Local\VirtualStore). The same issues can exist with registry writes, and Windows can also redirect those. When an application is specifically designed for Vista or Windows 7, this redirection (called UAC Virtualization) is not needed and so it is disabled.

This normally works so well that one doesn't need to know about it. However, it fails when an application designed for Vista or Windows 7 loads old plugins. For example, some old Winamp plugins cannot save settings. Here are some solutions:
  • Grant write access to the directory.
  • Delete the manifest resource from the executable using a registry editor. However, some executables such as winamp.exe require the manifest resource.
  • Edit the manifest resource in the executable and remove the trustInfo section from the manifest. This means removing text from "<trustinfo" to "</trustinfo>". It's best to use a resource editor, but you can overwrite the text with spaces in a hex editor.
Task Manager can tell you if UAC Virtualization is enabled: right click on the executable and look for the check mark by "UAC Virtualization". This method can be used to change the setting, but I do not recommend it because it would have to be repeated every time the application is run.

Thursday, December 17, 2009

Changing Windows Live Messenger status via Windows messages from HoeKey

I use HoeKey for hotkeys. I love how it's tiny and unobtrusive. It's only using 128K of RAM now. I change instant messaging status via HoeKey so statuses in multiple applications stay synchronized. Here are the lines I use for Windows Live (formerly MSN) Messenger:

=Msg|MSBLWindowClass|273|40166 ; WLM Available
=Msg|MSBLWindowClass|273|40169 ; WLM Away
=Msg|MSBLWindowClass|273|40168 ; WLM Busy
=Msg|MSBLWindowClass|273|40210 ; WLM Sign out

To use those lines, either put a hotkey identifier before the equals sign or append them to other hotkeys. MSBLWindowClass is the window class of the Windows Live Messenger window. 273 means the message is WM_COMMAND. The 5 digit numbers correspond to wParam of the message and identifiers of entries on the File menu. Text after the semicolon is an explanatory comment.

Disclaimer: I don't like Windows Live Messenger. I just use it because it fully supports all the features of the protocol.

YouTube FLV files contain unique identifiers which could be used to find who downloaded a particular file

FLV files which have been downloaded from YouTube have a unique identifier. In several files I examined, the string "sourcedata" occurs at offset 0x10E and a unique alphanumeric ID is at offsets 0x11B through 0x125. Presumably, these unique identifiers can be matched with information in YouTube logs in order to find the IP or user who downloaded the file.

Sunday, December 13, 2009

Links in Windows are annoying

I just created a directory of photos for use with the Windows 7 desktop background slide show feature. It consists of photos which I uploaded to Panoramio or printed. I used links so I didn't end up with multiple copies of photos. Here are a few reasons why links in Windows are annoying:
  • To create links, one needs administrative privileges (eg. run command prompt as administrator). This is stupid, especially for symbolic links.
  • When deleting a symbolic link from the command prompt or explorer, the link is deleted, as expected. When deleting a photo while it is viewed via a symbolic link, the original photo is deleted and the link remains.
  • Hard links work in a more reasonable way. However, when deleting a link, file permissions are changed.

Downloading photos, coordinates, titles and tags from Panoramio

I really like Panoramio. It's the main place where I publicly share my photos. Whenever I really like a photo and feel that it fits criteria for inclusion in Google Earth (via the Panoramio layer), I upload that photo to Panoramio.

My main complaint about Panoramio is that I cannot export any information about my photos. I've spent a significant amount of time and effort geotagging and tagging photos in Panoramio, and I cannot obtain any of that information. Yesterday I decided to do something about this.

I chose to do this from the command prompt using common GNU tools: bash, wget, grep, sed and more. There was an obvious simple first step: downloading the photo index pages. I noted that I had 27 pages, and then I used this bash command to get them all:

for (( i = 1 ; i < 28 ; i++ )) ; do wget "--user-agent=Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20091102 Firefox/3.5.5" "$i" ; sleep 10 ; done

Looking at the HTML source, I noticed lines containing photo ID numbers and titles. Such information can be extracted by a simple regular expression:

for (( i = 1 ; i < 28 ; i++ )) ; do sed -n "sX^.*h2><a href=\"/photo/\([0-9]*\)\">\([^<]*\)<.*\$X\1:\2Xp" 5539\?comment_page\=1\&photo_page\=$i ; done > photo2title.txt

The tags were more tricky, because they were on multiple lines. This required a simple sed program which joined the lines:

for (( i = 1 ; i < 28 ; i++ )) ; do sed -n 's/^ *"\([0-9]*\)":\[/\1:/; t next; b ignore; :next; N; s/\]$//; t end; N; s/,$/,/; t next; :end; s/\
//g; s/   *//g; s/"//g; p; :ignore;' 5539\?comment_page\=1\&photo_page\=$i ; done > photo2tags.txt

The coordinates were not in the photo index pages however, and so I had to look for another source of information. Obviously, I could just download all the web pages of all the specific photos, but I didn't really like that solution. I went to view all of my photos in the map and then I opened the AdBlock Plus blockable items list. The link from where the map gets its information was very obvious:

After downloading that I noticed that I was getting the type of information I wanted, but I was getting only 24 entries. I assumed it was due to the "to=24" part of the URL, so I changed that to the number of photos I had. The number I got was three less than the number of photos. Sure enough, three of my photos failed to appear in the map on Panoramio. I reported this bug in the Panoramio forum, and went on with my project. Extracting the coordinates wasn't hard. I based the regular expression on the data for one photo which I pasted from get_panoramas.

sed 's/"photo_id": \([0-9]*\), "longitude": \(-\?[0-9.]*\), "height": [0-9]*, "width": [0-9]*, "photo_title": "[^"]*", "latitude": \(-\?[0-9.]*\),/~\1:\3,\2~/g; y/~/\
/;' get_panoramas | grep "^[0-9]*:" > photo2coords.txt

If I didn't care about tags I could have avoided getting the photo index pages and started with get_panoramas output. It would have been simpler, but I would have missed three photos and failed to notice a bug in Panoramio. Since I knew about the three missing photos, I went to their photo pages, looked at the HTML source, and manually added the coordinates to photo2coords.txt.

The only remaining data was the correspondence between photos on my hard drive and photos on Panoramio. The data collected so far was not helpful. I decided to get the original photos and match them up with local photos based on MD5 hashes. I already had several files which listed all of my photo ID numbers, and it was trivial to download all the photos with wget. I placed delays between the downloads to reduce the load on Panoramio. At the end, I noticed one error in the wget output, and I manually downloaded that photo.

Once I had the photos, MD5 hashes successfully found local locations of most of the photos. The EXIF date and time of when the photo was taken found local locations of most of the rest. Out of 646 photos, I only had to manually match up 12, which wasn't bad. I'm not documenting the detailed matching procedure here. One hint: the join command is helpful.

Thursday, December 10, 2009

Fixing resolution of C-770 MPEG4 videos

My Olympus C-770 Ultra Zoom camera is supposed to record 640x480 MPEG4 videos. However, some applications instead play the videos at 320x240. For example, QuickTime 6.x and Xvid play the video at 640x480, while QuickTime 7.x and ffdshow play it at 320x240.

My solution up to now was to play the videos using Haali Media Splitter for the .MP4 container and Xvid for decoding. That resolved all the problems for me, but if I sent a file to someone else, they could still end up viewing the video at 320x240. Now I've finally figured out what is wrong with the files themselves.

I started out by compiling mp4v2 in Cygwin. This resulted in some errors, but just re-running make was enough to get the executables compiled. Then I used "mp4file --dump" to examine the contents of the MP4 container. It showed a 320x240 size in two places: the tkhd header for the video track and the stsd atom. QuickTime 7.6.5 uses the tkhd size, and Mplayer 1.0rc1-3.4.2 uses the stsd size. Changing both sizes to 640x480 should make the video always play at 640x480.

After seeing 320x240 at two places in the file and not seeing 640x480, I was left wondering what was the actual resolution of the video. It seems to be 640x480 based on several pieces of supporting evidence:
  • The videos are clearer when decoded at 640x480 than when decoded at 320x240 and scaled up.
  • Even when decoding at 320x240, Mplayer allocates a 640 wide YUV buffer with 320x240 chroma (which should be at half resolution).
  • If I extract the video stream using mp4creator, Mplayer plays the resulting MPEG4 ES stream at 640x480. This is even true if extracting from an unaltered .MP4 file which plays at 320x240.
At this point, I was wondering how to change the tkhd and stsd resolution values. The tkhd values may be changed via mp4track (from mp4v2), but I don't know what program can change the stsd values. After finding that the values aren't protected by any sort of checksum and they occur at the same place in all of my videos, I decided to directly alter all the values without using a tool specifically designed for MP4 container files. The changes which need to be made are:
000000F0: 01 02
000000F1: 40 80
000000F4: 00 01
000000F5: F0 E0
000001B9: 01 02
000001BA: 40 80
000001BB: 00 01
000001BC: F0 E0
This is the output of "fc /b". The first four are lines are tkhd and last four are stsd. Note that the patch is simply changing obvious big endian values.

Now the only problem was how to automatically change these values. I thought I would be able to find a utility which takes "fc /b" or "cmp -l" output, verifies the original bytes and applies the changes. However, I didn't find any simple utilities so I decided to create my own. For fun, I created a sed script which transforms "fc /b" output into a C program which performs the patch. You can download it and the resulting Windows executable.

Sunday, December 06, 2009

Windows 7 can't always automatically update root certificates?

Today Secunia PSI refused to run with the message: "an error occurred while verifying the security certificate". Then I found that IE refused to show because the certificate was "not issued by a trusted certificate authority". Firefox did not have a problem with that webpage. For some reason, IE did not recognize the "Thawte Server CA" certificate. IE also refused to recognize StartSSL.

This was really weird, because as far as I know, Windows 7 is supposed to automatically update root certificates. Microsoft even explains how the process works in Vista. My first thought was that my firewall was blocking the update, but that was not it. Event log showed event 4100 from CAPI2, which is "Successful auto update retrieval of third-party root certificate". The problem was event 4110: "Failed to add certificate to Third-Party Root Certification Authorities store with error: A certificate chain could not be built to a trusted root authority."

I manually downloaded and installed the latest root certificate update from Windows Update. After that, everything works. I'm just left wondering why I had to deal with this in the first place.

Saturday, December 05, 2009

256 colour mode palette handling is broken in Windows 7?

A while ago I ported AcidWarp to Windows using SDL. At the time I was running Vista, and I had to use a workaround for full screen mode. I described the issues and my workaround in a post here.

Now I find that the workaround does not work in Windows 7. AcidWarp fails to get all 256 palette entries even when I use the directx SDL video driver. The program's 256 colours are then remapped onto a smaller number of colours. This results in visible errors in many AcidWarp patterns.

There is an even more serious palette issue. When using the directx SDL driver in the normal way (without workarounds, just using the "set SDL_VIDEODRIVER=directx" command), a substantial number of palette entries remain unchanged in full screen mode. These colours are not remapped, resulting in very ugly static parts of the pattern. This can be avoided by using the windib SDL driver or the workaround I developed in Vista.

One workaround for everything is killing explorer.exe. Then both directx and windib drivers are able to grab all 256 colours. Explorer can easily be restarted from Task Manager, and even the tray icons are preserved. Still, it's not a very nice workaround.

Friday, November 13, 2009

Building multi-threaded XaoS in Windows

XaoS is a fractal viewer program which is designed for smooth continuous zooming. It's a great way to explore fractals such as the Mandelbrot Set. Nowadays, multi-core CPUs are the norm, but the Windows binary of XaoS does not support multi-thread operation.

XaoS is easy to build in Cygwin. The only problem is that XaoS is set up to build for MinGW (using -mno-cygwin) and Cygwin doesn't provide Pthreads support for MinGW applications. The solution is to use Pthreads-w32. Using this and running with the "-threads 4" option I'm able to use up to 100% CPU on my Q6600, and XaoS is much faster.

Thursday, November 12, 2009

Intel Matrix Storage Manager driver causes 0x9088 bluescreen

I just saw my first Windows 7 problem. My computer locked up with the hard drive LED lit after resuming from sleep. Then I reset my computer, it started resuming from disk, and I got a blue screen.

I had never seen the 0x9088 (sometimes written as 0x00009088 or 9088) code, and very little information was available online. Fortunately, WinDbg was able to help. The crash was in iaStor.sys, the driver for the ICH9R SATA controller on my GA-P35-DS3R motherboard. Release notes for version mentioned fixes for that error. I guess those fixes weren't sufficient, because I was using Matrix Storage Manager

After a bit of searching, I saw that there was a new Intel Rapid Storage Technology driver. It wasn't available from Intel, but it was digitally signed and available from many places online. I still don't know if it fixes the problem, and it will be hard to tell because this problem must be rare.

Friday, October 23, 2009

How to install a Broadcom Wi-Fi driver on an unsupported system

Dell stops releasing driver updates for a laptop rather quickly. However, the same hardware is found in other laptops, and often these drivers will install. Drivers can even support similar hardware which is not explicitly listed. For example, a driver's description may claim support for one wireless card, but the driver may support all of Dell's Broadcom based wireless cards. A while ago I fixed audio glitches in Vista by installing a newer driver for my Dell Wireless 1500 Draft 802.11n WLAN Mini-Card.

Today I found that Dell had a Broadcom Wi-Fi driver for Windows 7 (R242438), but that driver refused to install. The error message was: "No compatible hardware found. The software you are attempting to install is not supported on this system." Despite this warning, I could manually install the driver via Device Manager without any warnings. After a manual install, the wireless card worked, but I didn't have the utility which shows signal strength in the tray and other components.

Since the driver seemed to be compatible, I searched for a way to do a proper installation. The driver installer unpacks itself to C:\dell\drivers\R242438. In that directory there is a "DellInst.enc" file. It doesn't look like anything, but it may be decoded via "BcmCrypt.exe" (also in that directory, USAGE: BCMCRYPT -e or -d <input> <output>). The file decodes into a text file which shows what cards are supported and what systems are certified with each card. The "Dell Wireless 1500 Draft 802.11n WLAN Mini-Card" (PCI\VEN_14E4&DEV_4328&SUBSYS_00091028) was supported, but my system was not in the list of systems in that section. I simply added the "0x01BD ;Inspiron 6400" line for my system and encoded the file with BcmCrypt. After that the driver installed properly and everything worked, although the highest speed seemed to be 130 Mbps. After changing some advanced settings in Device Manager, I finally got 270 Mbps.

While doing this I also found that there are three different drivers in three subdirectories of C:\dell\drivers\R242438. DRIVER_US is for the US, DRIVER_JPN is for Japan, and DRIVER_ROW is for the rest of the world. For example, it's possible to manually install the driver from C:\dell\drivers\R242438\DRIVER_ROW using Device Manager and gain access to channels 12 and 13. I never tested these channels and I now use the US driver which the installer installed, but it's nice to know that I can change that easily.

Thursday, October 22, 2009

Windows Live Messenger 14 doesn't report message delivery failures?

Occasionally, Windows Live Messenger fails to deliver messages. In version 8.5 this would result in a delayed notification saying that a particular message could not be delivered. In version 14.0.8089.726, messages fail to deliver without any notification. I have never seen any message delivery failure notification in version 14. Miranda IM is still able to report message delivery failures, so it doesn't seem like a server-side issue.

Friday, October 09, 2009

I used Picasa's facial recognition to find friends and myself in photos

In the past I tried tagging my photos with tags corresponding to the location, major things and people in the photo. This was mostly a waste of time. Folder names were already sufficient for finding photos by location and I wasn't interested in finding particular types of things (eg. lakes) in my photos. The only useful part was tags corresponding to people.

The last tagging was a long time ago, and so I had a lot of untagged photos. Recently, I felt like adding tags corresponding to people, but I assumed that it would be very tedious. Then I learned that Picasa has facial recognition and I decided to give that a try.

Starting the process was surprisingly easy. When I added a folder to Picasa, it first scanned the folder in the usual way and generated thumbnails. Then it started scanning the photo for faces. It quickly started filling a list of faces, and I just had to start identifying people. After a bit of manual identifying, Picasa was able to automatically identify some people.

There were certainly some issues and limitations. More than a third of the time, Picasa found a face but failed to identify the person. Occasionally, a person was misidentified (or maybe it was a sign that I look like some relatives). Then there were all the strangers in the background, whom I had to remove from the list. The most interesting issue was occasional identification of faces in artwork (eg. Mt. Rushmore, paintings and T-shirts) and even patterns of reeds or clouds. Fortunately, dealing with all these things was fun.

When the scan finished I wanted to see how many faces were missed. At first I was somewhat disappointed. Picasa easily dealt with sunglasses, but tuques or harsh shadow boundaries often caused faces to be ignored. Picasa also seemed sensitive to face orientation. It did well when a face was vertical and viewed from the front or side, but other angles were a problem. Manually adding people was a bit more trouble than it should have been. I had to go to the photo page, draw a box around the face and select the name. I wish I could have added tags from the thumbnails page without defining the person's location. After doing all this, I felt that Picasa automatically found the faces in the majority of the best photos. Even the automatic face detection wasn't anywhere near perfect, it was good enough and I was satisfied.

Picasa's automatic face detection also provided an unexpected benefit: the way it cropped faces was sometimes very aesthetically pleasing. It actually improved some photos, and it provided many images which could be used online.

Now I'm wondering whether to continue using Picasa or extract the face information and uninstall Picasa. I'm happy with the way I organize things into folders, and generally not interested in programs for managing libraries of files. I still have to see a bit more about what Picasa offers.

Monday, September 21, 2009

Why I consider myself atheist now

Religious stories involving the supernatural seem to be mythological, and literally believing them seems brainwashed or even crazy. However, scientific understanding has such gaping holes that it's impossible to rule out that something like what religions talk about is part of reality. So, for a long time I considered myself agnostic.

Recently I realized that calling myself agnostic can imply that for all that mythological and crazy stuff, I'm saying "I don't know, it could be true". It doesn't feel right, and being unsure about delusions can lead to more delusions. To see the problem, imagine being unsure about something which is generally recognized as a delusion: the idea that there are satellites which read your thoughts and put thoughts in your head. This is kind of like the idea of God hearing your prayers and providing guidance.

I don't deny that religion can be a useful psychological tool. I don't deny that it can offer moral and ethical guidance. However, this doesn't mean that religion is fundamentally true, and I don't think that it's necessary for these purposes.

Thursday, September 03, 2009

In Vista, the "Previous Versions" tab requires administrative shares

No matter what I did, the "Previous Versions" tab for every file said "There are no previous versions available". System Restore was turned on, and both the GUI and vssadmin said that there were restore points. I was able to access old versions of files using syntax like "\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\config.sys". I was even able to access old versions via the "Previous Versions" tab when I accessed files via shared folders (eg. "\\computername\public").

The solution was enabling administrative shares (such as C$). In the past I set the dword at "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanServer\Parameters\AutoShareWks" to 0, which disabled them. I simply deleted that registry entry and restarted. (Note that even though Vista is a workstation OS, the registry entry is under LanmanServer.)

I wasted way too much time on this. I hate when something fails and there is no indication what went wrong. (I imagine something was trying to connect to C$ and it was failing, but that error was never reported.) This is actually my main complaint about Windows.

All this also applies to Windows 7.

Wednesday, September 02, 2009

JMicron JMB36X vs. Maxtor 92040U6

While backing up a partition to a Maxtor 92040U6 IDE (PATA) drive, Linux occasionally tells me stuff like:
ata9.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
ata9.00: cmd ca/00:00:ff:02:c9/00:00:00:00:00/e0 tag 0 dma 131072 out
res 40/00:03:00:00:08/00:00:00:00:00/b0 Emask 0x4 (timeout)
ata9:00: status: { DRDY }
ata9: soft resetting link
ata9:00: configured for UDMA/66
ata9:01: configured for UDMA/33
So, there a "write DMA" command timed out and the drive is ready. I'm not sure what else one can learn from that. I wonder what's at fault. The motherboard is Gigabyte GA-P35-DS3R. The PATA port is handled by a JMicron JMB36X chip, and the hard drive is a 10 year old Maxtor 92040U6 drive with MA540RR0 firmware. I've in the past I've had problems with the Memorex 3202 3292 PATA DVD+-RW drive which make me suspect the JMB36X. However, I also suspect the hard drive.

I'm curious because Windows 98 SE used to lock up when I was using the drive, and when I tried Windows 7, it would occasionally hang for a while with the hard drive light lit. In both cases there were no error messages, so I couldn't be sure what was happening.

If Windows 7 doesn't log error messages when there is an ATA timeout on a hard drive, then the people who wrote the ATA driver are idiots. Meanwhile, Firefox fails to properly display the Linux source file which produced the error message, and searching through a lot of text in Internet Explorer 8.0 is insanely slow, as if some evil genius invented a search algorithm that's even slower than a totally dumb algorithm. Sometimes, software sucks way too much. But hey, in this case at least it gives me something to do during the backup, and I don't have to routinely use PATA and deal with these errors.

Do all OSes still use a dumb LRU algorithm for caching?

I am backing up a partition from SystemRescueCd using dd and gzip. Occasionally I run ls to see the size of the output file. If I haven't used ls in a bit, the DVD drive spins up. So, it seems like Linux is using a dumb "least recently used" algorithm for caching, and the partition backup I/O is constantly removing ls from the cache. Do all operating systems still use such a dumb algorithm?

Friday, August 28, 2009

Connect to WebDAV folders from the command line to avoid a Vista bug

Microsoft's WebDAV implementation has been very buggy. One issue is that Vista cannot connect to a WebDAV folder if WebDAV is not supported in the server's root. That was supposedly fixed with KB942392, which was supposedly included in SP2. With SP2, if I attempt to connect via the "Connect to a Web site that you can use to store your documents and pictures" feature, that behaviour persists. I can successfully connect from the command line (using something like"net use r: http://servername:portnumber/foldername").

Thursday, August 27, 2009

Why do network applications still fail to handle sleep?

If I put a computer to sleep and then wake it, network-related applications generally try to pretend it didn't happen and then deal with the consequences. For example:
  • Thunderbird 2.x locks up for a while when I try to check my mail, and then starts working again.
  • Miranda IM shows a bunch of pointless alerts as if I lost network connectivity. These come from the KeepStatus add-on, which actually supports "Reconnect on APM resume".
  • Windows Live Messenger also acts as if I lost connectivity, waits a while to reconnect and then sometimes reconnects improperly, requiring another reconnect.
  • Putty loses the connection if the other side tried to send any data while the computer was sleeping. However, when the other side didn't try to send data an ssh connection can survive sleep. In this particular case, it might make sense to not add special suspend handling.
Sleep has been around for a long time. In Windows, the WM_POWERBROADCAST message was introduced in Windows 2000. Why not handle it and make the experience better for the user?

Wednesday, August 26, 2009

How I stopped hating Microsoft and concluded that Apple is worse

When I first started using MS-DOS, I didn't know any better. Yes, DOS was ridiculously primitive, even compared to operating systems which were developed decades before. However, I did not know about those operating systems at the time.

I started to hate Microsoft when I started using Windows in the 3.x days. Windows provided some appealing possibilities, but unfortunately it was an unstable piece of garbage. If it was an alpha release, I might have been impressed, but Microsoft was pretending that Windows was a finished product.

Eventually, Linux rescued me from Microsoft software. It was so much better that for a long time I didn't look back. When I got a new computer with Windows 95, it sucked so much that I laughed at it before reformatting and installing Linux. Meanwhile, Microsoft's alleged evil anti-competitive practises were in the news, further reinforcing my negative attitudes about Microsoft.

What started to change my attitudes was Windows NT 4.0 with SP6a. Much to my surprise, it seemed like Microsoft could actually create somewhat decent software. Instead of crashing on a daily basis, it only crashed about once a month. That could be bad on a server, but it was acceptable on a workstation. Later releases in the Windows NT family were even better, and soon I noticed that Windows only crashed due to bad drivers or defective hardware.

Windows opened many possibilities because so much software was available for it and practically all available hardware was supported. Microsoft truly deserved its "Where do you want to go today?" marketing slogan. In Linux I would often run into walls, such as not being able to send files or have voice chats via instant messaging and not being able to play some media. Meanwhile, drivers started to get worse in Linux. Often, devices would be supported but the drivers would only support a subset of the features and not work reliably. For example, I had to make changes to the sound driver to even get it to see my card, and then about half the time it would play beeping instead of sound, and graphics drivers didn't support all available acceleration. The Windows GUI also seemed more efficient than any Linux GUI. Simple drag and drop often accomplished what took many more steps in Linux. Sometimes, Unix command line tools were even more efficient, but that was not a problem because like so much other software, they were also available on Windows.

Meanwhile, it started to seem like Microsoft was being unfairly picked on by others. For example, the idea that the browser is part of the OS may seem ridiculous, but imagine getting a computer without a browser. With a browser, you can download or purchase practically any program. So, for example, if Windows came without other features (eg. image viewing, media playback, disc burning, calculator, defragmentation, etc.), one could easily obtain those. However, without a browser it's difficult to obtain anything. You would have to install from a disc, download on another computer or maybe download via FTP. So, Internet Explorer is useful even if the first thing you do with it is download Firefox. Also, use of HTML in the operating system seems like a sensible design choice, and that does actually make parts of the browser into parts of the OS.

I also started to notice another villain: Apple. While people were talking about how Microsoft would use a trusted platform module for all kinds of sinister things, Apple was the company that actually started doing some things. The iPhone and their recent iPods use code signing in an attempt to prevent running of modified or third party firmware, and OS X uses it for copy protection. Apple even tries to prevent iPods from syncing with third party software. They also use the legal system. Apple is trying to make iPhone jailbreaking illegal and they even go after enthusiastic fans who excitedly shared information about upcoming products!

While Microsoft's deals with PC makers were undergoing scrutiny, Apple was requiring that OS X run on Apple hardware. Yes, it can run on a variety of PCs, and if you carefully select compatible components it can run very well. However, Apple says that is illegal, even if you have a valid OS X license!

Finally, I feel uneasy about the whole Apple philosophy. Their slogan used to be Think Different, but reality makes that seem like doublespeak. Apple seems to design a very specific user experience, and to benefit from their design the user seems to have to conform to it. I very much prefer freedom. Apple actually rejects iPhone applications which don't conform to their ideals. For example, they didn't let Google release a Google Latitude application, because they feel it would be confused with the map application on the iPhone, and they routinely reject applications which duplicate some functionality that is already found on the iPhone. Because of all this, I feel that it's best to describe Apple's recent products as shiny prisons. (The term is not my idea; I want to thank the person that invented it.) Yes, their shiny prisons can be give a good user experience, but getting to that point seems almost like joining a cult.

Meanwhile, my only significant concern about Microsoft is their battle against open source. This seems like a very major evil, but even there it seems like Microsoft is changing and becoming better. It's important to consider the current situation, and not base conclusions on the past and on old news and commentary.

Monday, August 24, 2009

Playing SHOUTcast in Windows Media Player

Windows Media Player can play SHOUTcast streams without any additional software. You can save the PLS file, get a stream URL from it, and then "File -> Open URL..." (Ctrl+U) in WMP. To automate the process, install Open PLS in WMP. Then it's possible to click on a "Tune In!" button and automatically start playing the station. WMP can even show song names!

Saturday, August 22, 2009

The red Four O'Clocks seem to like the cold

The red Four O'Clocks always started opening later than the others, and they didn't even fully open in the middle of the night. Today and tonight are especially cold, and they've finally fully opened. Under incandescent light they seem red:

but white LED and strobe light bring out a magenta star:

A near-UV LED does not do anything interesting.

Monday, August 17, 2009

Smartmontools now supports some common USB to ATA bridge chips

External hard drives which connect via USB often do not offer a standard way to access S.M.A.R.T. to assess their health. Fortunately, some USB to ATA bridge chips at least have a proprietary method that can work, and smartmontools just got support for some common chips. The support came after the 5.38 release which is currently available, so I got smartmontools source via SVN and compiled for mingw32 from cygwin. Then I ran smartctl as administrator, and used the "-d usbcypress" option. I was able to get S.M.A.R.T info from my Archos Jukebox Recorder v2, which uses an ISD300A1 and is doing fine.

For more info see USB device information and the list of supported devices on the smartmontools wiki.

Wednesday, August 12, 2009

Google Safe Browsing can be used to track users?

I was just looking at some HTTP requests using the TamperData extension for Firefox. There amongst the requests I wanted to look at was an unexpected request. It was an update request for Google Safe Browsing. In that request there was a long wrkey parameter. The server provides a shared secret key via HTTPS. Updates are then retrieved via ordinary HTTP, and the key can be used to verify that the update has not been tampered with. Unfortunately, the key can also be used to track individual users. Why couldn't they simply use HTTPS?

Four O'Clocks

This meteor "shower" makes seem like a bunch of trolls. However, I did see a few occasional meteors, and I have some neat fragrant night blooming plants I can sit next to.

Most of the plants in the picture are Mirabilis jalapa, commonly known as Four O'Clock, Marvel of Peru. When I went swimming on Ošljak, I remember seeing plants called "bonašere", a name derived from the Italian phrase "buona sera" meaning "good evening". When I arrived the flowers would be closed, but when going back to the ferry they would be open and large bumblebees would be pollinating them. When I saw seedpacks showing simillar flowers and the name "Four O'Clock" I thought I found the same plant and I had to try growing them. At first, the seeds failed to germinate, possibly because it was too cold. Then I tried again, with a 33¢ seed packet from Dollarama. Those germinated and they grew into these large plants here. Now they're starting to bloom. I'm not sure if they're exactly the same as the "bonašere" I remember, but they're certainly similar and I remember the smell.

Thursday, August 06, 2009

Windows is so funny

I just updated my Sysinternals utilities and I was looking around in Process Explorer. SYSTEM is running a web server on port 2869 (icslap), apparently for UPnP. Windows is so funny.

Sunday, August 02, 2009

When is shutdown not really shutdown

I went away for a day and I shut down the power to my computer and router by turning off the UPS. When I powered them back on just over 24 hours later, Vista told me "Network cable unplugged" and corresponding lights on the Gigabyte GA-P35-DS3R motherboard and the router were off. I tried restarting and shutting down the computer, I tried reinstalling the RTL8168 drivers, and I tried several cables. Nothing helped. I was beginning to think there was a hardware failure. The only hopeful sign was that the Realtek diagnostic said all tests passed and it was able to measure cable length.

Then I realized that off was not truly off for the network card, because the lights can be lit even when the computer is off. So, I powered down the computer via the switch on the back of the power supply. Then I waited a bit to be sure that the standby power capacitors discharge. When I powered up again, everything worked.

I wonder if this has anything to do with the latest F13 (2009/06/19) BIOS.

Wednesday, July 29, 2009

A bucketful of water on the floor

Before yesterday, it seemed reasonable to assume that a bucket can support the weight of a bucketful of water. I never even thought about it. Then this happened:

The design defies common sense. It even doesn't make sense when trying to use less plastic, because everything other than the ends of the handle and the hinges seems robust.

Monday, July 27, 2009

On fandom

When I became a fan of someone/something on Facebook I just meant to say "that's really good". I didn't mean to subscribe to stuff; that part even got to be a bit annoying.

For example, with Infected Mushroom, I meant to say their music is great and highly recommended. I can also say that seeing them live is highly recommended if you get a chance. (The one time I saw them in Toronto is still a very memorable positive experience, even though the club was unreasonably packed.)

At first, seeing all the stuff they posted was annoying. It almost seemed like spam and it certainly seemed to decrease the signal to noise ratio. Yet the first article I read was interesting. It's a weird feeling, realizing that there can be more to something than I ordinarily experience. I'm not really sure what's the point of taking an interest in more than just their music but it certainly feels worthwhile.

Saturday, July 25, 2009

So, I have a WiFi router which runs Linux...

For a while now I was interested in getting a WiFi router with USB ports and ability to run third-party Linux-based firmware. Theoretically such a device can be very useful. Besides the obvious routing and WiFi functionality, it can also function as a low power always on computer running Linux. The possibilities seem endless. They include:
  • web server, with CGI, PHP, etc.
  • file server on the LAN
  • handling downloads
  • using an external display to show information from the Internet (such as e-mail notification, the weather forecast, RSS feeds and messages left via the web server)
  • webcam server
  • playing Internet radio
  • doing things via the serial console
I decided on the Asus routers, because they seem to have good support from third party firmware, they have USB 2.0 ports, and they have a decent amount of RAM and flash. At first I couldn't decide between a WL-500G variant or a WL-500W. At first, the WL-500G seemed like a better choice. Pre-N didn't really seem necessary, and in any case the alternative firmwares I looked at didn't support it. Then I learned about Oleg's firmware, which supports pre-N, and I decided to get a WL-500W.

The initial experience with the WL-500W and Oleg's firmware was quite positive. Things simply worked. Configuration was simple and there was a nice repository of software which can be installed on an external drive.

However, I quickly learnt that doing all the things I initially imagined would be a lot of work. In many cases, it doesn't seem like the software is available, and I would have to do a lot of coding. For example, I'm not aware of any software which can use an external display in the way I envisioned. The closest thing seems to be LCDproc. Another example the lack of download manager software which can run as a daemon.

There were also some problems, even with things which should simply work:
  • Much to my surprise, the procedure for building a cross-development environment was simple, but GCC 3.2.3 is so buggy that it can't even bootstrap itself. There, the solution seems to be -fno-schedule-insns2, but I would still like fully functional GCC.
  • Oleg's firmware helpfully provides modules for using a USB-to-serial adapter, but that version of Linux has a serious bug which prevents the onlcr stty option from working properly. The solution was simple: use the pl2303.c and pl2303.h files from the latest version of the 2.4 Linux kernel.
  • My webcam was totally unsupported, and spca5xx failed to build correctly. The binaries I found didn't support my webcam. I found a patch, applied it to the latest compatible version, and it worked. It even allowed me to use my Dakota "single use" digital camera as a webcam. The Asus webcam software didn't work properly with either, and it seems like an kludge, but fortunately, other applications are available, and w3cam works.
So, now I'm building up the capabilities. I even ported the client software for the LED sign I built from Windows to Linux. The main thing that remains is to tying stuff together in a way that's useful and beneficial in a long-term way. In the meantime, the best thing I've done is using my HP Portable Plus as a serial terminal for accessing Google Talk via mcabber.

Sunday, July 19, 2009

Fix for Dell Inspiron 6400 audio glitches

Since installing Vista on my Dell Inspiron 6400 laptop I've had problems with sound interruptions. They ranged from short clicks and pops to significant interruptions approaching a second in length. Disabling WiFi made them go away, so I assumed it was some conflict between the Dell 1500 (BCM4328) Draft 802.11n WiFi card and Sigmatel STAC 92XX C-Major HD Audio.

At one point I updated the WiFi driver and the sound interruptions went away once I connected to an 802.11g network. This was pretty good. If I didn't need the WiFi card I could disable it, and if I needed it, I would connect. However, when I bought a 802.11n router, the interruptions started happening a lot, even when I'm connected. The solution again was updating to the latest drivers, although that's not straightforward for reasons I'll explain later.

This time, I found a very useful tool: the DPC latency checker. I highly recommend it if you're experiencing audio glitches. Looking at the graph it produces is much faster and easier than listening for glitches. Here's what I saw:

When I disabled WiFi, the latency went back into the green. This showed me that it's entirely the WiFi driver's fault. Yes, updating audio drivers had helped, but I shouldn't expect audio drivers to be able to cope with this.

With some further online research, I found that people running Windows on Macbooks were having the same problems, and the driver fixed it. They had a slightly different BCM43xx chip, but I thought the same driver might support my chip. So, I searched Dell's support pages for the version number, downloaded the latest file and installed it. Here's what dpclat.exe showed me:

Yeah, that's not ideal, but it's a big improvement. More importantly, the audio interruptions are gone!

This would all have been much easier if Dell helped me find the latest drivers. It seems that soon after they stop selling a model, they stop saying that their drivers support that model. So, soon after I got my laptop, the drivers which support the Dell 1500 WiFi card stopped saying that they support my laptop. It gets worse. Soon, drivers stopped saying that they even support the Dell 1500 WiFi card. Dell claims that the driver I'm using is for various other wireless cards and for another laptop. It actually seems to be a universal Broadcom driver.

Friday, July 17, 2009

Proper packing of parcels

It seems to me that when packing stuff for shipping, the stuff should be in the centre of the box, and it should be surrounded by packing material. Once upon a time, I remember stuff arriving this way.

DirectCanada just puts stuff in the box, against the sides, and then fills the remaining space with packing material. This leaves product boxes resting against the outer box. In those locations, impacts are transferred directly to product boxes. Because of that, I've seen damage to product boxes. Fortunately, product boxes generally have padding and space inside, and so I didn't receive any damaged products.

I just got my first order from NewEgg Canada, and they did the same thing. Is this way of packing the norm now?

I guess it might not matter because product boxes protect the products. Things are also probably less fragile than I assume. For example this EVGA 8600GT video card was totally loose in its own box and able to rattle around. I thought that would break solder connections, but the card still works perfectly over two and a half years later.

I shouldn't single out Facebook invites

Shortly after I posted about how Facebook invites are spam, Yaari and LinkedIn reminded me that they do the same thing. Isn't capitalism fun?

I opted out of Yaari, because it's like a virus. The LinkedIn invite didn't even have a decline link, so I accepted it. I filled all the fields with made up information and connected the account to a temporary disposable e-mail address. (GuerillaMail is nice.) That was fun. I'll probably do it in the future if a site re-sends invites and I have some free time. Maybe I should also post the username and password on BugMeNot or here. That could make the accounts into a collaborative art project.

Friday, July 10, 2009

Facebook invite e-mail is spam

I have a Facebook account which is associated with one e-mail address. A friend sent an invite to another e-mail address. Since then I keep receiving the invite again and again.

Last time I added the second e-mail address to my Facebook account settings. When I did that I got a weird e-mail telling me that the e-mail address was removed from my account but I can still use it. However, the e-mail address is still in the settings, and if I search for it I find myself on Facebook. Facebook then sent another invite to that address as if I don't have an account.

The worst part is the content of the e-mail itself. It shows the person who invited me and "Other people you may know on Facebook". The name of each person is a link. However, those links are useless. If I am logged in, they take me to my Facebook home page. If I am not logged in, they take me to a page where I can start creating a Facebook account. There's no way to get information about the people listed in the e-mail. To add the friend who sent the invite, I had to search for him by name. Looking at the links for various people, I see that they're all identical and they are the same as the "sign up for Facebook" link at the bottom. Because of that it doesn't matter which link you click; all the people listed are basically being used as advertisements for Facebook.

Besides creating a Facebook account, the only thing I can do with the invites is ask Facebook to stop sending e-mail to that address. There is no way to reject one particular invite without preventing all future invites. I suspect that this "unsubscribe" option is designed to stop people from using it.

So, yes, it kind of looks like a genuine e-mail, but the way it's deceptive and repetitive makes it spam. I don't know what to do about this. I don't expect Facebook to listen to my complaint, complaining to their ISP(s) would be silly. It's too bad that deleting my account isn't an option because of so many other people who use Facebook. (It is to social networking what Windows is to operating systems.)

Wednesday, July 08, 2009

Simple and free FLV to AVI conversion in Windows

Both FLV and AVI are container formats. That means they merely wrap the audio and video data into a file. The data can be extracted from one file and put in another. Here's how to do it.

The program I use is VirtualDub. It is a free basic video editing and video capture application. To get it to open an FLV file, put the FLV Input Plugin (FLVInputDriver.vdplugin) into the VirtualDub plugins directory. With the plugin, FLV files may be opened by dragging them to VirtualDub or via the "File->Open video file..." dialog box. However, VirtualDub may still refuse to open your file, because FLV files often use video codecs which are not supported by default in Windows. I recommend FFmpeg, in particular ffdshow tryouts. When installing ffdshow tryouts, make sure you install the VFW interface. Afterwards you need to run the ffdshow "VFW configuration" (not "Video decoder configuration") and on the decoder tab enable the codecs you need. FLV can contain video in VP6F, FLV1, H.263, H.264 and possibly other formats.

When all this is done, converting FLV to AVI is simple. Open the FLV file in VirtualDub, in the Video menu select "Direct stream copy", make sure that's also selected in the Audio menu, and in the File menu select "Save as AVI...".

Note that the resulting AVI files still use video codecs which aren't supported by default in Windows. VirtualDub can also re-encode the video into a more popular codec. I recommend Xvid, which isn't supported by default but is a de-facto standard.

Also note that AVI is just another proprietary container format. Only convert videos to AVI if you really need to. There are many ways to play FLV files, and they can even be played in most DirectShow applications, like Windows Media Player.

Wednesday, July 01, 2009

Evening primrose

Here is some evening primrose, in particular, Oenothera biennis. It has nice yellow flowers, which open late in the evening, close early next morning and then wilt. New flowers open every evening. In the photo you see tonight's flowers, the remains of last night's flowers and many buds preparing for upcoming nights.

Sunday, June 28, 2009

Why I don't value American culture

A society should support and improve people's lives. Capitalism focuses on something else: supply and demand and profit. The problem is that profit or demand for something does not mean that it is a positive contribution.

Drugs are the easiest example. They are in demand but most people feel that at least some drugs make a negative contribution. They're not the only example however. There's also unhealthy food, television, video games and more.

The main counter-argument is personal responsibility and in particular the idea that if someone makes bad choices, that is their fault. However, things are not that simple. From one point of view people make decisions from their own free will, but from another point of view people may be influenced in various ways. For example, consider the amount of money being spent on advertising. That money is spent because it is often a worthwhile investment; it changes people's behaviour. For another example consider food. It's possible to carefully optimize food to increase its appeal to people, but that doesn't have to make food healthier.

America obviously isn't the only capitalist country, but it seems to be the one that's most involved in this destructive cycle of recklessly increasing demand to produce profit. For example you can see what happens when unhealthy food is optimized for appeal, and when advances in video games make them so appealing and available that children spend more time playing video games and less time playing outside. You can also compare BBC to American television and food in other countries with US food.

When the government tries to fix the problem via laws, that can fail and just cause more pain and suffering. The problem is that laws are used as a crude tool which essentially amounts to ongoing terrorist attack. They say that if you do something bad, agents of the government can take your money, possessions and freedom. For example the US war on drugs hasn't worked out very well, and America has the highest incarceration rate in the world. Laws don't seem to be able to create a substitute for a healthy culture. For example, compare what US alcohol laws do with other countries which have a healthier culture surrounding alcohol.

The worst part may be how American culture is spreading throughout the world. Look at its icons: companies like Coca-Cola and McDonald's. That can't be good. The problem is that the main motivation to spread comes from companies who want more customers so they can increase demand and profit.

Culture has a sort of inertia, which is a double-edged sword. It means that old healthy patterns can persist, but it also means that when new unhealthy patterns form, they tend to persist. Because of inertia, culture has value. Positive patterns are an asset and negative patterns are a liability. People need to keep this in mind.

The main hopeful thing I see is that the same things which cause problems can also be used in a positive way. For example, maybe capitalism would work if sales involved the true value of objects: both their current value and their long-term value and/or cost. Also, an ability to effectively influence people can also be used to influence people to make healthier choices. Many things cause harm when overused or otherwise abused, but they still can have a constructive place in life if used intelligently.

The main obstacle I see is lack of awareness about the fundamental problem. Awareness seems focused on particular instances of the problem such as the mortgage crisis, obesity epidemic or messed up health system. People need to understand the underlying pattern which needs to be fixed.

How to copy Windows from a bad hard drive

If a hard drive starts going bad, and read errors and bad sectors start appearing, what do you do? It's best to have a recent backup, and if you don't, it's best to recover your files and settings and reinstall Windows on a new hard drive. However, if there aren't too many bad sectors, it's possible to copy Windows from an a bad hard drive to a good one. Here's what I did.

First, I considered the requirements. I did not want to run chkdsk or otherwise attempt to fix things on the bad drive, because that could make things worse. I wanted to transfer the entire filesystem, not copy individual files. I wanted to know which files have read errors, so I could see the extent of damage and then either replace individual files or conclude that the situation is hopeless and reinstall. Finally, I wanted the process to be reasonably fast and automated.

Disk cloning software seems like the obvious choice. Unfortunately error recovery and logging features are lacking. After some research it seemed that no disk cloning program will create a log of files with errors. The only promising program was DiyDataRecovery Diskpatch, but it was ridiculously slow.

I decided on another approach: ddrescue. I downloaded the Ubuntu Rescue Remix, booted it and ran ddrescue, putting the log on a USB flash drive. The initial copy was fast and simple. Then, retries quickly read about half the bad sectors. I was left with 26 sectors which seemed totally unreadable. The ddrescue log gave offsets, which I divided by 512 in an automated way to give sector numbers.

Now I put the write protect jumper on the old hard drive and swapped the SCSI IDs. I wanted to be sure that the sector numbers I had remained valid. This was probably unnecessary and it complicated things. Windows started booting off the new drive, but then it mounted the partition from the old drive as C:, and I got a blue screen of death because of write protection. (Make sure you set up Windows to not automatically reboot after a BSOD. It's much easier to set that option in Windows than to edit the registry when Windows can't boot.) To fix the problem I used a disk editor to change the disk signature in the MBR of the new disk, and then I used Partition Saving to update which partition is mounted as C:.

Finally, I was able to boot Windows on the new drive. I used nfi.exe (from OEM Support Tools Phase 3 Service Release 2) to find which files those bad sectors corresponded to. The results were encouraging. Only one bad sector was in a real file, and Windows File Protection took care of that. The others were already marked as bad sectors or in unallocated space.

Since the filesystem on the new drive was directly copied from the old drive, it had sectors which were marked as bad. I needed to remove these. Again, I used Partition Saving. This was probably a mistake.

Now it was time to increase the size of the partition because the new drive is larger. Unfortunately, partition resizing programs refused to work. This wasted by far the most time of the whole operation. Eventually I tried ntfsresize, which told me I had hopelessly many bad sectors. (This is the sort of unprofessionalism found in open source software; it shouldn't be making an emotional comment. Commercial software handles the problem in a more professional way, such as cryptic error codes, generic error messages telling you to run chkdsk, or lockups.) Eventually I concluded that the bad sector file was corrupted in a way that chkdsk was unable to detect or fix. I suspect the problem was caused by Partition Saving, because Partition Magic started once before I reset the bad sector list and it always locked up after that.

Fixing the bad sector list was a problem. The /b option in Vista chkdsk didn't help. I read about a method using ntfstruncate, but a LiveCD with ntfstruncate was hard to find and ntfstruncate refused to work. Finally I recompiled ntfsresize, commenting out that check for hopelessly many bad sectors. (I used System Rescue CD. Besides rescue tools, it also has basic networking tools and gcc.) After a resize, chkdsk found some problems with the bad sector file, and after that everything was fine. Mission accomplished.

One interesting pattern here is that open source tools were far more useful than commercial software. For example, I used to think of Ghost and Partition Magic as important tools, but their poor error recovery and reporting made them useless here.

Thursday, June 25, 2009

A better way to play FLV files in Windows

I used to play FLV files using FLV Player. That worked fine, but I've now found a better way: FLV Splitter from Guliverkli2 and ffdshow tryouts. With these, I can play FLV files in practically any video player which supports DirectShow.

Monday, June 15, 2009

Tulip trees are interesting

Tulip trees are interesting. The flowers really are tulip-like from the outside, but they are greenish so, so they're not as spectacular and noticeable as the name implies. The inside of the flower is especially interesting. Here are some photos I took today:

Sunday, June 14, 2009

Friday, June 05, 2009

What I did about my Reddit addiction

Reddit is an endless source of information and discussion on practically any subject. I find it endlessly entertaining, highly addictive and almost entirely unproductive. I finally found the perfect solution: I blocked the Reddit cookie, and I don't log in anymore. Sure, I still go there, but I don't linger, and so I spend very little time there.

It's interesting that this worked but blocking Reddit via LeechBlock didn't. If I try to extrapolate from these experiences I come up with two relevant ideas or hypotheses:
  • Directly fighting myself over what I want or don't want to do is stupid.
  • Psychological addiction is not a craving for something, but a tendency toward a particular pattern of activity.

Friday, May 22, 2009

I think JMicron finally fixed their JMB36X drivers

After I upgraded from XP to Vista, I started having problems with my Memorex 3202 3292 16x dual layer DVD writer after resuming from sleep (S3, Standby to RAM). Sometimes my computer just hung for a bit when resuming. Other times my computer kept hanging for a fraction of a second every few seconds and it was impossible to access the drive. My workaround was simply to disable the JMB36X (GIGABYTE SATA2 RAID) device on my GA-P35-DS3R (rev. 1.0) motherboard, and only enable it when needed. I needed the drive rarely so, this wasn't too bad.

I just upgraded to R1.17.48.12 drivers direct from JMicron (I used, and it seems the problems are gone.

By the way: earlier while trying to solve this problem I flashed my drive with the NEC ND-3520 3.07 firmware, and I got PIE/PIF scanning support.

An old genuine 2GB SanDisk Ultra II SD card

Yesterday I picked up a 2 GB SanDisk Ultra II SD card, mainly for my small and cheap RCA RC3000A boombox. (Earlier, RCA support told me 2 GB is the maximum size supported.) I got the card from FactoryDirect. Here's what it looks like:

That's not like any of the images I found via Google, and according to online information, there are many counterfeit SanDisk Ultra II SD cards. I was starting to think it is counterfeit, but when I called SanDisk, I was told that the card is old but genuine.

Tuesday, May 19, 2009

Beware of Vista firewall environment variable substitution in paths

If I attempt to create a Vista firewall rule for an executable which is in my personal directory (under \Users\<username>\), the browse dialog substitutes environment variables like %APPDATA% or %USERPROFILE%. However, the firewall itself runs as a different user, so those variable substitutions are invalid. A full path must be used in these cases (eg. starting with C:\Users\<username>\).

BTW. The Blogger composer can't handle < and >. Instead I had to use &lt; and &gt;

A streaming success story

I watched the 2009 Eurovision Song Contest live from the official site. Octoshape P2P streaming worked very well, and image quality was good. It was legal, free and without commercials. It was even without the sometimes annoying commentators who are found on TV broadcasts of the contest. You can even watch it again from the official site. This is all very impressive. It shows what technology is capable of when people don't try to stop it from working.

BTW. If I could vote, I would have voted for Finland. However, I'm in Canada, so I can't vote and I couldn't even watch this on TV.

Monday, May 11, 2009

My love/hate relationship with Reddit

In one way, Reddit is the best site on the Internet. Practically any new an newly discovered interesting thing shows up there. It often shows up earlier than on other sites like Digg or in the news. Generally, if someone tells me about something, it's already on Reddit. Sometimes I've already seen it on Reddit.

In another way, Reddit is the worst site on the Internet, because it is horribly addictive. It is the most addictive thing I've discovered, and I don't mean just on the Internet. It's also for the most part useless. I used to think that learning about new things there could be helpful, but it's far more efficient to actively seek knowledge which is currently useful. For example, I saved many stories from Reddit thinking some of that would be interesting or useful later, but it never was.

Reddit also has another downside: alarmism. That is stupid because it is an unproductive fad which is disconnected from real risks. For example, high oil prices led to countless Peak Oil posts and then, when oil prices went down, suddenly it seems like everyone forgot about it. Recently, there has also been some alarmism about the Swine Flu. There are also regular "outrage posts" about various injustices suffered by individuals. In all these respects, Reddit seems worse than the mainstream media. It's interesting how something like this happens automatically. I guess the upvote/downvote paradigm is simillar to TV ratings, but there's probably more to it than that. I guess Reddit is getting better however.

Despite the downsides, I like Reddit. I think the main strength of the site is the sense of community which sometimes exists. Discussion of new and interesting things is not innovative. It's an old idea which has been around for a long time. It also has no staying power; it draws people as long as Reddit presents new and interesting things, and if another better source appeared, those people would move on. However, what goes on in some "self" posts and the occasional deeper thread of comments is different. There, I see signs of a Reddit community. That makes me think that Reddit might even be immune to the sort of decline that Digg experienced.

Friday, May 08, 2009

Is Windows ready for the desktop?

Some people doubt Linux is ready for the desktop. What about Windows? Is Windows ready?

The answer is a clear NO. The problem is that maintaining a computer running Windows is too much work. Sure, it's not a problem if you make it a hobby. However, if you just want things to work and be safe, it's totally unacceptable.

Microsoft updates used to be a pain. I remember when updating XP required checking the Windows Update web site and rebooting multiple times. Nowadays, keeping Vista up to date is quite easy. However, Windows isn't very useful without third party software.

Updates for third party software come from many sources, and there is no consistency. Sometimes one has to uninstall the application, download a new copy, and reinstall it. Other times it's best to not uninstall. Sometimes the application has a built-in update check. Sometimes the company making the application has an updater program. Often, updaters don't work. For example, Java or Flash Player updaters never seem to find new versions. Even when updaters work, they're still a waste of resources; there's no need to have a process running constantly to keep a program up to date.

For example I just installed a Winamp update. The installer is relatively user-friendly. It detects what is currently installed and by default doesn't install what you didn't want before. However, I still had to check to make sure that it isn't installing new crap. Then there are a bunch of dialog boxes to go through. That was all for a minor and insiginificant update.

I wish everything came from a central repository and updated itself automatically.

Monday, April 20, 2009

I just removed ads from my blog

Several times in the past I thought about removing ads from my blog. I always concluded that they might as well stay, because practically everything on the web has ads, and if anyone doesn't want to see them, it's easy to block them. (For example, if you use Firefox, you just need to install AdBlock Plus and use a filter subscription.) I finally decided to remove them. I don't feel that they're contributing to my blog and I want to make it clear that ad revenue is not my motive here.

I also decided to remove the Google search box. All browsers have a search bar, and so search boxes on pages are obsolete. Plus the one I had did not blend smoothly into my blog's colour scheme. I still think Google is the best search engine; try it and see.

Wednesday, February 25, 2009

AutoPager is great

A lot of content on the web is split into numbered pages. AutoPager is a Firefox extension which concatenates pages, so instead of clicking "next page" links I can simply scroll down. This is great, and it makes me realize how obsolete pages are on the web.

In the past, I've used CustomizeGoogle to "stream search result pages". That was pretty good, but it sometimes got stuck in a loop when I was logged in and it only supports this feature for Google. AutoPager supports it on many web sites, and I have not had any problems with it.

A few suggestions: The simple modal prompt is annoying, so turn that off. A green rectangle in the bottom right corner of the screen is much nicer than a "yes/no" popup. I generally set AutoPager to only autoload one page. Page loading is so fast, that by the time I'm done with that page, the next page will be loaded and so on.

Monday, February 23, 2009

Yaari is like a virus

I got an invite for Yaari, a social networking site which is being marketed to Indian youth. A search for Yaari has a very interesting blog post as its second result. Apparently, the registration procedure requires a Yahoo, Hotmail or Gmail address, and you have to give them your password so they can send invites to everybody in your address book! Then those invites are sent as if they are coming from the address you gave. If you continue reading that post, you'll see there's Yaari has more downsides. So, I'll be telling Gmail that Yaari invites are spam.

Sunday, February 08, 2009

The Vista shutdown screen (ie. Why is Microsoft insane?)

A friend who installed the Windows 7 beta was complaining about the shutdown screen. It tells you that an application is preventing shutdown, but it prevents you from interacting with the application to do something about it. Instead, you can either kill the application or cancel the shutdown, interact with the application, and then shutdown again. What idiot added this feature?

Vista does the same thing. Fortunately, I'm not too familiar with it because due to standby to RAM and hibernate I rarely shutdown or restart.