Showing posts with label questions that bother everyone. Show all posts
Showing posts with label questions that bother everyone. Show all posts

C++ Streams & Typedefs: Be Charful

The C++ typedef keyword is indispensable in many situations, especially for writing portable low-level code. However, in some circumstances it can cause trouble, particularly when it comes to function overloading. Consider the following C++ template class:
template <typename T>
struct foobar
{
    foobar( const T foo ) : foo_( foo ) {}
    T foo_;
};
One might want to write a simple stream output operator to format the template class’ member values, e.g. for debugging purposes:
template <typename T>
ostream& operator<<( ostream& s, const foobar<T>& fb )
{
    return s << "foo: " << fb.foo_;
}
This seems reasonable. Now, let’s assume that this template is going to be used in a context where T will be one of several fixed-width integer types. These are usually typedefs from a header like stdint.h (for those that don’t mind including a C header) or boost/cstdint.hpp (to be a C++ purist). They are commonly named int64_t, int32_t, int16_t, and int8_t, where the X in intX_t specifies the number of bits used to represent the integer. There are also unsigned variants, but we’ll ignore those for this discussion.

Let’s now explore what happens when we initialize a foobar<intX_t> instance with its foo_ member set to a small integer and print it to standard output via our custom stream output operator:
cout << foobar<int64_t>( 42 ) << endl;
cout << foobar<int32_t>( 42 ) << endl;
cout << foobar<int16_t>( 42 ) << endl;
Each of these statements prints “foo: 42″, as expected. Great, everything works! But wait, there was one type that we didn’t test:
cout << foobar<int8_t>( 42 ) << endl; 
 This prints “foo: *” instead of “foo: 42″. This is probably not the expected result of printing the value of an int8_t. After all, it looks and feels just like all of the other intX_t types! What causes it to be printed differently from the other types? Let’s look at how the integer types might be defined for an x86 machine:
typedef long int int64_t;
typedef int int32_t;
typedef short int16_t;
typedef char int8_t;
The problem is that the only way to represent an integer with exactly 8 bits (and no more) is with a char (at least on the x86 architecture). While a char is an integer, it is also a… character. So, this trouble is caused by the fact that the char type is trying to be two things at once. A simple (but incorrect) approach to work around this is to overload1 the stream output operator for the int8_t type, and force it to be printed as a number:
// This is incorrect:
ostream& operator<<( ostream& s, const int8_t i )
{
return s << static_cast<int>( i );
}

The problem with this approach is that the int8_t typedef does not represent a unique type. The typedef keyword is named poorly; it does not introduce new types. Rather, it creates aliases for existing types. By overloading the stream output operator for the int8_t type, the char type’s operator is being overloaded as well. Since the standard library already defines a stream output operator for the char type, the above definition would violate the One Definition Rule and result in a compiler error. Even if it did compile, the results of redefining the way characters are printed would probably not be desirable.

An alternative (working) solution to the problem is to overload the output stream operator for the foobar<int8_t> type:

ostream& operator<<( ostream& s, const foobar<int8_t>& fb )
{
    return s << "foo: " << static_cast<int>( fb.foo_ );
}
This definition does not clash with any existing overloads from the standard library, and it effectively causes the int8_t to be printed as an integer. The downside is that it will cause unexpected behavior when a foobar<char> is printed, if the programmer intends char to represent a character. The only way to avoid this would be to define int8_t as a class instead of making it a typedef, and providing a well-behaved stream output operator for that class. The class’ arithmetic operators could be overloaded to make it look almost exactly like a POD integer, and it wouldn’t necessarily take up any extra memory. However, this solution is still not ideal, because classes behave differently than POD types in subtle ways (e.g. POD types are not initialized by default, but classes are).

If there’s anything to take away from this, it’s that the C++ char type is an odd beast to watch out for. Also, the name of the typedef operator could use some improvement…

To subscribe to the "Guy WhoSteals" feed, click here.
You can add yourself to the GuyWhoSteals fanpage on Facebook or follow GuyWhoSteals on Twitter.

How This Guy Discovered Four New Planets Without a Telescope


Peter Jalowiczor is a gas worker from South Yorkshire, England. He's also the discoverer of four giant exoplanets, according to the University of California's Lick-Carnegie Planet Search Team. But he's not an astronomer and he doesn't even have a telescope.

