0

ISO Master – An Useful ISO Creator and Editor for GNU/Linux

If you are following my Twitter, identi.ca, or Facebook feed recently, you knew that I’m currently switching to Arch Linux on my laptop since I don’t like Unity to be the default UI for Ubuntu 11.04. Besides, I already lost interest with Ubuntu 10.10. This post is based on the upcoming post about my Arch Linux installation experience.

When I was installing Arch Linux, I have to change the ISO label in order to reproduce the following error message inside VirtualBox:

(Click to enlarge)

I never changed label for an ISO file in GNU/Linux. So I googled a bit and found an useful tool for creating and editing ISO files called ISO Master. It is on the Softpedia website, which is a software download and review site. Unfortunately, I don’t think this tool is in any of the GNU/Linux repositories. This means that I have to compile and install it myself. Surprisingly, after I downloaded the source file, the compiling and installing process went smoothly without any error.

After the installation was finished, I launched ISO Master from the Sound & Video application menu. The UI is clean and easy to navigate. I opened downloaded Arch Linux image file and click File → Properties. I then changed its volume name and saved as a new ISO. Thanks to this useful utility, I was able to reproduce the above screenshot, as well as my operation with ISO files in the future.

For the complete review of ISO Master, read the article on Softpedia: http://www.softpedia.com/reviews/linux/ISO-Master-Review-50543.shtml

3

The reasons why I switched back to Ubuntu 10.04

Since I installed Ubuntu 10.10 last Sunday, I always had a problem with the new version. As you already knew, one of the issues is that it couldn’t play the C program tutorials that recorded with mov files. I think the problem lies in the broken codecs. Here is the full list of issues I encountered when using 10.10:

aptitude not installed by default

When I don’t want to open the Synaptic Package Manager to manage the packages, I use apt-get to install new and upgrade existing packages and aptitude to search packages. To my surprise, the aptitude command is already not installed by default in Ubuntu 10.10 (I think that the Synaptic Package Manager will also not be installed by default in Ubuntu 11.04).

I had to manually install aptitude using the following command:

sudo apt-get install aptitude

The quick search box in Synaptic does not work

In Ubuntu 10.10, the quick search box in Synaptic Package Manager is moved to the far right of the toolbar along with the search button. Sometimes I use Synaptic to search through the packages when I’m not be able to find packages using aptitude. The quick search box is no longer functional and I had to use Search button to perform searches. I don’t like to use the Search button in Synaptic because I’m not able to clear the search history.

Some video formats cannot be played

As I stated before, the .mov files cannot be played by Totem and other players. I didn’t test other video formats, but this prevented me to learn the video tutorials from Lynda.com and VTC. I also cannot downgrade the codec packages and other related packages to the most stable one.

The Unity interface cannot open multiple instances of application

I tried the new Unity interface on my netbook. Personally, I like the old interface available in Ubuntu 10.04 a little better. The icons in the quick launch panel are related to the application and system menu in the Ubuntu 10.04 UNE. This means that I can customize the command for each item in the Main Menu editor. For example, I often use multiple Firefox profiles. I can navigate to System -> Preferences -> Main Menu and change the command of Firefox from

firefox %u

to

firefox -P -no-remote

This opens a new browsing session when clicked on the Firefox icon instead of opens a new browser window. The quick launch bar in the Unity is more like the task bar in Windows 7. It only can launch applications one time.

10.10 Installer cannot be copied to USB flash drive using UNetBootIn official Lucid version

After several failures tried to boot Ubuntu 10.10 live using USB, I noticed that I was not using the latest version of UNetBootIn. I added its PPA and tried one more time and worked. This means that I have to update the package using PPA and make the live USB before my computer was reinstalled, which means that it would take more time to install Ubuntu 10.10 then Ubuntu 10.04.

Ubuntu 10.04 is LTS, which is more stable

Ubuntu 10.04 is the Long Term Support version. Compare to 10.10, it is more stable. I will wait Ubuntu 11.04 and see if it suits me. If not, I will wait another 2 years for the LTS version.

Do you have other issues with Ubuntu 10.10? Share them in the comments below.

Note that since I have downgraded to Ubuntu 10.04, I’m able to play the .mov files. I will continue the C programming tutorials tomorrow.

4

Enable Backspace in Chromium

Since I discovered that Google doesn’t add the backspace support to its Chrome browser to navigate between web pages history, I always tried to find a way to add this shortcut key support to Chromium. I don’t like to press two or more keys combo (in this case, alt + left) just to go back one page, especially in the low-light condition when I cannot clearly see the keyboard.

Finally, with the help of an Ubuntu forum I found a Chrome extension called Backspace As Back/Forward for Linux. Once you installed this extension, the backspace key icon () would appear at the end of the URL address bar along with other extensions when the web pages history is available. Note that you need to refresh the existing opened web pages in order to activate the extension.

The only disadvantage I’ve found with this extension is that the page needs to be fully loaded in order to activate the backspace key. I think this is the nature of Chrome extension since the Chrome extensions are JavaScript / AJAX based.

2

