Jun 24, 2009

Compile Programs in Linux

People new to linux find it often difficult to install programs from source. However, if the first hurdle is overcome, people appreciate that the fact that most programs are open-source gives you great freedom of choice. Miss a function? Maybe you find it in a nightly-build. Find a bug? Maybe you find the bug-fix already in the new source.

If you want to install a program by compiling from source, this usually begins by downloading a tarball and extracting it using the tar utility. If the file extension is tar use tar -xvvf file.tar, if it is gz use tar -xzvf file.tar.gz, for bz2 use tar -jxvf file.tar.bz2.

The GNU Compiler Collection (GCC), which includes compilers for C, C++, Fortran and other programming languages. In order to be able to compile programs you need to have GCC and some libraries installed. In ubuntu, you'll install it typing:
>> sudo apt-get install build-essential

Usually, to compile a C program to binary myprogram you type:
>> gcc -o myprogram myprogram.c
or, for C++
>> g++ -o myprogram myprogram.cpp

However, most programs that you would download need more than that. They need some configuration, detect dependencies, among other things. Usually you'll find a readme file that carries you through the steps of installation. Typical these would be configure; make; sudo make install.

What happens often is that you get back some error that you miss some library that you've never heard of. In some cases you would spend hours searching forums in order to find out in which package the library is located. A simpler way to find out you in which package your library is located is:
>> apt-file search package

If you use the rpm package manager, similarly you can use:
>> rpm -q package

Jun 22, 2009

Physical Exercise and Brain Function

The hippocampus is essential for learning, memory, and mood regulation. Given the high metabolic demands of hippocampal neurons, it is not surprising that the function of hippocampal cells would be influenced by energy expenditure and intake and that the energy budget in turn would influence brain function. This is what this post is about. I just read two reviews about this topic and would like to summarize some of the arguments.

The first one is called "Impact of Energy Intake and Expenditure on Neuronal Plasticity" written by Alexis M. Stranahan and Mark P. Mattson. A summary in bullet points (esp. of this nice graphic).

Some effects of nutrition on brain function:
  • Food high in saturated fats and cholesterol increases the risk of cognitive decline,
  • Caloric restriction benefits learning (neuroplasticity) and protects the brain from effects of stress.
Physical activity enhances regional cerebral blood volume in the hippocampus, in parallel with improvements in declarative memory. Physical exercise increases neurogenesis, medial perforant path long-term potentiation (LTP), dendritic spine density. Brain-derived neurotrophic factor (BDNF), a neurotrophin, recognized as a potent modulator of neuronal excitability, synaptic function, and hippocampal morphology, is increased with exercise and caloric restriction. Running upregulates BDNF and can protect against stress-induced downregulation of BDNF. Insulin-like growth factor (IGF-1) is produced in a variety of organs, including the liver, muscle, and brain. Administration of exogenous IGF-1 ameliorates cognitive deficits in diabetic animals, and enhances hippocampal learning in non-diabetic animals. Additionally, the effects of running on hippocampal BDNF levels are prevented when peripheral upregulation of IGF-1 is blocked. Physical exercise increases:
  • Corticosterone, involved in the regulation of stress responses.
  • Neurotrophines, a class of growth factors, which are capable of signaling particular cells to survive, differentiate, or grow.
  • Increased plasticity in hippocampus. Plasticity is important for learning and memory function. Physical exercise increases
    • adult neurogenesis,
    • synaptic plasticity,
    • dendritic plasticity.

The second review is called "Exercise and the brain: something to chew on" by Henriette van Praag about combinations of nutrition and exercise for brain function. It focuses on dietary supplement to enhance the effect of exercise on improving brain function. Candidate food is:
  • omega-3 fatty acid (e.g. fish oil),
  • teas,
  • fruits,
  • folate (vitamin B9),
  • spices, and
  • vitamins.
Van Praag notes that plant-derived products such as grapes, blueberries, strawberries, tea and cocoa (chocolate!) are particularly interesting. She notes further that rather than observing a ceiling effect of exercise in young people, being active makes a functional difference. In addition, exercise in childhood might increase the resilience of the brain later in life, resulting in a so-called cognitive reserve, resilience to neuropathological damage of the brain. She lists advantages of physical exercise as the following:
  • it improves cognition and might delay age-related memory decline
  • it protects against brain damage caused by stroke
  • it promotes recovery after brain injury
  • it is an antidepressant.
In this article, discussion of combined effects of nutrition and exercise is rather short. There is not much literature yet, the author concludes.

Jun 16, 2009

Synchronize Browser Bookmarks

I often switch between different computers and synchronization of data can be painful at times. Fortunately, my online reading list is completely unaffected by the change of computer, because my browser bookmarks get automatically synchronized. In this post I show how easy it is to set this up.

I can synchronize my browser bookmarks on different computers, and access and edit them on-line. Overviews over bookmark synchronization software can be found here and here. I use the XMarks plugin which supports Mozilla Firefox, Internet Explorer and Apple Safari.

See the Xmarks advertising (earlier called Foxmarks).

Enjoy. Please tell me how you synchronize your bookmarks.

Jun 9, 2009

Getting a Data Projector to Work in Linux

Getting a data projector to work can be quite annoying. You are nervous, because you have a presentation and on top of the stress the projector might not work properly. In this post I talk about some of the issues involved and give some pointers about how to resolve them.

See this tutorial presentation on how to get data projectors to work.

Of course, it is really bad publicity if you don't get the data projector to work. Just today I was watching a guy with ubuntu trying to give a presentation and trying to help him get it work. Finally somebody brought a windows computer. I am using linux exclusively and usually I am enjoying it, but these two issues make me consider to have a double boot with linux and windows.

