Thursday, May 29, 2008

File Browsing Tip

the unix command cd is often not included as a command that sudo can do. In order to open up folders that somehow not viewable because it belongs to another user, you must sudo gnome-open to open up a gnome browser to view the folder.

Wednesday, May 28, 2008

Lenovo, just how good is it

I just saw a blog regarding the quality of Lenovo T61p xealcom.co.uk

I always thought that Lenovo actually have good laptop quality, but it turns out that it might not be correct. A friend of mine's Lenovo t41p just broke. he has been using it for the past 3 years. So I would say that even though Lenovo thinkpad series are engineered to stand security and physical abuse, the normal quality of computer parts the company use to make their hardware are not durable.

I was talking to my co-worker today. and He said that most power supplies are not providing the level of voltage they are tested to provide, which greatly reduces the life time of capacitors and inductors in computers. Normally, capacitors are tested to last long enough under cretain amount of voltage, let's say 10 volts, but if the power supply is supplying the capacitor 15 volts, the capacitor will only have half of its guaranteed life time. A good power supply lengthen the life time of a computer greatly because of that.

.. okay, that may not be related to the topic i was saying.

my point is that Lenovo thinkpads truely has some really nicely engineered features that no other brands offer: shock mounted hard drive, magnesium + carbon fibre monitor encasing, steel turn hinges, low power comsumption motherboard, replacable compartment, and last but not least, keyboard sink holes in case of spill. Its normal computer components are average: my frined's monitor LCD screen just died after 3 years of use, not-so durable motherboard, normal power supply and such. Thus its key components arnt really any better than other brands. It may prevent youe from destrying the laptop due to accidents, but it doesn't guarantee that the laptop will have a longer normal lifespan. and if you like to take really good care of your laptop, any PC brand can just be as good as lenovo.

Things to do when installing Ubuntu on Lenovo T61p with Nvidia graphic card

Just found out that for some weird reason that after installation my Ubuntu does not use my swap partition. With some detection, i found out that the /etc/fstab is using a partition with the wrong UUID as the swap partition and therefore the system does not enable swap. so I think I'll have to make a reminder list of things to do after installing Ubuntu:

Things to do after installing Ubuntu on Lenovo T61p with Discrete graphic card:

1. Install Nvidia graphic card
2. setup program update source and update software
3. edit /etc/fstab and enter all other partitions into designated folders
4. edit /boot/grub/menu.lst to include other OS if there is any
5. set ~/Downloads folder as the default firefox downloads folder
6. enable/download Compiz fusion and setup conpiz fusion
7. download and install Kiba-Dock
8. download the latest JDK and install into /usr/lib/jvm
9. using update manager to get latest Java
10. download the latest version of Eclipse and NetBeans and install them into /usr/lib; create a link in /usr/bin to those executables; edit /usr/share/Applications to include those programs as application in category development
11. install latest Apache into /usr/lib and setup Apache
12. install administration applications: boot manager, firestarter, partition editor

Thursday, May 22, 2008

C++ Namespace buzz

namespace has proven more tricky than I thought. I have always thought of it like an env created in more powerful langauges such as Dr.Scheme and Haskell, but there are quite some major differences, some syntaxes of namespaces with just minor details will cause drastic differences. here is what i learned:

1. namespace is just like how Scheme represent functional environments using the let syntax, execept namespace allows you to give a name to the environment for other files to references to it (let itself in Scheme doesn't do it, you must use define syntax to define a variable and then combine it with the let)

2. to reference to a namespace env, you can using either syntax: using namespace name; or directive syntax :: . those 2 things mean totally different things, however:

using namespace name;

using syntax basically loads all the env variable symbol into the current env, but does not bind them automatically! those symbols will be bind to the definition during linking. it is less powerful than the directive :: . it probably work like this:

load into current env symbol binding pair (symbol,

directive ::

the directive is more powerful, it automatically binds the env symbol to the definition. using directive does not create any symbol binding in the env, but just directly links the namespace_symbol::symbol into the definition directly inside the namespace

alternatively, you are also allowed to write:

using namespace name::symbol;

this declaration work just like directive, binding the env symbol to the definition right away, also making the rest of the env to alias any symbol without the namespace declaration to the same symbol defined inside the namespace. i.e.

using namespace std::string;

string st = "string";

this code basically says load namespace std's into current env with binding with binding pairs: (string, std::string) and (std::string, )

-----------------------------------------------------

so, with the compiler behaivior defined, here comes the interesting part: classes and data in a namespace are compiled as part of the namespace, i.e. if thinking of namespace as functions with its own scope, then the local variables are basically being part of the function, whereas functions being declared inside this function is not physically inside this function, but through compilation, is in another part of the program that is labeled to be inside this function's local env.

now this leads to a problem, whenever you declare a function inside a namespace, and you declare it in one .cpp file, inside the file you used the
directive symbol loading to define the function, the function is not automatically linked into the header file's namespace function because the using directive only loads the name, but since .cpp files can also have functions for itself, it assumes this function belong to the file, not the namespace during linking.

so as a result, an linking error pops whenever you use this function somewhere else, saying this function is not defined.

however, this will not happen to namespace objects and data using the directive, because the linker assumes the symbol taken first by the namespace.

------------------------------------------------------------

on side note, namespace can be declared without a name, creating an anonymous environment, but it behaves like this:

namespace uniquely_generated_label{
data...
}
using namespace uniquely_generated_label;

which actually looks quite like the Dr.Scheme functional define + let thingie.
though, those unamed namespace can only be used inside the file that declares it.

TODO: try what happens to the env symbol if 1 symbol is inside of 1 un-named namespace of another un-named namespace, and being accessed outside both namespaces at the later part of the file

UPDATE 1:

typing

using namespace nspace::func1;

will generate an error stating that func1 is not an object in namespace, this could only mean that c++ treats functions just as primitive as C, where all functions are basically from the same environment, any functions that are inside a namespace basically have the compiler extended their function name with the namespace name. and therefore, functions are not treated as objects still, just a name tag.

this leaves only 1 way to define any functions in C++ namespace: using the :: directive.

more on namespace without names later

Wednesday, May 21, 2008

Adding another linux os into linux grub boot list

finally fixed my ubuntu grub to include a option of booting up fedora 9 today. Apparently it could have been because I was tired when I was writing the fedora boot info into the grub menu.lst. first I mounted my fedora's partition, went to the /boot/grub and retrieved the menu item that boots up itself, copied it into ubuntu grub. it didn't work. and the problem that it doesn't work is becuase there are two initrd images, and i used the wrong one. the correct initrd i should be using is

/boot/initrd-2.6.25-14.fc9.i686.img



it was not because of the root= value, which was actually correct (even though during the failed fedora booting up, it says it's because it cannot find such partition as what the root= describes)

the correct value for root= should be the UUID of the parition, which can be retrieved using the command:

ls -l /dev/disk/by-uuid

Tuesday, May 20, 2008

wxWidget 2.4.2 library wxHashMap

spent 3 hours trying to fix the wxHashMap. the tutorial for using wxHashMap is completely wrong and not working. Even if I copy the example out and build them in VC++ IDE, it will not work (linking error)

I searched the samples in wxWidget 2.4.2, there is only 1 sample that uses wxHashMap, and ironically it only tests it on declaring the hash map, but NOT using it... way to go sample writers

TODO: test out wxHashMap in newest wxWidget 2.8.7

update:

wxHashMap works just like the one in the tutorial in version 2.8.7