Import additional snippets to Bluefish

Update (12/5/2010): As Matt pointed out in the comments section below, you need to replace HTML code for the special characters with raw characters during the import process. For example, replace &lt; with the less than (<) character. Scroll down for more information on the replacement process. Thanks, Matt.

In the last post, I talked about the snippets plugin in Bluefish that allows me to import HTML 5 and CSS 3 tags as well as other languages for reference and reuse purposes. This time I’m going to show you how to import the snippets from the Bluefish wiki into the Bluefish snippets menu.

  1. First, go to here to copy the xml code of your choice. Make sure not to copy the <pre> tag.
  2. Paste the copied code into a text editor and save as a xml file.
    Update (12/5/2010): Make sure to use the Find and Replace feature in your text editor to replace all the HTML code for special characters with the actual characters. Here are some common ones (HTML code is in the parentheses): < (&lt;),  > (&gt;).
  3. Start Bluefish and switch to the third tab on the left side bar which looks like the following:
  4. Right-click inside the left-side bar and choose Import.
  5. Select the xml file you just saved and click Open.
  6. If the xml code was copied correctly, there should be a new branch appear inside the left sidebar.
  7. Right-click the newly created branch and choose Edit snippet to change the displayed name if you want.
  8. Now you can browse through the code snippets and hover the cursor over one element to learn more about the new tags of HTML 5.
0

Switching my Development Environment to Bluefish (Updated)

Update (10/15/2010): It seems that the snippets plugin for Bluefish is just used for reference and reuse of code. It doesn’t affect the auto-completion feature, which disappoints me. However, it could help me to learn new HTML 5 and CSS 3 techniques.

I had always used NetBeans for my only web development environment for a long time. Today when I tried it on the netbook and felt a little sluggish. Perhaps it’s because it is a multi-purpose IDE – PHP, Java, C, and Ruby. I don’t use many of its features, such as upload and compile/run, because I use FireFTP and command line to upload and compile code. These features are waste of RAM space and I think that’s the cause to slow down the system.

Therefore I tried to search for a light-weight web development IDE for GNU/Linux and found Bluefish. It has the features I need for a perfect IDE to develop web applications. The auto-complete and spellcheck are two of my most used features. It also has the snippets plugin which I think it is used to add more tags support for the auto-completion feature, such as the HTML 5 tags add pre-defined tags for the reuse purpose.

Bluefish starts up on my netbook very fast. It also runs very smoothly compare to the NetBeans. I enjoyed using it so far. To install Bluefish, type the following command:

sudo apt-get install bluefish

It should be placed in the Programming section after installed it.

By the way, it appears to also support the C language according to the snippets, although I have not test it yet.

Please share your thoughts in the comments section on how does the Bluefish IDE work for you.

http://fireftp.mozdev.org/
0

Problem With mov file and Hold of C Tutorials

Since I upgraded to Ubuntu 10.10 last Sunday, I hadn’t watched C tutorial videos using Movie Player. I was beginning to watch them today and discovered they are not playable in the Totem Move Player anymore. Since they are mov files, I tried other players like VLC and Xine, even with OpenShot and Kdenlive, all with failure. When I was using Ubuntu 10.04, the only player that can play mov files perfectly was the Totem movie player with appropriate plugins. But now in 10.10, even the Totem player cannot play mov files. Here is the error message I got when I opened a mov file:

As I stated above, I installed and tried to play the files on almost all the video players, even with Miro, and Ubuntu still cannot play them. Therefore, I decide to pause the C tutorials posting a little while until I fixed this issue. In the mean time, I will try to keep the normal posting schedule (one post per day).

1

The C Macros

A macro is a #define plus some parameters. It looks like a mini function. For example:

#define Max(a, b)   a > b ? a : b

As you remember, #define is used to replace the text in the source code with another text that is specified in the #define line. This rule also applies to the macros.

Here is the sample code that contains the above line:

/*
 *
 * macro.c
 *
 * Program to demonstrate a #define macro
 *
 * by Mark Virtue, 2001.
 *
 */

#include <stdio.h>

#define Max(a, b)    ((a) > (b) ? (a) : (b))
#define Double(s)    ((s) * 2)

main() {
 int x, y, z;

 x = 6;
 y = 7;
 z = Max(x, y);
 z = Double(x+1);

 printf("Double x is %dn", z);

 fflush(stdin);
 getchar();
}

Note that the best way to prevent the macros to work incorrectly is to place parentheses everywhere around the parameters. In the above code, the answer will be 8 (6 + 1 * 2) instead 14 ((6 + 1) * 2) if the parentheses were not added.

Since Max() is defined to contain two parameters, there will be a compiler error if Max() only has one parameter in the source code. Below is the error message for GCC compiler if z is set to Max(y):

macro.c:21:11: error: macro "Max" requires 2 arguments, but only 1 given
0

The C #include Directive

The #include directive replaces the #include line with the content of the specified file. For example,

#include <filename.h>

It replaces the line with the content of filename.h. The extension h is known as a header file or include file. The location of these header files can be found at one of the paths specified in the include path variable of the compiler.