He worked for three years on the discovery, analyzing data made public by the university using his two home computers, spending hundreds of hours of his spare time in the task. Jalowiczor, who has two science degrees but no formal astronomy training, used a process called doppler spectroscopy or radial velocity measurement. As he explains it:
I look for faint changes in stars' behaviors that can only be caused by a planet or planets orbiting about them. Stars are incredibly far away and no telescope yet built can directly see their discs, let alone any planets going around them.
Astronomers therefore have to devise other indirect techniques of detection. If a planet orbits a star it causes a tiny wobble in the star's motion and this wobble reveals itself in the star's light. Special software works out the properties about the planet's orbit and precise measurements of the star taken over many years enable scientists to build up profiles of systems as planets are gradually revealed.
According to the Lick-Carnegie Planet Search Team, the gas worker is the co-discoverer of gas planets HD31253b, HD218566b, HD177830c and HD99492c, which is the closest of the four, 58 light years away. 

To subscribe to the "Guy WhoSteals" feed, click here.
Shamelessly stolen from: http://gizmodo.com/5723473/how-this-guy-discovered-four-new-planets-without-a-telescope
You can add yourself to the GuyWhoSteals fanpage on Facebook or follow GuyWhoSteals on Twitter.

Don't teach like you code

As programmers, how do we go about teaching people well?

After all, coding has many of the same traits as teaching. Underneath the fancy patterns and elegant frameworks, code is just a set of concrete instructions to do something. Even if one, seemingly obvious, detail is left out, you'll know soon enough. Code has an order too. You can't implement a concept before it's been defined yet, just like you couldn't teach someone how to multiply before they understand how to add.

But, good coding isn't like teaching at all. It promotes habits that are entirely counterproductive to the art of teaching. A really good programmer just might make for an awful teacher.

First, rarely do we code linearly. You don't start from the top and just work your way down to the end of the story. Along the way, a clear concept in your head turns into a half-truth. Part way through writing a method, you might decide you need to track things in an array. After a few minutes, you'll decide a hashtable works better. If coding against a platform is at all like talking to a student, you'd sound rather unsure of yourself.

Second, coding lets you cheat on the details. We compile our code not because we think we're done, but because we want to find out what we may have missed. You can usually bucket most compiler errors in the "I was just being lazy" category. A missed instantiation here, a data-type mismatch or non-returned value there. I'm a habitual compiler. A compiler is a lazy programmer's best friend. Ditto for unit tests, code-hinting and auto-completion.

All these niceties are great for programming. They give us softly padded walls to bounce our code off of. They let us focus on the hard stuff first and not worry too much about perfection in our code-speak. A good programming platform is simultaneously wiping our chin, correcting our grammar, and telling us what we really mean while we spew out semi-coherent lines of instruction. And, the faster and more efficient we are at coding, the more we rely on the platform to steer us in the right direction.

Teaching a newbie is entirely different. Every missed detail is a lost detail. You can't start your sentences expecting your student to finish them — at least not early on. And unlike a compiler, who invariably will forget your missteps once you correct them, people don't have as much luck separating the wrong details from the right. You may compile your code a dozen times before you finally get it right, but imagine correcting yourself twelve times before your teaching lesson finally makes sense.

You, my friend, make a terrible teacher.

How do you teach people well? It starts by knowing that what may make you a great programmer will not make you a great teacher.

To subscribe to the "Guy WhoSteals" feed, click here.
Stolen from: http://blog.wearemammoth.com/2010/12/dont-teach-like-you-code.html
You can add yourself to the GuyWhoSteals fanpage on Facebook or follow GuyWhoSteals on Twitter.

10 Things to Learn Next Year



It's almost the end of the year, which means that the usual flood of "Top 10", "Year in review" and other backward-looking articles are here.  Retrospectives can be a lot of fun and even occaisionally insightful, but in my opinion they are looking in the wrong direction.  So, in the spirit of looking forward to a new year, here's my top 10 list.  Not things that happened in 2010, but things I want to learn in 2011.  Some of these I have already started using but want to master, others are mysterious new toys that have grabbed my attention if not my time.

10.  HTML5.  The importance of HTML5 cannot be overstated, IMHO.  With support for the Canvas object, video, geolocation, etc, etc, HTML5 is already changing the web in surprising and innovative ways.  The best part?  It's not a new language.  All the tags I know and love are still there.  There is still a lot to learn, but I don't have to start from scratch.  In some ways (like the doctype), HTML5 is even simpler than earlier versions, a refreshing reversal of the usual cruft of complexity that builds up on a language over time.

9.  GroovyGroovy is one of a slew of new(ish) languages that run on the venerable and performant Java Virtual Machine.  Groovy borrows heavily from Java's own syntax, flattening out the learning curve for developers that already know Java.  So, it runs on the JVM, and it looks a lot like Java.  What's the big deal with Groovy?  Well, proper closures, for one.  A great console, for another.  One of the things I LOVE about coding in Python is that if I want to play around with some code I can just start up a Python console and go to work.  Java's edit -> compile -> debug cycle seems positively crippling by comparison.  Add in the fact that apps written in Groovy can leverage Java's gigantic library of existing components and you have a language that I have to add to my toolbox this year.  Oh, and don't forget Grails.  I've built a couple simple apps with it and I think I'm in love.

