< Browse > Home /

How to add Open in Terminal support To Nautilus in Ubuntu

March 9th, 2010 | No Comments | Posted in Linux, Tips, Ubuntu by Diego | - [Full Entry]

Wouldn’t it be great to open up Nautlius (equivalent to Windows-Explorer in Ubuntu) and be able to open up your terminal in that specific folder by simply right clicking and choosing an Open in Terminal option? Unfortunately this option isn’t set by default. Luckily there are two ways to install this option.

  1. Installing through the terminal (easiest)
  2. Installing through the Synaptic Package Manager

Read more »

C++ Recursion – Printing Elements of a Vector

February 21st, 2010 | No Comments | Posted in C++ by Diego | - [Full Entry]

Printing elements of a Vector using Recursion


Below is an example of how to print the elements of a vector using recursion. Later, we’ll print the elements in reverse. Why is this useful? You can apply this principle later to more complex data structures such as Binary Search Trees, or Linked Lists.

This tutorial assumes you understand the following:

Iterative version for printing elements of a vector


To understand how to print elements of a vector using recursion, let’s write a simple algorithm that will do it for us using iteration.

void printVector(vector <int> vec) {
   
     for ( int i = 0; i < vec.size(); i++ ) {

          //Printing ith element  followed by a space
          cout << vec[i] << " ";

     }

     //Printing end line
     cout << endl;
}

Read more »

C++ Recursion – Power Continued

February 11th, 2010 | No Comments | Posted in C++ by Diego | - [Full Entry]

Creating a power function using Recursion


So, previously we tried computing the Power function using recursion but we didn’t take into account when the exponent was negative. This continues the previous function, so if you haven’t yet, go back. Make sure you understand the following as well:

  1. C++ Recursion
  2. C++ Recursion – Summation
  3. C++ Recursion – Factorial

Power Function using Recursion


Below is our previous power function which takes into account only positive exponents. So how would we go on by taking into account negative exponents?

int power(int base, int exp) {
     
     //Return 1 when n is 0
     if ( n == 0 )
          return 1;
     else if ( n == 1 )
           return base;
     else
          return base * power(base, exp-1);
     int result = base;

}

Let’s start by coming up with a formula again.

power(2,-1) = (1/2);

power(2,-2) = (1/2) * power(2, -1) = (1/2) * (1/2) = (1/4);

power(2,-3) = (1/2) * power(2,-2) = (1/2) * (1/4) = (1/8);

power(2,-4) = (1/2) * power(2,-3) = (1/2) * (1/8) = (1/16);

//Until exp == -1
power(base, -exp) = (1/base) * power(base, exp+1);

Taking into account negative exponents


So now that we have a formula, what would be our base case? We surely don’t want our previous base case to return 1 when (n==0) because that would be wrong.
Read more »

Using Workspaces in Ubuntu

February 10th, 2010 | No Comments | Posted in Linux, Tips & Tricks by Diego | - [Full Entry]

Workspaces allows you to organize your GNOME Desktop in Ubuntu by creating virtual desktops from which you can place your applications. In my case, I like having two files I’m currently working on my first workspace, my browser in the second, and so on. That way, I only have to switch through the spaces instead of having to bring up the windows individually.

This in turn increases productivity since Workspaces allows you to focus on things that you need to get done, instead of sifting through your applications on simply one screen.

Setting up Workspaces in Ubuntu

To set up a Workspace you can simply right click on a panel and choose Add to panel and select Workspace Switcher. This by default should add four Workspaces to wherever you clicked on your panel. To change this, simply right click your Workspace Switcher, and choose Preferences

So now that you have them you can switch to them by clicking on them, or preferably by pressing CTRL + ALT + RIGHT, or instead of RIGHT: LEFT, UP, or DOWN would be fine depending on how you set up your rows and columns and where you currently are.
Read more »

How to set the Color Scheme in vim

February 9th, 2010 | No Comments | Posted in Linux, Tips & Tricks by Diego | - [Full Entry]

I’ve been using vim (or better yet, gvim) for the better part of my undergraduate programming career and for quite some time I struggled on figuring out how to set the default color scheme for gvim under Ubuntu. Well, now that I figured it out, I wanted to share it with you.

Setting the default Color Scheme in vim (gvim)


To set your colorscheme in gvim to a theme of your choice, simply edit the file named .gvimrc. It can be opened using the following in your terminal. If it doesn’t exist, simply create it.

gvim ~/.gvimrc

Then after opening the file, add the following lines of code to the file if they don’t exist yet.

 
syntax on
colorscheme slate
 

Slate (left) and Evening(right)

But why Slate you must ask? Its the one mentioned on all the other tutorials. Yes, I know, but it simply rocks. Just check it out and you’ll understand. If not you can choose from any of these other themes.
Read more »

VirtualBox – Virtualize on Windows, Mac, and Linux

February 8th, 2010 | No Comments | Posted in Software by Diego | - [Full Entry]


Create a virtual machine using VirtualBox

Virtual Box is a powerful open source x86 virtualization that runs on Windows, Linux, Mac and OpenSolaris. It supports a large number of guest operating systems such as Windows XP, Windows 7 RC, Ubuntu, Debian, SUSE, Fedora, and Red Hat. VirtualBox is free as well as many linux distributions. So if you haven’t tried any, I’d recommend you doing so.

In simpler terms, Virtual Box allows you to run another OS on top of your currently existing one. If you wanted to try installing an OS without the hassle of dual-booting, or even wanted to install another OS to do some programming since maybe Windows isn’t the best for you, then virtualiziation is one way to go. There is also no way you can harm your computer so its risk-free. If you corrupt a guest OS, simply delete it and try again.

VirtualBox Features

  • Guest Additions for Windows, Linux, and Solaris – Allows you to install software inside the OS that improves performance. Just recently the guest additions allowed users running Ubuntu to run the Visual Effects, which is nice.
  • Shared folders – Access folders from the host in the guest machines
  • Virtual USB Controllers – Connect a USB device and your virtual machine will recognize it, including USB Flash Drives.

For more features visit Virtual Box Features.

VirtualBox running Ubuntu under Windows

How to start

If you want to start, simply download Virtual Box and an OS. I’d recommend Ubuntu since thats probably the most user friendly (or so I think). If you want something else, hit up DistroWatch. Once you have that, setting up Virtual Box with the OS is pretty straightforward. I’ll add a tutorial later on for those who still need help.
Read more »

C++ Recursion – Power

February 7th, 2010 | 1 Comment | Posted in C++ by Diego | - [Full Entry]

Creating a power function using Recursion


Below is an example of how to calculate the x to the power of n. This tutorial expects you to understand the following:

  1. C++ Recursion
  2. C++ Recursion – Summation
  3. C++ Recursion – Factorial

Example:

pow(2,3);
pow(5,4);

Result:

8
125

Iterative version of a function that calculates the power function


To understand how to calculate the power function using recursion, let’s write a simple algorithm that will do it for us using iteration.

int power(int base, int exp) {

     if ( exp == 0 ) {
          return 1;
     }

     //Initial value for the result is the base
     int result = base;
     
     //Multiplies the base by itself exp number of times
     for ( int i = 1; i < exp; i++ ) {
          result = result * base;
     }

     return result;
}

Read more »

Page 1 of 912345...Last »