The #include line can also write using the format below:

#include "filename.h"

Note that the only difference between the two formats is that this one searches the specified file through current directory that the compiler will run, then search through the folders specified in the include path if it’s not found.

The header files (.h) are used to share its source code between multiple C source files. They are just like the frameworks, such as jQuery. They can also use #include directives to include other header files. And of course, we can write own header files as well.

The header files don’t contain any code that generates machine code. Instead, they can only include:

  • Other preprocessor directives (#include directives are also allowed)
  • Global and external variable declarations
  • Structure, enum and typedef definitions
  • Function declarations (prototypes)
  • Comments

Most of the items in the above list are called definitions, except for the comments.

Here is a random section of code in stdio.h located at /usr/include/ folder:

#include <libio.h>
#ifdef __USE_XOPEN
# ifdef __GNUC__
#  ifndef _VA_LIST_DEFINED
typedef _G_va_list va_list;
#   define _VA_LIST_DEFINED
#  endif
# else
#  include <stdarg.h>
# endif
#endif

Note that I will be talking about these preprocessor directives in the upcoming posts.

2

C sizeof Operator

The sizeof operator is used to determine the memory size of a variable or a type in bytes. Here are some examples:

size = sizeof array; // determine the size of an array
size = sizeof array[i]; // determine the size of i th element of the array
size = sizeof(float); //determine the total size of the float variable type in a program

As you can see, when used with variable types, the sizeof operator must use parentheses around the type name.

Below is the sample code for this operator:

/*
 *
 * sizeof.c
 *
 * Program to demonstrate the sizeof operator
 *
 * by Mark Virtue, 2001.
 *
 */

#include <stdio.h>

main() {
 int x;
 short arr[20];
 double y;
 char string[51];

 printf("The size of x (an integer) is %lu bytesn", sizeof x);
 printf("The size of arr (an array of 20 shorts) is %lu bytesn", sizeof arr);
 printf("The size of one element of arr (one short) is %lu bytesn", sizeof arr[0]);
 printf("The size of y (a double) is %lu bytesn", sizeof y);
 printf("The size of string (an array of 51 char) is %lu bytesn", sizeof string);
 printf("The size o one element of string (one char) is %lu bytesn", sizeof string[0]);
 printf("The size of a long is %lu bytesn", sizeof(long));

 fflush(stdin);
 getchar();
}

Note that I made a little change to the above code. It originally has %d in the printf statements instead of %lu. Since the gcc compiler interprets the output of sizeof operator as a long unsigned int, I changed to %lu as long unsigned. Interestingly, %li (long integer) also works.

Here is the sample code that shows the usage of this operator:

/*
 *
 * sizeof2.c
 *
 * Program to demonstrate the use of the sizeof operator
 *
 * by Mark Virtue, 2001
 *
 */

#include <stdio.h>

main() {
 int array[] = {1, 34, 65, 778, 111, 23, 782, 75, 94, 3, 100, 22, 58, 145, 72, 99, 43, 67, 278, 98, 53};
 int total = 0;
 float average;
 int i;

 for (i = 0; i < sizeof array / sizeof array[0]; i++) {
 total += array[i];
 }

 average = total / (sizeof array / sizeof array[0]);

 printf("The total is %dn", total);
 printf("The average is %.3fn", average);

 fflush(stdin);
 getchar();
}

The usage of sizeof operator in the for loop at the above code reminded me the sizeof function in PHP. Both usages are similar except C needs to divide by the size of one element in the array since C has different sizes on each variable types.

0

C ? : Operator

This operator is the conditional operator, which has the same usage in PHP and other languages. It’s the shorthand method for the if-else statement. The format of this operator as follows:

condition ? expression : expression

The first expression is the if statement, which is the true part. Another is the else statement, which is the false part. For example,

max = x > y ? x : y;

The statement shows that if x is greater than y, then max is equal to x, else max is equal to y. Here is another example:

printf("%s", gender?"male":"female");

The above example shows that if gender is set to 0, false, or undefined, it will output female. Otherwise, it will output male.

Blow is the sample code for this operator:

/*
 * conditional.c
 *
 * Program to demonstrate the conditional operator (? :)
 *
 * by Mark Virtue, 2001.
 *
 */

#include <stdio.h>

main() {
 int num1, num2;
 int answer;

 printf("Enter the first number: ");
 scanf("%d", &num1);

 printf("Enter the second number: ");
 scanf("%d", &num2);

 answer = num2==0 ? -1 : num1/num2;

 printf("%d divided by %d is %sn", num1, num2,
 answer==-1 ? "undefined" : answer%2==0 ? "even" : "odd");

 fflush(stdin);
 getchar();
}

As the above code shows, the conditional statement can be nested.

 // First conditional statement
answer==-1; // is the condition
"undefined"; // is the true part
answer%2==0 ? "even" : "odd"; // is the false part

 // Second conditional statement
answer%2==0; // is the condition
"even"; // is the true part
"odd"; // is the false part
Pages ... 1 2 3 4 5 6 7