8.  The ins and outs of cross-platform mobile development.  Compared to the whole of computing, mobile applications are still in their infancy.  Without getting into the growing pains this market is going through (Apple's walled garden, Verizon Android crapware, etc), there is one big challenge as a developer.  What platforms do you support?  What language(s) do you develop in?  Is it worth it to build both Android and iOS apps?  Do you even have the resources to do so?  Companies like Appcelerator aim to make this easier by creating cross-platform dev tools for popular mobile device platforms.  I want to make my apps available to as broad an audience as possible without the headache of maintaining several codebases.  This is a space to watch.

7.  A NoSQL database.  Most of the platforms I work with rely on relational databases.  They work.  MySQL / Oracle ( the two I work with most frequently) are mature, stable and perform well enough when properly tuned.  But, like any tool, RDBMSs aren't the right solution for every problem.  They can be expensive to scale quickly, and frankly I don't always need a well defined schema.  Sometimes I just need a persistent store for some simple objects.  Now that CouchDB is available as a client-side DB for Android, I can see quite a few interesting applications for this technology.  If iOS support comes through then we have another choice for cross-platform data stores.

6.  Arduino.  What the heck is an embedded processor doing on a top 10 list for a web / mobile developer?  Well, the Arduino is simply one of the coolest things I have ever seen.  It's open source.  It's cheap.  It's easy to program.  It's capable of surprising feats.  I have an Arduino Mega sitting on my desk just begging for the right project.  I had originally intended to use it as the brains behind an automated bottling line for my homebrew, but decided that kegging was much more practical :-).  Right now it is hooked up to a 2 line LCD display and a couple of blinkenlights, just waiting for inspiration to strike.

5.  GIMP.  This is one of those tools that I already use constantly but wish I had a better handle on.  The GIMP is a great image editor for the price (free), and I use it all the time for creating iPhone buttons, logos, splash screens, etc.  If you just need to slice and dice some PNGs for the web it is a great option.  In the next year I want to hone my design skills and GIMP-fu.

4.  TropoTropo is a telephony platform that runs in the cloud.  If you want to add SMS or voice functionality to a web application, Tropo takes all the guesswork out.  They build the infrastructure and provide the APIs, you build the cool stuff on top of it in your choice of Ruby, Python, JavaScript, PHP or Groovy or your language of choice by calling their REST API.  Oh, and did I mention that it is free for developers?

3.  Django.  This is another one of those tools that I have worked with occasionally but haven't ever really mastered.  In particular I want to use Django running on the Google App Engine to build some simple scalable web services.  I haven't ever implemented a REST API in Django, but need to learn.

2.  Alfresco.  I use Alfresco constantly.  It's a big part of my day job and I have even written / contributed to a few open-source components that exist in the Alfresco ecosystem.  However, it's a huge product.  It provides so much functionality that I feel like I only know / use 10% of what it is capable of.  Maybe with another year of hard work I can bump that to 20%.

1.  Time Management.  As evidenced by the list above, I have more ambitions than time.  To get all of this done I will need to focus on what is, in my opinion, the single most important tool that any developer or engineer can learn.  This is one of those critical life skills that almost everybody has room to improve.  If I only get one thing done next year, this should be it.

So that's my list.  10 things that I want to focus on in 2011.  What are yours?

Check out the an anime project solely made through Free and Open Source software click here.
To subscribe to the "Guy WhoSteals" feed, click here.
You can add yourself to the GuyWhoSteals fanpage on Facebook or follow GuyWhoSteals on Twitter.

Solving Einstein’s Riddle using nondeterministic computing

If you ever read Structure and Interpretation of Computer Programs, you will recall learning about nondeterministic computing, which is a fancy name for backtracking techniques. In section 4.3.2, there are a couple of typical problems for which these techniques are appropriate, the first being the resolution of logic puzzles, and the second a minimal implementation of a natural language parser. Let’s focus on the former. Years ago I remember solving a fun riddle written by Albert Einstein -don’t fret, nothing related to physics-, which I will show below, in case it doesn’t ring a bell. But first of all, I encourage anyone to try to solve it using only its logic skills, since it is a very rewarding experience, especially when its creator declared that “98% of the world population would not be able to solve it”

The Riddle
  1. In a town, there are five houses, each painted with a different color.
  2. In every house leaves a person of different nationality.
  3. Each homeowner drink a different beverage, smokes a different brand of cigar, and owns a different type of pet.
