I just got back from a rally on the steps of the Winnebago County Courthouse, organized by Rep. Gordon Hintz of Oshkosh. The rally was to protest Scott Walker's proposal to eliminate collective bargaining for state workers. Main theme: It's not about the money, it's about the disrespect Walker shows all working people when he takes away their right to have a say in their working conditions.
There's another rally in support of state workers ** 5PM Today (Thursday 2/17)** in Opera House Square, downtown Oshkosh.
Thursday, February 17, 2011
Sunday, February 6, 2011
SSD Saga continued
So I got my OCZ Vertex2 SSD some time ago, and I managed to get it running in AHCI mode on my existing Windows XP pc. However, I had not yet transferred my windows system partition from hdd to ssd. A good job for Super Bowl Sunday, as it mirrored the highs and lows, the moments of elation and crushing despair, that I would have experienced had I watched the game itself.
After many false starts, I arrived at this process:
1) I aligned the partition, and formatted the whole ssd drive as one partition.
2) I used Clonezilla to copy my C: drive partition on my hdd to the new empty partition on the ssd. I used the "device-device" (device to device) menu option, with the basic (not advanced) option.
So far, so good. Here's where the fun began. Naturally, after such a cloning operation (operating on partitions, not the whole disk), the master boot record on the SSD was not set up properly to boot into windows.
First, I unplugged the hdd, so the ssd would show up as C: (and so I wouldn't fat-finger it into oblivion). I booted from the XP install disk into the Recovery Console, and used the three classic incantations:
This is supposed to repair the mbr, and make the drive bootable. No dice. I just received the message "Error loading operating system" on a black screen.
I turned to the old reliable, Ultimate Boot Cd (not UBCD4win this time)
It comes with several MBR tools. The one that worked for me was MBRWork (version 1.07b)
Here's how to use MBRWork, from here and here
Success! It boots, and is much much faster booting and loading programs. And, it's still aligned properly, according to this ssd alignment calculator.
However, if you're using XP, and thinking about transferring your existing install to an ssd, know that it is not an easy or straightforward operation. Newer versions of windows are apparently much smarter about the way they handle ssds.
After many false starts, I arrived at this process:
1) I aligned the partition, and formatted the whole ssd drive as one partition.
2) I used Clonezilla to copy my C: drive partition on my hdd to the new empty partition on the ssd. I used the "device-device" (device to device) menu option, with the basic (not advanced) option.
So far, so good. Here's where the fun began. Naturally, after such a cloning operation (operating on partitions, not the whole disk), the master boot record on the SSD was not set up properly to boot into windows.
First, I unplugged the hdd, so the ssd would show up as C: (and so I wouldn't fat-finger it into oblivion). I booted from the XP install disk into the Recovery Console, and used the three classic incantations:
fixmbr
fixboot C:
bootcfg /rebuild
This is supposed to repair the mbr, and make the drive bootable. No dice. I just received the message "Error loading operating system" on a black screen.
I turned to the old reliable, Ultimate Boot Cd (not UBCD4win this time)
It comes with several MBR tools. The one that worked for me was MBRWork (version 1.07b)
Here's how to use MBRWork, from here and here
Steps to recover lost partitions
7> Change active hard drive. (ignore if you have only one hard drive)
1> Backup first track
4> Reset MBR to zero
3> Reset EMBR area to zero.
A> Recover MS Partitions (see fig 2)
5> Install standard MBR code
Reinstall your boot manager. (if used)
See explanations below..
Below view shows after 4> Reset MBR to zero. A> Recover MS Partitions has been
added to the list of options, also notice MBR Partition Informationis
now all zeros. There are no longer any partition boundaries, meaning the hard
drive is unbootable and you can't read any data. If you now try to use fdisk
or other utility to recreate the partitions, new file tables will mean all
your data will be inaccessible, except for data rescue efforts. MBRWork finds
the original partition boundaries and reconstructs them exactly as they were,
meaning your computer works again and the data is intact.
MBRWork Menu
1) Backup First Track This is your safety valve to put things back as they were
2) Restore First Track Appears as an option only after using 1)
3) Reset EMBR Clear extended partition area
4) Reset MBR Remove partitions
5) Install Std MBR Same as fdisk /mbr (removes any boot manager)
6) Set active partition Also can be done with fdisk
7) Change active HD
8) Only shows if DDO present Remove Dynamic Disk Overlay (i.e. EZDrive, Maxblast)
9) Capability Check Runs tests on your BIOS, makes no changes.
E) Exit
A) Recover partitions Appears only after running 3) (and/or 4)
Success! It boots, and is much much faster booting and loading programs. And, it's still aligned properly, according to this ssd alignment calculator.
However, if you're using XP, and thinking about transferring your existing install to an ssd, know that it is not an easy or straightforward operation. Newer versions of windows are apparently much smarter about the way they handle ssds.
Tuesday, January 18, 2011
Using the GNU tools for find and replace on Windows
There are many ways to do find and replace in multiple files on Windows. I use the familiar GNU find | grep | sed tools.
I use the GnuWin32 version of the unix utilities. I have used UnixUtils, but they are now outdated. The Automated gnuwin32 download tool downloads and manages the gnuwin32 utilities. Read the Readme in the getgnuwin32 distribution folder for instructions.
The use of GNU utilities in the windows command prompt environment is not without pitfalls. You use only double-quotes. There are problems with filenames containing spaces, and with path separators. We handle dodgy file names the same way we do on Linux, by passing around null-delimited lists of file names.
In this example, I'm replacing the
First I find all the html files. I put all the file names in to a temp file. Passing
Next, I use xargs to read in all those null-delimited file names, and run grep over them looking for the
Then, I use sed to replace all instances of
Now I check the results. This grep should now find nothing.
I use the GnuWin32 version of the unix utilities. I have used UnixUtils, but they are now outdated. The Automated gnuwin32 download tool downloads and manages the gnuwin32 utilities. Read the Readme in the getgnuwin32 distribution folder for instructions.
The use of GNU utilities in the windows command prompt environment is not without pitfalls. You use only double-quotes. There are problems with filenames containing spaces, and with path separators. We handle dodgy file names the same way we do on Linux, by passing around null-delimited lists of file names.
In this example, I'm replacing the
⁄ html character entity with the more common slash /. I have broken it down in to smaller steps, and I save the intermediate results to temp files.First I find all the html files. I put all the file names in to a temp file. Passing
-print0 separates the file names with null strings.
find "C:\The\windows\path to\my directory" -name "*.html" -type f -print0 > "C:\Temp\tmp.txt"
Next, I use xargs to read in all those null-delimited file names, and run grep over them looking for the
⁄ html character entity. I write out the names of files where grep found ⁄
xargs --null --arg-file="C:\Temp\tmp.txt" grep --null -l "⁄" > "C:\Temp\tmp2.txt"
Then, I use sed to replace all instances of
⁄ with /. Note that I have to eascape the & in the replacement.
xargs --null --arg-file="C:\Temp\tmp2.txt" sed -i -e"s/⁄/\//g"
Now I check the results. This grep should now find nothing.
xargs --null --arg-file="C:\Temp\tmp.txt" grep "⁄"
Friday, December 31, 2010
iTunes: How to share apps between different accounts on a single computer
I've got multiple family user accounts on a Windows XP computer. I have my iTunes library set up the way I want, and my son has his playlists set up in iTunes under his own Windows login. All good. We even share the same iTunes music library, thanks to clear instructions here
To complicate matters slightly, he's using my iTunes account.
To summarize:
2 windows accounts
1 iTunes account
shared iTunes media library
I sync the iPad when I'm signed in under my windows login
he syncs the iPod when he's signed in under his windows login
This sounds complicated, but it all works remarkably well. His playlists and ratings are blessedly separate from mine, yet we can pull from the same underlying pool of music. I can listen to his Weird Al, and he can (hopefully, someday) learn to appreciate Elvis Costello and Gillian Welch.
Now, one little problem was that the apps were not shared automatically the way the music was. I sync an iPad to mine, he an iPod. The apps I install, I can see in iTunes when I'm logged in to my PC as me. However, even though we are sharing the library across multiple PC accounts, the apps are not showing up in his iTunes.
Instead of redownloading, here's what to do to get the apps to appear in his iTunes:
Log in to windows under his account. Right-click on one app in the local iTunes Library, and choose "Show in Windows Explorer". This brings up an explorer window at "D:\Bla\Bla\iTunes\iTunes Music\Mobile Applications". This folder contains all the .ipa files that store the applications on the PC. Since we are sharing an iTunes library, this "Mobile Applications" folder contains all the apps I downloaded while I was logged in as me.
I dragged the relevant .ipa files from the explorer window over to iTunes, and it added those apps. Now I can see the apps from his Windows login, and I can install them onto the iPod as well as the iPad.
To complicate matters slightly, he's using my iTunes account.
To summarize:
2 windows accounts
1 iTunes account
shared iTunes media library
I sync the iPad when I'm signed in under my windows login
he syncs the iPod when he's signed in under his windows login
This sounds complicated, but it all works remarkably well. His playlists and ratings are blessedly separate from mine, yet we can pull from the same underlying pool of music. I can listen to his Weird Al, and he can (hopefully, someday) learn to appreciate Elvis Costello and Gillian Welch.
Now, one little problem was that the apps were not shared automatically the way the music was. I sync an iPad to mine, he an iPod. The apps I install, I can see in iTunes when I'm logged in to my PC as me. However, even though we are sharing the library across multiple PC accounts, the apps are not showing up in his iTunes.
Instead of redownloading, here's what to do to get the apps to appear in his iTunes:
Log in to windows under his account. Right-click on one app in the local iTunes Library, and choose "Show in Windows Explorer". This brings up an explorer window at "D:\Bla\Bla\iTunes\iTunes Music\Mobile Applications". This folder contains all the .ipa files that store the applications on the PC. Since we are sharing an iTunes library, this "Mobile Applications" folder contains all the apps I downloaded while I was logged in as me.
I dragged the relevant .ipa files from the explorer window over to iTunes, and it added those apps. Now I can see the apps from his Windows login, and I can install them onto the iPod as well as the iPad.
Thursday, November 18, 2010
How to switch Windows XP from IDE mode to AHCI mode.
Many recent motherboards include AHCI-capable SATA controllers. However, if you have an existing installation of Windows XP, you can not easily switch from IDE to AHCI mode.
If you are doing a fresh install of Windows XP, you can introduce the proper drivers with the old F6 method, or by slipstreaming the needed drivers on to you own custom install disk. However, for existing installations of XP, there's a catch-22.
You can't switch to AHCI mode in the BIOS - that causes a Stop Error (BSOD) at the start of the boot process. This is because the Windows bootloader loads the existing IDE driver, but the motherboard is presenting an AHCI interface.
Neither can you solve the problem by replacing the Windows driver first. The AHCI drivers won't install, since all Windows can see is an IDE controller.
Some vigorous googling revealed nothing more than some dubious and dated registry hacks, or the suggestion to do a Repair installation of XP.
I wasn't satisfied with any of those solutions. I thought, "Isn't this chicken-and-egg problem the kind of thing that Utility Boot CDs are supposed to solve?" Indeed. There is a little utility on the Ultimate Boot CD for Windows called Fix HDC, purported to "Fix the Hard Drive Controller when replacing your motherboard on an XP system" That sounds good to me.
Now, the Ultimate Boot CD for Windows (UBCD4Win) is a decidedly do-it-yourself affair. You build it yourself, based on your own copy of the Windows XP install disk (I used an nLite install disk, slipstreamed with SP3 and the right AHCI drivers, but a plain Windows XP install CD should work fine too, since UBCD4Win comes with a bunch of drivers). I hit a snag caused by multiple copies of cygwin1.dll on my computer, but this post helped me clear it up.
So, burn a UBCD4Win cd, and put it in the drive. Boot the computer, and go in to your BIOS to make some changes. First, make sure that the CD player is first in the boot order. Also, change your SATA controller from IDE mode to AHCI mode in the BIOS. Note that many motherboards have two SATA controllers, so make sure you are changing the right one. Mine has a six-port Intel controller, and a four-port controller from Gigabyte.
After a long boot process, UBCD4Win dumps you in to a bizarro-world version of Windows,with a zombie-colored, MS Serif Start menu. No matter, we didn't come here for the design. Under Start > Programs > Registry Utilities, you will find Fix HDC. Make sure you have changed your BIOS to AHCI mode beforehand, otherwise FixHDC will just install regular IDE drivers.
In the Start Menu, Fix HDC is a folder, containing two items. The first allows you to set which Windows installation you want to modify. The second runs the actual Fix HDC utility. It runs in a dos window, and prompts you to back up your installation and/or modify your storage drivers. I chose Modify. UBCD4Win comes with a comprehensive selection of drivers, so Fix HDC will likely find the right driver for your hardware.
If UBCD4Win does not have the right driver for your hardware, it may install a "close enough" driver that will at least allow you to boot into your hard-disk Windows in AHCI mode. Once there, you can upgrade the driver just as you would any other.
This post has a very clear explanation of which driver to use based on your motherboard.
Anyway, the changes made by Fix HDC worked.
If you are doing a fresh install of Windows XP, you can introduce the proper drivers with the old F6 method, or by slipstreaming the needed drivers on to you own custom install disk. However, for existing installations of XP, there's a catch-22.
You can't switch to AHCI mode in the BIOS - that causes a Stop Error (BSOD) at the start of the boot process. This is because the Windows bootloader loads the existing IDE driver, but the motherboard is presenting an AHCI interface.
Neither can you solve the problem by replacing the Windows driver first. The AHCI drivers won't install, since all Windows can see is an IDE controller.
Some vigorous googling revealed nothing more than some dubious and dated registry hacks, or the suggestion to do a Repair installation of XP.
I wasn't satisfied with any of those solutions. I thought, "Isn't this chicken-and-egg problem the kind of thing that Utility Boot CDs are supposed to solve?" Indeed. There is a little utility on the Ultimate Boot CD for Windows called Fix HDC, purported to "Fix the Hard Drive Controller when replacing your motherboard on an XP system" That sounds good to me.
Now, the Ultimate Boot CD for Windows (UBCD4Win) is a decidedly do-it-yourself affair. You build it yourself, based on your own copy of the Windows XP install disk (I used an nLite install disk, slipstreamed with SP3 and the right AHCI drivers, but a plain Windows XP install CD should work fine too, since UBCD4Win comes with a bunch of drivers). I hit a snag caused by multiple copies of cygwin1.dll on my computer, but this post helped me clear it up.
So, burn a UBCD4Win cd, and put it in the drive. Boot the computer, and go in to your BIOS to make some changes. First, make sure that the CD player is first in the boot order. Also, change your SATA controller from IDE mode to AHCI mode in the BIOS. Note that many motherboards have two SATA controllers, so make sure you are changing the right one. Mine has a six-port Intel controller, and a four-port controller from Gigabyte.
After a long boot process, UBCD4Win dumps you in to a bizarro-world version of Windows,with a zombie-colored, MS Serif Start menu. No matter, we didn't come here for the design. Under Start > Programs > Registry Utilities, you will find Fix HDC. Make sure you have changed your BIOS to AHCI mode beforehand, otherwise FixHDC will just install regular IDE drivers.
In the Start Menu, Fix HDC is a folder, containing two items. The first allows you to set which Windows installation you want to modify. The second runs the actual Fix HDC utility. It runs in a dos window, and prompts you to back up your installation and/or modify your storage drivers. I chose Modify. UBCD4Win comes with a comprehensive selection of drivers, so Fix HDC will likely find the right driver for your hardware.
If UBCD4Win does not have the right driver for your hardware, it may install a "close enough" driver that will at least allow you to boot into your hard-disk Windows in AHCI mode. Once there, you can upgrade the driver just as you would any other.
This post has a very clear explanation of which driver to use based on your motherboard.
Anyway, the changes made by Fix HDC worked.
Labels:
ahci,
controller,
drivers,
existing,
sata,
ssd,
ubcd4win,
upgrade,
windows xp
Tuesday, October 26, 2010
Ctrl-Enter in Thunderbird
Did you know that Ctrl-Enter in Thunderbird sends your email message immediately? If you do, you probably learned it the hard way, by sending a half-written email, like I just did. Awkward . . .
To get rid of this behavior, install the keyconfig extension. Once you have installed the extension and restarted Thunderbird, go to the Tools menu > Keyconfig. Choose "Send Now", and click the disable button.
If you installed keyconfig, but you can't find the "Send Now" option:
1) Open Thunderbird
2) Start composing a new message (in a new window)
3) In the main Thunderbird window, go to the Tools menu > Keyconfig
4) At the top of the Keyconfig window, there is a dropdown box, with one entry for each open Thunderbird window
for example:
- Inbox
- Write (no subject)
- Keyconfig
5) Choose the "Write . . ." window in the Keyconfig dropdown box
6) Send Now should now be listed in the Keyconfig listbox
7) Select Send Now, and click Disable
8) done!
To get rid of this behavior, install the keyconfig extension. Once you have installed the extension and restarted Thunderbird, go to the Tools menu > Keyconfig. Choose "Send Now", and click the disable button.
If you installed keyconfig, but you can't find the "Send Now" option:
1) Open Thunderbird
2) Start composing a new message (in a new window)
3) In the main Thunderbird window, go to the Tools menu > Keyconfig
4) At the top of the Keyconfig window, there is a dropdown box, with one entry for each open Thunderbird window
for example:
- Inbox
- Write (no subject)
- Keyconfig
5) Choose the "Write . . ." window in the Keyconfig dropdown box
6) Send Now should now be listed in the Keyconfig listbox
7) Select Send Now, and click Disable
8) done!
Tuesday, July 20, 2010
Nested list comprehensions in Python
Python's nested list comprehensions often hover on the edge between elegance and obfuscation.
I made some examples to show the order of evaluation, and the results of adding/removing the nested bracket symbols.
Thanks to Luka Marinko for his instructions for setting up syntax highlighting on Blogger.
I made some examples to show the order of evaluation, and the results of adding/removing the nested bracket symbols.
matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
]
# This flattens and transposes the matrix.
c = [row[i] for i in range(len(matrix)) for row in matrix]
d = []
for i in range(len(matrix)):
for row in matrix:
d.append(row[i])
assert(c == d)
print c # [1, 4, 7, 2, 5, 8, 3, 6, 9]
# This flattens the matrix.
e = [row[i] for row in matrix for i in range(len(matrix))]
f = []
for row in matrix:
for i in range(len(matrix)):
f.append(row[i])
assert(e == f)
print e # [1, 2, 3, 4, 5, 6, 7, 8, 9]
# This transposes the matrix.
a = [[row[i] for row in matrix] for i in range(len(matrix))]
b1 = []
for i in range(len(matrix)):
b2 = []
for row in matrix:
b2.append(row[i])
b1.append(b2)
assert(a == b1)
print a # [[1, 4, 7], [2, 5, 8], [3, 6, 9]]
# This returns the matrix unchanged.
g = [[row[i] for i in range(len(matrix))] for row in matrix]
h1 = []
for row in matrix:
h2 = []
for i in range(len(matrix)):
h2.append(row[i])
h1.append(h2)
assert(g == h1)
assert(g == matrix)
print g # [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
# This oddity builds up a nested list from simple lists.
k = [zip(j,j) for j in [range(i) for i in range(4)]]
m1 = []
for i in range(4):
m1.append(range(i))
m2 = []
for j in m1:
m2.append(zip(j,j))
assert(k == m2)
print k # [[], [(0, 0)], [(0, 0), (1, 1)], [(0, 0), (1, 1), (2, 2)]]
Thanks to Luka Marinko for his instructions for setting up syntax highlighting on Blogger.
Labels:
example,
list comprehension,
nested list comprehension,
python
Subscribe to:
Posts (Atom)