Monday, 20 April 2009

LaCie external harddrive clicks and ticks, but does not work

A while ago I bought this LaCie 500Gb external hard drive and I was rather satisfied with it. With the occasion of the horrible Easter holidays I finally turned off my computer (after weeks of it working continuously). So imagine my dismay when I came back home, turned the LaCie on, then the computer and all I had to show for it was an USB mass storage controller error in the Hardware Manager.

After trying a few things (and noticing that the hard drive would not actually turn on, instead a tick-tock sound was heard from inside) I decided to open up the drive box, proudly written on it "Designed by F. A. Porsche". Well, fuck you, Porsche! I had to almost destroy the box to open it, then the insides had so many "one installation, no after service" components that I felt like walking on broken glass.

Anyway, inside the LaCie there is a small USB controller and an SATA Seagate Barracuda 7200.10 hard drive. I installed the hard drive as an internal drive and... nothing! Windows XP blue screen 0x0000007B. The computer wouldn't even recognize the drive in the boot up screen.

Well, after looking for drivers and stuff like that, I was resolved that the hard drive was defective and all my music, movies and books were lost. But shutting the computer down I noticed that the drive was actually spinning in its internal setup configuration. So, desperately, I tried to use the power from the internal computer power source and the rest of the drive in its USB setup... and IT WORKED!

Now I am going to buy another drive and get all data from this one, but still, if you are desperate that your USB hard drive is lost, try to open it up and power the internal drive with a normal computer power chord.

As for why the internal drive did not work directly on the computer? I have almost no idea. The Seagate site says clearly that SATA drives do not require drivers, but the various SATA controllers do! Since I already have a SATA internal drive, I think that that is not the issue. Rather, the people at LaCie used another drive firmware! The Seagate drive also provides with some downloadable firmware so it is clearly possible. As a completely desperate option to recover your lost data, I guess trying to rewrite the hard drive firmware could work, but I don't recommend it and I wonder how it is possible, considering it wouldn't allow me to boot Windows.

I hope this helps somebody. And Happy Easter everybody!

Update September 2012: after three years and a half, the drive (powered by both USB and internal computer power) started to develop bad sectors. It still works, mind you, I just removed it because I didn't need it as much. Thus ends the saga of the mutant harddrive in the computer that never sleeps and never dies [creepy music in the background] :)

Wednesday, 15 April 2009

XSD (XML Schema) Hierarchical Unique Contraint

While working on RegexConverter I've started learning things about XML. I disliked it before, but now... I loathe it completely. It feels like the XML people are from another planet and I have to twist my brain at straight angles just to understand what they meant.

One of the problems I met was "how to declare in an XML schema a unique constraint/index on the entire document when there are nested elements of the same type". In other words, something like this:
<regex>
<group index="1">
<group index="2">
</group>
<group index="3">
</group>
</group>


Bottom line:
  1. Use the declared namespace
  2. Declare the index in the root element
  3. Use the name of the nested element (in my case group) in the selector
  4. Use the one or more levels deep selector (.//)
  5. Use the declared namespace AGAIN.
.

Concrete example:
<xs:element name="regex" type="regexType">
<xs:unique name="uniqueIndex">
<xs:selector xpath="mstns:group|.//mstns:group"></xs:selector>
<xs:field xpath="@index"></xs:field>
</xs:unique>
</xs:element>


I tried to solve this for two hours only to find the solution was this idiotic. Neither one of "group","mstns:group","mstns:group|.//group" work. The only one is "mstns:group|.//mstns:group".

Grrrr...

Wednesday, 8 April 2009

RegexConverter on Github!

Update: two more days of work and a huge text file of regular expressions and I know a lot more about the syntax of .Net Regex than even MSDN :)
The third (Apr11) release of the library has a huge load of bug fixes and new features and it is now... [Tadaaaaa]... a stable version. At least I think of it that way :) Go download it.!

I've been working for two days on an idea. What can I do to make those long regular expressions that I always leave in my code more readable and easy to understand without having to compile automatons in your head?