The Question
Who owns the fishes?

Hints
  1. The Brit lives in a red house.
  2. The Swede keeps dogs as pets.
  3. The Dane drinks tea.
  4. The Green house is next to, and on the left of the White house.
  5. The owner of the Green house drinks coffee.
  6. The person who smokes Pall Mall rears birds.
  7. The owner of the Yellow house smokes Dunhill.
  8. The man living in the center house drinks milk.
  9. The Norwegian lives in the first house.
  10. The man who smokes Blends lives next to the one who keeps cats.
  11. The man who keeps horses lives next to the man who smokes Dunhill.
  12. The man who smokes Blue Master drinks beer.
  13. The German smokes Prince.
  14. The Norwegian lives next to the blue house.
  15. The man who smokes Blends has a neighbor who drinks water.
This seemed a bit of neat problem to solve using the material explained in the book, just for fun. We will use both helper procedures defined in the text:

(define (require p)
  (if (not p) (amb)))

and
(define (distinct? items)
  (cond ((null? items) true)
        ((null? (cdr items)) true)
        ((member (car items) (cdr items)) false)
        (else (distinct? (cdr items)))))
Also, the houses will be abstracted using a constructor and several selector procedures. The constructor simply glues together the information related to a house:
(define (make-house number color pet beverage nationality cigar)
  (list number color pet beverage nationality cigar))
The selectors are responsible for the extraction of the information of a house we are interested on:
(define (number-of house) (car house))
(define (color-of house) (car (cdr house)))
(define (pet-of house) (car (cdr (cdr house))))
(define (beverage-of house) (car (cdr (cdr (cdr house)))))
(define (nationality-of house) (car (cdr (cdr (cdr (cdr house))))))
(define (cigar-of house) (car (cdr (cdr (cdr (cdr (cdr house)))))))