I just searched for troubleshooting the data projector issue. I found that for many people reconfiguring the X Server (running dpkg-reconfigure xserver-xorg or editing /etc/X11/xorg.conf) and restarting it works, although it failed for other people.

If you have a newer version of X, you might notice that your /etc/X11/xorg.conf has become much cleaner. This is because many modes are automatically recognized rather than configured. As part of the XRandR project) many external devices should be able to hotplug ideally making it unnecessary to change any configurations. Thanks to this post to point it out.

Jun 8, 2009

The Skeptical Environmentalist

I used to think that we are living in a polluted world with few years left on the doomsday clock until disaster will strike us with the punishment deserved by us for destroying mother nature. Like many others: Gallup reported in April that most Americans think that the environment is getting worse. Examples for this thinking can be found abundantly in the media.

Reading The Skeptical Environmentalist brought about many paradigm shifts for me. I found it a remarkable book, well-written and broad in scope. The second title being "Measuring the Real State of the World," it looks into many different aspects of environmental problems, well being of humanity, and global warming, and looks into seriousness and approaches to solution from a cost-benefit perspective.

The book has been criticized a lot (how not?) but has likewise found praise from many sides. The author Bjørn Lomborg uses global and historic statistics to analyze whether we are developing into the right direction and what our future will look like, supplementing many charts with analyses that come from credible sources such as world bank, UNESCO, and many others.

Lomborg collaborated with several nobel prize winners on a second book, "Cool it," so I think it is safe to assume that he is not some isolated crackpot.

His conclusions are many-fold, but I'll attempt to summarize the main ones:
- There is what he calls the "Litany," a wide-spread bias towards believing in humanities doom.
- This comes from blowing up negative news and bad (but probably well-meant) statistics (his reviews of some literature reveals stunning errors in statistics).
- Our health, well-being, the environment in many aspects, are becoming much better over the years and still will become much better.
- It is important to prioritize and choose where to spend limited resources.
- Money could be most effectively spent in education, infrastructure, and sanitation, and
- Market economy seems to work. Environmental regulations could have adverse effects and benefits are slight as compared to other policy decisions (with respect to e.g. taking costs of life-years saved per dollar).
- Natural catastrophes, deaths, and malaria are probably not going to increase because of global warming.
- We are living in a good world.
- We are not going to die out as punishments for our sins.

Not convinced? See and hear Bjørn Lomborg at TED talks. His talk is called "Our priorities for saving the world." See whether he can make you call your convictions into question.

Jun 5, 2009

Tomboy - a Note Taking Application

Tomboy is an open-source desktop note-taking application for Linux, Windows, and MacOS. Notes are connected over a wiki which makes it an excellent tool for personal information management. In this post I give a short introduction to tomboy.

Tomboy supports synchronization, export to HTML and pdf, reminders, and todo lists, and formulae in LaTeX.

A criticism to tomboy is that it is implemented in the mono programming language. In Ubuntu Karmic Koala a port from mono to C++ will be available as Gnote. For the Android there is tomdroid, a project, which aims to be compatible and able to sync notes with tomboy.

This screencast shows how it works and what it looks like.


Notes can be synchronized using ssh, webdav, or locally mounted directories (see this blog post for example). However the caveat is that tomboy saves notes all the time even when just looking at them, so you will always have two versions and later synchronization requires user's decision on which note to keep, which can be very tiresome if you have many notes.

Watch out for Snowy, a coming web application designed to power an upcoming Tomboy Online free web service where any tomboy user can viewing, synchronize, edit, and share notes. First support for snowy is included in tomboy version. 0.15.1.

Jun 4, 2009

Remote Backup Server

I was searching for a hosting service that I could use for remote backup, synchronization, and revision control. It should have reliable and easy access and allow me to use scp, rsync, and svn, among other programs. In this post I explain what I found and motivate my final choice.

I started in wikipedia, checking the list of online backup services and the article on online storage, then I read a pc world article without finding enlightenment. Most of the services seem to be directed at say "Windows Power Users." I finally found answers in a slashdot discussion about the identical question Best Online Remote Backup Service w/Linux Client?

Turns out Jungle Disk is quite cheap and there is also blacksun. I decided in the end to sign with rsync that offers discounts for educational staff and students. I took the minimum volume of 8GB and payed about 36 euros for the entire year. I received a short mail with all the relevant information and so far I am happy.

You might also see my cheat-sheet of basic subversion commands and the short tutorial on automatic synchronization.

Jun 2, 2009

Debugging in Java

Sun provides the Java Platform Debugger Architecture, an API for debugging. The debugger JDB (java debugger) is a simple demonstration of how to use the API. JDB works similarly to GDB. Netbeans and Eclipse offer more comfortable controls. Anyways, in this post I give a short introduction to the JDB command line interface.

Here come the most important commands in JDB:

To run jdb in ubuntu (as stand-alone, or from within an IDE), make sure your hostname corresponds to your current ip address when you are running jdb (edit /etc/hosts, then restart networking). [1]

Launching of application similar to java command

jdb -classpath CP package1.package2.program

As I mentioned, basic commands resemble gdb's. There is run, cont, where (dump trace, similar to gdb's bt), print, next, step.

You set breakpoints with stop. Syntax:

stop in .[(argument_type,...)]
stop at : -- set a breakpoint at a line

As stated before, there are more sophisticated ways to debug java. This video is the first part of an introduction to debugging in java using eclipse. Enjoy!