Archive for September, 2005

What is blog for..? (#2)

Tuesday, September 27th, 2005

A few months ago, I have a question for myself.., "What is blog for..?"

This time, I’ll answer the question. Pretty funny huh.. I ask the question, and then I answer the question.

My main purpose of writing blog is to practice writing and to learn how to deliver idea (lagi kepingin belajar nulis inggris :D ). How come..? Why..? Because blog is published to anyone and anybody can read it. So, I will try to write my blog as best as I can, for I believe that it could be read by anyone. If I only practice writing on a piece of paper or anything which is not published publicly, I think, the result could not be good enough. As people say, "learning by doing", If you want to learn, the best way to practice is by doing it.

But, I’m sure that each bloggers might have different idea about blog. :) just like this one (warning: the site contains quite rude language, but also funny and interesting.. I think).
 

Yahoo mail: Character String Verification Error

Tuesday, September 20th, 2005

I really feel frustrated with yahoo mail this time.. :(

I was composing an application letter (yes, I’m looking for a new job)..  After pressing the ’send’ button, it’s not the usual page that appeared, but a page asking me to enter some characters for verification to make sure I’m not a bot (yahoo said it’s helpful to prevent abusers and spammers). There’s an image containing distorted characters:

Yahoo_verification

I entered: dTVVK and clicked the continue button. Unfortunately, yahoo mail said I entered wrong characters. Here is what I got:

Character String Verification Error

You need to pass the verification test to send any more email.

Your message has not been sent and will not be saved.

What makes me feel very bad is, yahoo mail help page said like this: "If you guess incorrectly, you will have an opportunity to enter a different word on the next screen.". But the fact…. instead of having a chance to enter a different word for the verification, I lost my unsent email… :(

I’ve tried to compose and send the same mail for three times, and none of them sent successfully. All ended up with character string verification error. Having no clue.. I asked uncle Google, hoping the similar problem happened not only to me.. Well, I found blog complaining the same thing with me here. But I still don’t get the idea of how to pass the verification.. :(

Nevertheless.. for about one month ago, it also happened to me.. after composing the mail, I was asked the verification characters. But at that time, I could pass it easily. dunno why..

Yahoo_verification_againOn the left is another distorted string (click the image to see full size). I entered HTnX but the same error page occured.

Anyone know the solution, please help me..

Nintendo New Controller

Saturday, September 17th, 2005

MediaI’m not a gamer.. , but this news is really interesting because of the idea. Nintendo obviously makes radical changes from the common game controller type to its new revolutionary controller.

The new
controller looks like a remote control of TV, with sensors placed near
the TV. The sensors function is to detect the position and orientation of the controller, which enable player to swing or aim it as a sword or gun. The controller itself also has an expansion port at the bottom of the unit for adding an add-on hardware/accessories.

Personally, I think the new controller design is really a great idea, although it might take some time to make used to it.

For more detail of the story, can be read here.

 

   
   

Here are some other pictures taken from 1up.com.Media2Media3

String to Number, Number to String

Friday, September 16th, 2005

There are many features of C++ which make easier to code than of C.
For example is to convert a type of number to string, and vice versa. I used to
call function such as atoi() and its brothers and sisters to do the conversion,
but I think, by using the trait of C++ it looks cooler and easier.. hehehe..

After seeing example from cprogramming.com (I forget the exact page link), I
learn that to do conversion between string and number,
ostringstream/istringstream classes and input/output operator ( >>
and << ) can be used (by including sstream). To simplify the
usage, I create two functions numtostr() and strtonum() which convert any number
(integer, char, float, double, etc) to string, and string to any number. These
two functions are based on the example I’ve seen. I only add the template and a
little modification to make it easier to use.

Here is the code and the example (in total, there are 3 files: convert.h and convert.inl
contain the conversion function, and main.cpp
is the example).

file convert.h:

/**
file name: convert.h
*/

#ifndef MY_CONVERT_H
#define MY_CONVERT_H

#include <sstream>

using namespace std;

/* *
function name : numtostr()
used to convert T to string *
parameter:
i : variable with type T
return value: string contains the value of T
*/

template<class T>
string numtostr(const T i);

/* *
function name : strtonum()
used to convert string to T
parameter:
s : string to convert
o : the output (variable of T contains the converted value)
return value:
true means success, false means failed
*/

template<class T>
bool strtonum(const string &s, T &o);

#include "convert.inl"
#endif

file convert.inl:

template<class T>
string numtostr(const T i)
{
    ostringstream output;
    output << i << flush;
    return output.str();
}

template<class T>
bool strtonum(const string &s, T &o)
{
    istringstream input(s);
    if (input >> o)
        return true;
    return false;
}

And here is the main.cpp:

#include
<iostream>
#include "convert.h"

int main()
{
    double d = 0;
    int i = 0;
    char c = 0;

    string s = "";

    //string to double
    s = "0.25";
    if (strtonum(s, d))
        cout << "converting
string "
<< s << " to
double : "
<< d << "
success"
<< endl;
    else
        cout << "converting
string "
<< s << " to
double : "
<< d << "
failed"
<< endl;

    //string to integer
    s = "25";
    if (strtonum(s, i))
        cout << "converting
string "
<< s << " to
integer : "
<< i << "
success"
<< endl;
    else
        cout << "converting
string "
<< s << " to
integer : "
<< i << "
failed"
<< endl;

    //string to char
    s = "A";
    if (strtonum(s, c))
        cout << "converting
string "
<< s << " to
char : "
<< c << "
success"
<< endl;
    else
        cout << "converting
string "
<< s << " to
char : "
<< c << "
failed"
<< endl;

   
    s = "";
    //double/integer/char to string
    cout << "converting
double "
<< d << " to
string "
<< numtostr(d) << "
ok"
<< endl;
    cout << "converting
integer "
<< i << " to
string "
<< numtostr(i) << "
ok"
<< endl;
    cout << "converting
char "
<< c << " to
string "
<< numtostr(c) << "
ok"
<< endl;

    return 0;
}

However, I’m still wondering whether these functions perform better or worse
than atoi() families. ^^’