Every house, in order to be eligible for a solution, must fulfill a set of rules as described in the hints list above, namely:
(define (required-rules house)
  (if (eq? (color-of house) 'red) ;by hint 1
      (require (eq? (nationality-of house) 'British)))
  (if (eq? (nationality-of house) 'British) ; by hint 1
      (require (eq? (color-of house) 'red)))
  (if (eq? (nationality-of house) 'Swede) ; by hint 2
      (require (eq? (pet-of house) 'dogs)))
  (if (eq? (pet-of house) 'dogs) ; by hint 2
      (require (eq? (nationality-of house) 'Swede)))
  (if (eq? (nationality-of house) 'Dane) ; by hint 3
      (require (eq? (beverage-of house) 'tea)))
  (if (eq? (beverage-of house) 'tea) ; by hint 3
      (require (eq? (nationality-of house) 'Dane)))
  (if (eq? (color-of house) 'green) ; by hint 5
      (require (eq? (beverage-of house) 'coffee)))
  (if (eq? (beverage-of house) 'coffee) ; by hint 5
      (require (eq? (color-of house) 'green)))
  (if (eq? (cigar-of house) 'PallMall) ; by hint 6
      (require (eq? (pet-of house) 'birds)))
  (if (eq? (pet-of house) 'birds) ; by hint 6
      (require (eq? (cigar-of house) 'PallMall)))
  (if (eq? (color-of house) 'yellow) ; by hint 7
      (require (eq? (cigar-of house) 'Dunhill)))
  (if (eq? (cigar-of house) 'Dunhill) ; by hint 7
      (require (eq? (color-of house) 'yellow)))
  (if (eq? (cigar-of house) 'BlueMaster) ; by hint 12
      (require (eq? (beverage-of house) 'beer)))
  (if (eq? (beverage-of house) 'beer) ; by hint 12
      (require (eq? (cigar-of house) 'BlueMaster)))
  (if (eq? (nationality-of house) 'German) ; by hint 13
      (require (eq? (cigar-of house) 'Prince)))
  (if (eq? (cigar-of house) 'Prince) ; by hint 13
      (require (eq? (nationality-of house) 'German))))

In addition, some of the rules are applicable only to the whole set of houses, for instance the positioning of the neighbors. To enforce those rules, the following helper procedure is defined:
(define (index-of value extractor houses)
  (define (iter index rest)
    (cond ((null? rest) 0)
          ((eq? (extractor (car rest)) value) index)
          (else (iter (+ index 1) (cdr rest)))))
  (iter 1 houses))
index-of returns the number of the house whose value matches the argument. For example, (index-of ‘beer beverage-of the-houses) will return the number of the house in which the guy who drinks beer lives. This procedure is used by the actual procedure that deals with global restrictions:
(define (require-global-rules houses)
  (let ((white-index (index-of 'white color-of houses))
        (green-index (index-of 'green color-of houses))
        (blends-index (index-of 'Blends cigar-of houses))
        (cats-index (index-of 'cats pet-of houses))
        (horses-index (index-of 'horses pet-of houses))
        (dunhill-index (index-of 'Dunhill cigar-of houses))
        (water-index (index-of 'water beverage-of houses)))
    (if (and (> green-index 0)
             (> white-index 0))
        (require (= (- white-index green-index) 1))) ; by hint 4
    (if (and (> blends-index 0)
             (> cats-index 0)
             (> water-index 0))
        (begin
          (require (= (abs (- blends-index cats-index)) 1)) ; by hint 10
          (require (= (abs (- blends-index water-index)) 1)))) ; by hint 15
    (if (and (> horses-index 0)
             (> dunhill-index 0))
        (require (= (abs (- horses-index dunhill-index)) 1))))) ; by hint 11
Finally, the main procedure that implements the nondeterministic search:
(define (einsteins-riddle)
  (let ((color-one (amb 'red 'green 'yellow))
        (pet-one (amb 'dogs 'birds 'cats 'horses 'fishes))
        (beverage-one (amb 'tea 'coffee 'beer 'water))
        (nationality-one 'Norwegian) ; by hint 9
        (cigar-one (amb 'PallMall 'Dunhill 'Blends 'BlueMaster 'Prince)))
    (let ((one (make-house 1 color-one pet-one beverage-one nationality-one cigar-one)))
      (required-rules one)
      (let ((color-two 'blue) ; by hint 14
            (pet-two (amb 'dogs 'birds 'cats 'horses 'fishes))
            (beverage-two (amb 'tea 'coffee 'beer 'water))
            (nationality-two (amb 'British 'Swede 'Dane 'German))
            (cigar-two (amb 'PallMall 'Dunhill 'Blends 'BlueMaster 'Prince)))
        (require (distinct? (list pet-one pet-two)))
        (require (distinct? (list beverage-one beverage-two)))
        (require (distinct? (list cigar-one cigar-two)))
        (let ((two (make-house 2 color-two pet-two beverage-two nationality-two cigar-two)))
          (required-rules two)
          (let ((color-three (amb 'red 'green 'yellow))
                (pet-three (amb 'dogs 'birds 'cats 'horses 'fishes))
                (beverage-three 'milk) ; by hint 8
                (nationality-three (amb 'British 'Swede 'Dane 'German))
                (cigar-three (amb 'PallMall 'Dunhill 'Blends 'BlueMaster 'Prince)))
            (require (distinct? (list color-one color-three)))
            (require (distinct? (list pet-one pet-two pet-three)))
            (require (distinct? (list nationality-two nationality-three)))
            (require (distinct? (list cigar-one cigar-two cigar-three)))
            (let ((three (make-house 3 color-three pet-three beverage-three nationality-three cigar-three)))
              (required-rules three)
              (let ((color-four (amb 'red 'green 'white 'yellow))
                    (pet-four (amb 'dogs 'birds 'cats 'horses 'fishes))
                    (beverage-four (amb 'tea 'coffee 'beer 'water))
                    (nationality-four (amb 'British 'Swede 'Dane 'German))
                    (cigar-four (amb 'PallMall 'Dunhill 'Blends 'BlueMaster 'Prince)))
                (require (distinct? (list color-one color-three color-four)))
                (require (distinct? (list pet-one pet-two pet-three pet-four)))
                (require (distinct? (list beverage-one beverage-two beverage-four)))
                (require (distinct? (list nationality-two nationality-three nationality-four)))
                (require (distinct? (list cigar-one cigar-two cigar-three cigar-four)))
                (let ((four (make-house 4 color-four pet-four beverage-four nationality-four cigar-four)))
                  (required-rules four)
                  (let ((color-five (amb 'red 'green 'white 'yellow))
                        (pet-five (amb 'dogs 'birds 'cats 'horses 'fishes))
                        (beverage-five (amb 'tea 'coffee 'beer 'water))
                        (nationality-five (amb 'British 'Swede 'Dane 'German))
                        (cigar-five (amb 'PallMall 'Dunhill 'Blends 'BlueMaster 'Prince)))
                    (require (distinct? (list color-one color-three color-four color-five)))
                    (require (distinct? (list pet-one pet-two pet-three pet-four pet-five)))
                    (require (distinct? (list beverage-one beverage-two beverage-four beverage-five)))
                    (require (distinct? (list nationality-two nationality-three nationality-four nationality-five)))
                    (require (distinct? (list cigar-one cigar-two cigar-three cigar-four cigar-five)))
                    (let ((five (make-house 5 color-five pet-five beverage-five nationality-five cigar-five)))
                      (required-rules five)
                      (require-global-rules (list one two three four five))
                      (list one two three four five))))))))))))

This procedure might seem threatening, but it is quite easy to follow. For each generated house, we require that:
  1. It complies with the rules enforced by the procedure required-rules.
  2. Its items are different than those of the previous houses.
After the fifth house is generated, we apply require-global-rules to filter the final solutions that are returned as a value of einsteins-riddle.

Solving the Riddle
When we pass the expression (einsteins-riddle) to the underlying nondeterministic interpreter, the final and unique solution is computed and returned:
;;; Amb-Eval input:

;;; Starting a new problem
;;; Amb-Eval value:
((1 yellow cats water Norwegian Dunhill) (2 blue horses tea Dane Blends) (3 red birds milk British PallMall) (4 green fishes coffee German Prince) (5 white dogs beer Swede BlueMaster))

;;; Amb-Eval input:
try-again

;;; There are no more values of
(einsteins-riddle)

Or more viewable:

House 1 House 2 House 3 House 4 House 5
Color
yellow
blue
red
green
white
Pet cats horses birds fishes dogs
Beverage water tea milk coffee beer
Nationality Norwegian Dane British German Swede
Cigar Dunhill Blends Pall Mall Prince Blue Master

I wonder if this qualifies this program as part of that 2% the world population able to solve the Einstein’s Riddle…

You might want to have a look at how search optimization sucks, click here.
To subscribe to the "Guy WhoSteals" feed, click here.
You can add yourself to the GuyWhoSteals fanpage on Facebook or follow GuyWhoSteals on Twitter.
Read the personal side of me here.

Read disk error. Fuck you!!!

This is one of the most frustrating error messages you can ever deal with. Sometimes the fix is simple, sometimes it's a complete pain. Having recently dealt with this again, I thought I'd post my thoughts in the hopes that it helps someone else out there.

So you receive the dreaded "a disk read error occurred. Press Ctrl+Alt+Del to restart". Multiple restarts result in the same error message.

If you put your drive into another computer, or connecting it as a slave on your own computer, it will typically work fine, and no data is missing.

Because this error is not usually associated with data loss, DO NOT RE-PARTITION THE DRIVE. Your data is likely safe and sound.

Here's how we'll recover your data. Try each step below, in order, and see if your drive becomes accessible after each step. In my experience, you won't start seeing results until step 5 or so.

1. Run CHKDSK /R /P from the recovery console (it will typically find no error)
2. run FIXBOOT from recovery console (typically has no result)
3. run FIXMBR from recovery console (typically has no result)
4. Run the manufacturer's diagnostic utility, downloaded from their website (it will typically find no error)
5. Changing the drives from cable select to Master/Slave may fix it.
6. Replacing the data cable may fix it, but usually not.
7. Setting the BIOS to use defaults may fix it, but usually not.
8. Changing the BIOS drive settings from auto to user-specified, ensuring that LBA is selected may fix it.
9. Pulling the CMOS battery to let the BIOS lose it settings may work.

At this point, you may be feeling some frustration. :-)

If all that fails, here's what will usually work:

Ghost your data to a new drive, and use the original one as a slave. It will work. And all of your data will still be accessible. Your computer should boot normally. If it doesn't, or it there are errors, run the Repair Installation option from your Windows boot CD.

But why does this happen? Nobody seems to know why. The problem typically evades all forms of detection.

Here's what I've learned: this error message likely has more to do with a hardware interaction between the drive and your system than any actual issues with the drive. To put it one way, your motherboard and drive are no longer on speaking terms.

I don't know why the original disk has no problems being a slave. Perhaps it got tired of running the show. Perhaps it's preparing for retirement.

I hope this helps!

A true gem for creationists

The temperature of Heaven can be rather accurately computed from available data.

Our authority is Isaiah 30:26, "Moreover, the light of the Moon shall be as the light of the Sun and the light of the Sun shall be sevenfold, as the light of seven days." Thus Heaven receives from the Moon as much radiation as we do from the Sun, and in addition seven times seven (49) times as much as the Earth does from the Sun, or fifty times in all. The light we receive from the Moon is one ten-thousandth of the light we receive from the Sun, so we can ignore that. With these data we can compute the temperature of Heaven.

The radiation falling on Heaven will heat it to the point where the heat lost by radiation is just equal to the heat received by radiation, i.e., Heaven loses fifty times as much heat as the Earth by radiation. Using the Stefan-Boltzmann law for radiation, (H/E)^4 = 50, where E is the absolute temperature of the earth (~300K), gives H as 798K (525C). The exact temperature of Hell cannot be computed, but it must be less than 444.6C, the temperature at which brimstone or sulphur changes from a liquid to a gas.

Revelations 21:8 says "But the fearful, and unbelieving ... shall have their part in the lake which burneth with fire and brimstone." A lake of molten brimstone means that its temperature must be at or below the boiling point, or 444.6C (Above this point it would be a vapor, not a lake.)

We have, then, that Heaven, at 525C, is hotter than Hell at 445C.

                -- "Applied Optics", vol. 11, A14, 1972

Sigh

Let's have a quick look at the main goings-on in South Africa. I haven't done that for a while, because it was too depressing. I guess I was right to avoid it.

The enfant terrible of South African politics, Julius Malema (a regular in these posts and known for his many dodgy dealings with government tenders) has thought of something new. After trying to revive the struggle against Apartheid, attempts to copy Robert Mugabe's way of handled the Zimbabwean economy, and an ongoing campaign to nationalize all assets that contribute to the South African economy, he now claims that the oppressed masses of South Africa are being looted by banks, "which are all owned by white males". He also believes that nationalization of the mines could pay for university education. Riiiighhtt... Ehm... Which planet did you say you're from, Julius?

A new batch of proposed changes to the Immigration Act will soon force me to jump through even more difficult hoops. Foreigners will now personally have to visit offices of the department of home affairs or a foreign embassy to apply for permits to enter the country. Read: you will no longer be allowed to go through an intermediary such as an immigration service company or an attorney or lawyer. Needless to say, this is an unmitigated disaster. Most Home Affairs offices are in a terrible state, and one can expect to stand (not sit) in queues for literally days on end - I once spent a total of four whole days standing in the Home Affairs office in Germiston just to get a three month extension on a three month tourist visum. Also, it will make "no difference whether the applicant is the chief executive of a multi-million rand company or a student wanting to study in South Africa". In other words, if Bill Gates or Richard Branson wants to come and work in South Africa, he must stand in line with several hundred hopefuls (none of which have had a shower recently) from Zimbabwe, Nigeria, Mozambique, Cote d'Ivoire, Somalia and who knows where else. Well... if that doesn't encourage them to invest in the South African economy, I don't know what will... :-(

With the Soccer World Cup over it's now time to pay the piper - as we all knew (or should have known) was going to happen. The Green Point stadium in Cape Town, built to the tune of 4.4 billion Rand because FIFA didn't consider the existing stadiums fancy enough, will cost R46.5 million Rand a year in maintenance, management and operational costs. Because the stadium is "underutilized" (read: it's just been sitting there since the soccer final a few months ago) there's no way that the stadium will generate enough income to cover even a fraction of that, and there are no commercial parties interested in leasing it - the last one just pulled out. So it will be up to the tax payer to finance the ownership of these white elephants - because the Cape Town stadium isn't the only one. The stadium in Nelspruit, for example, hasn't seen more than a few soccer matches and (if memory serves) one minor sports game in the week following the final, and the lights haven't been on ever since. In fact some stadiums have already started to fall somewhat into disrepair.

As usual, South Africa is a circus... and the biggest clowns are in charge.

Corruption is not for amateurs

Oh dear oh dear... It appears that a taxi driver has gotten himself in trouble by trying to offer a 20 Rand bribe to a traffic cop, and now has to appear in court on charges of corruption. Tsk.

Well, and rightly so. I mean, what an idiot! Everyone knows that the going rate for traffic cop bribes is at least R100! Of course you're going to get yourself arrested when you offer the guy only R20! He's going to feel insulted and pissed off, and he's going to get all righteous all of a sudden and haul your ass to jail! What else do you expect?

To illustrate the state of justice in South Africa: metro police spokesperson Wayne Minnaar stated that "motorists who attempt to bribe officers who are not corrupt, will be arrested and have to appear in court to be charged with corruption." (Emphasis mine.) I kid you not, that's what he said. A police spokesman makes a statement on a very minor and unremarkable case, but he does feel the need to make the distinction, and apply his statement only to officers who are not corrupt. Go figure.

The message, then, is clear: you will feel the wrath of the law and be snared by the mighty arm of justice... but only if you try to bribe a cop who is not corrupt. Fortunately there's not much chance of that - they're a bit rare these days. And when you attempt to bribe one who is (which mean in the overwhelming majority of cases) then of course you're purrrrrfectly alright...

A witch! A witch!

There is no denying that the soccer worldcup games of 2010 have been a great success, especially where South Africa's new and improved image in the eyes of the world. No stone has been left unturned to keep the problems that continue to plague the country (such as crime, poverty, miserable living conditions, dysfunctional municipal and governmental services) out of sight. Soccer fans are very enthusiastic, and return home convinced that South Africa is a modern country with an infrastructure and society that are on par with the best ones found in Europe and the US.

Apart from a slight case of witchcraft, that is.

Artist Yiull Damaso, who feels that art should provoke an emotional response, has created a modern version of Rembrand's The Anatomy lesson of Dr. Nicolaes Tulp. In Damaso's version the knife is wielded by the late AIDS orphan Nkhosi Johnson, while the cadaver is that of Nelson Mandela. The onlookers are political figures such as de Klerk, Zuma, Mbeki and opposition leader Zille.

Whether or not this is within the limits of good taste is up for debate - which is not unusual for daring expressions of art. But the ANC has slammed it for entirely different reasons. Not only do they call the painting "racist" (because everything that displeases the ANC is considered racist these days) but the real problem is that we're dealing with a typical manifestation of witchcraft: "In African society it is a foreign act of ubuthakathi (witchcraft) to kill a living person..." according to the ANC's statement.

Witchcraft is not uncommon in South Africa. Every now and then people are killed because they are suspected of witchcraft. Even more people (especially children) are being killed and slaughtered for muti - a form of traditional healing that uses human organs for certain rituals and treatments, and even (if desperate measures are required) human sacrifice. Yes, we are talking about South Africa in the year 2010 - the country that currently hosts the soccer world cup.

There is even a "Witchcraft Suppression Act" in South African law. This bill states that:
6 Any person who conducts himself in the manner below shall be guilty of an offence:-
1 (a) Imputes to any other person the causing, by supernatural means, of any disease in or injury or damage to any person or thing, or who names or indicates any other person as a wizard;
(b) In circumstances indicating that he professes or pretends to use any supernatural power, witchcraft, sorcery, enchantment or disappointment of any person or thing to any other person;
(c) Employs or solicits any witchdoctor, witch-finder or any other person to name or indicate any person as a wizard;
(d) Professes a knowledge of witchcraft, or the use of charms, advises any person how to bewitch, injure or damage any person or thing, or supplies any person with any pretended means of witchcraft;
(e) On the advice of any inyanga, witch-finder or other person or on the ground of any pretended knowledge of witchcraft, uses or causes to be put into operational any means or process which, in accordance with such advice or his own belief, is calculated to injure or damage any person or thing; and
(f) For gain pretends to exercise or use any supernatural powers, witchcraft, sorcery or enchantment.
There is no denying that South Africa has done a brilliant PR job. It's a bit of a shame, of course, that all this money and effort has gone into hiding the country's real problems from the world, rather than solving them, but that's politics for you, I suppose...

Well, that was it, then...

Micheal Dell sucks!

Why did I order a computer from Dell? I guess I had a good opinion from 6 years ago when I last bought something from them.
Let's count the ways in which their customer service has failed me. (And my computer isn't even here yet.)
  1. As documented, their website couldn't process my credit card without a phone call.
  2. After a week of my computer being "in production", I started getting more phone calls from an unidentified phone number that Google told me was Dell. Fearing another billing problem, I called back. And I was told "Thanks for calling, but our order tracking system is down. And we're all going home. Call back tomorrow morning.".
    If only Dell had some means to acquire reliable computer systems on which to build their order tracking database.
  3. I called the next day and was told my order was fine. I was also told (per script, I'm certain) that I could check my order status on Dell's website. Which of course I knew. I know it costs the company money every time someone calls, and they try to strongly discourage calls for that reason, but their script made it sound like I was an imbecile.
    I found it quite condescending. I dislike these canned scripts pander to the lowest common denominator of customer. They should be happy to take my call. I just spend upwards of a thousand dollars on their crap.
  4. Turns out the phone calls I was getting were from someone trying to give me "free internet from Shaw or Telus for 3 months", and I was eligible because I bought a Dell computer. So I was being telemarketed before my computer even got here.
    I said I already had internet service, and they said "Oh, too bad, it's for new customers only." I do not appreciate this.
  5. I got an email saying my order shipped. Joy! 20 minutes later I got an email saying my order was delayed, and if it didn't ship in 5 days I should call. What?
    It really did ship though, I have a tracking number. Why the contradictory emails?
All of my phone dealings with Dell were via some offshored far-eastern country, judging by the accents of the phone reps. I have nothing against this in principle; I'm not a xenophobe. But the phone connection is always so static-filled and laggy that it really puts a damper on communication.
My computer isn't here yet, and I just hope to God it works and doesn't break in a month. I kind of wish this article had come out a week earlier.
That'll teach me for trying to save time, I guess. Next time I'll build my own system from scratch. Dell goes onto my List of Companies Not to Buy From in the Future (LCNBFF), along with Westinghouse and oh so many others.
Related Posts Plugin for WordPress, Blogger...
top
Share