Tutorials

warning: Creating default object from empty value in /home1/tylofout/public_html/modules/taxonomy/taxonomy.pages.inc on line 33.
The following posts are tutorials that I have written up primarily to remind myself, but I thought they could be worthwhile to someone else. Some of these tutorials will only work on a Ubuntu or other Debian based Linux distributions, while others are more general programming concepts.

Returning Pointers From Functions

This is something that was not entirely obvious to me. My problem was that I wanted to return a character pointer to a string of characters in a safe and easy way. The following listing is a simple C++ program that will compile, but contains a couple semantic errors.

Programming Interview Question: Vector

Look at the following program written in C++ and see if you can spot the error. Assume that populate_vector() is a function that returns a vector. (Note: This program will compile.)

#include <vector>
 
int main() {
   const int x = 5;
 
   std::vector<int> myvector = populate_vector();
 
   int size = myvector.size();
 
   for(int i = 0; i < size; i++){
      if(myvector.at(i) == x) {
         myvector.erase(myvector.begin()+i);
      }
   }
   return 0;
}

To view the solution click read more.

Edit Picture Metadata With exiv2

Have you ever uploaded your pictures from a camera only to find out that the your cameras dates and times had reset to the wrong date? Then, have you ever wanted to change images metadata to the correct dates and times? This is a problem that I encounter every once in a while and it usually becomes a chore to find a utility to change this data. I've discovered a great command line program to fix all your metadata problems, exiv2.

Fixing Audio in Ubuntu

A major problem that I have had for a while in Ubuntu has been the audio, especially when flash is involved. If I go to a web page that plays flash (e.g. youtube.com) Firefox takes control over all the audio on my computer. All other audio on the computer stops working. This is extremely annoying. One way to fix this is to close Firefox, but it sometimes takes a few minuets or it doesn't fix the problem at all.

Using the command "ps -aux | grep audio" showed me that a program pulseaudio is running. For a while I though pulseaudio was the problem because running "killall pulseaudio" would fix the problem. After doing some research I realized that pulesaudio is actually a powerful tool that I have just scratched the surface. By changed the "Audio output module" in VLC to "Pulseaudio audio output" I no longer have this problem between flash in Firefox and audio in VLC. Unfortunately I couldn't fix this problem with Amarok or Songbird, but this is at least a start. I will continue to investigate into this problem.

Send Email Via Comman Line

Here is a short explanation on how to send an email from the command line using sendEmail.  I will also explain a few of the problems that I encountered when attempting to do this in Ubuntu 8.04.