I have first researched on Google regular expression converters. Nothing was even close to what I wanted. Also, on the more scientific side, people were talking a lot about BNFs, as a superset of regular expression syntax. I looked at BNF. Yes, it describes anything in a human readable form, it is used in RFCs but I hate it even more than XML! So XML it is. Most of the inspiration for the code came from this link: Regular expressions and regular grammars

I give you, RegexConverter. It is a library+demo that transforms a Regex into an XML and then back again. The demo application demonstrates (duh!) this by having two panes, one in which to write regex and the other in which to write XML. Changing one, also changes the other. It warns you of errors in both Regex, RegexConverter and then checks if what it got can be safely converted into your changed string!

Please tell me what you think. I believe it can be a real help in understanding regular expressions, some specific ones or regular expression syntax in general, whether one is a pro or a complete noob.

I've worked hard to design the library source in a way that is understandable, I also added comments everywhere. I tried to implement all the specifications of .NET regular expressions from the MSDN site so if you have a regex that is valid but can't be turned into XML or the conversion is not perfect, let me know.

The link is: RegexConverter on Github.

I will update this post with more science and links to my places of inspiration for this, so stay tuned.

RegexConverter Update: Ok, so I haven't updated this post much. Shame on me. I was reminded of this project when I got an email from the FamousWhy site which said RegexConverter "has been granted the Famous Software Award". I know it's probably an automatically generated message and went to many or all of the Codeplex people, but still: automated attention is still attention :)

Friday, 3 April 2009

Type names for nested classes

Just a small mention of a thing I've learned today: what is the FullName of a Type of a class that is nested into another?

Usually, you would use it inside Visual Studio as ParentClass.ChildClass, but if you ever want to use the full name of the ChildClass Type (as when declaring it in web.config) you have to separate them with the + (plus) sign.

So let's assume you have this MyHandler class in the MyNamespace namespace which has a nested class Configuration in it. In the code you do a
var conf = new MyNamespace.MyHandler.Configuration();
while when using the handler type name to declare it in web.config you do it like this:
type="MyNamespace.MyHandler+Configuration"
.

customErrors=Off not working!

First off, I have to say something about forums: stop copying content from one another, jerks!. I have been trying to find a solution for this problem and I found a zillion forum pages with the same "problems" and the same "solutions" again and again and again!

Much better! Now, I have been trying for an hour to understand why setting customErrors="Off" in the web.config of my ASP.Net application would not work. I tried just about anything, including the bloody forums. customErrors Off did not work!.

In the end I found one little comment for a StackOverflow question: set the retail setting in the machine.config file to "false"!! So, go to %WINDOWS%\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config and set retail to false!. Setting it to true means it will NEVER show you any useful debugging message.

Thursday, 2 April 2009

Wednesday, 1 April 2009

Internet Explorer 8 installation fails and then browser crashes. Solved by updating Sun's Java?!

Today Internet Explorer 8 appeared to me in the Automatic Updates list. I have been using IE8 for months now and so I was glad that the official release finally came out. So I downloaded and installed IE8.

The installation process has several steps. First is the removal of any previous version of IE, then a reboot, then several small steps of the setup program: Downloading IE8, Downloading IE8 updates, Installing IE8, Installing updates, Finishing installation. Well, for me, at the Installing updates step it threw an error that said the installation cannot complete because the station is shutting down, then my computer restarted.

I did have Internet Explorer available, though, so I tried a few pages. After the pages loaded, I was invariably getting an error and IE closed. "Internet Explorer has encountered a problem and needs to close. We are sorry for the inconvenience.". Well, so was I!

I was trying the installation of IE the third time now and suddenly a Java update traybar icon appeared. I updated Java, then I was amazed to see that IE was no longer crashing! So, my solution for Microsoft IE errors: update Sun Java! :)

Well, the Java update probably completed some steps that the installer failed to. But still :)

And interesting link I found regarding any IE error that causes the browser to excuse itself and leave is on Sandi's Site