9

Changing Back to the Original Schedule and First Video Post (Updated)

Update (12/08/2010): For some of you having trouble to run the PHP script, I posted a tutorial on how to install web server with PHP to help you who are non web developers to run the PHP scripts I wrote. Take a look here and leave a comment if you have any questions.

Update (08/25/2010): The video quality has been improved thanks to OpenShot. Note that to watch the original HD quality, you must switch to 720p or 1080p. I also fixed the PHP script to exclude the XML file inside the background.xml file so that the slideshow can run smoothly without an empty image.

After weeks of consideration, I finally decided to change back to my original post schedule of one post per day. Two posts each day simply doesn’t work for me.

I also plan to make a video version of the post along with each post. Here is my first video showing how to create a wallpaper slideshow in Ubuntu, one of the popular posts I wrote back to March of this year:

The steps in the video are different from the post. I recorded this video this afternoon. Just before that, I wrote a PHP script that can generate background.xml file for me.  You can download the PHP script here:
http://blog2.robbychen.com/Ubuntu/slideshow.tar.gz

To use this script, you must first change the permission of the folder where the images are to 777. You may change it back to original permission after that for security reason.

If you have any problem running this script, please leave a comment below.

4

C Increment and Decrement Operators

C Plus Plus Minus MinusPrograms coded with short-hand operators can run several milliseconds faster. Same as increment and decrement operators. They are — (minus minus) and ++ (plus plus). The following example shows the usage of these two operators:

x = y + z++; // z is incremented by one after x was calculated
x = y + --z; // Decrement z by one first, then calculate x

In the above example, if y = 2 and z = 4:

x = 2 + 4++ => x = 6 (z has become 5, x doesn’t change since it’s already calculated)
x = 2 + –4 => x = 2 + 3 => x = 5 (z first decremented to 3, and then calculates x)

As you can see, the position of the operator is very important.

Here is the sample code for these operators:

/*
 * inDecrement.c
 *
 * Program to illustrate the use of the increment
 * and decrement operators
 *
 * by Mark Virtue, 2001.
 *
*/

#include <stdio.h>

main() {
 int x, y, z = 1;

 y = 5;
 x = 6;

 puts(""); // Prints out a new line
 printf("Before: x = %d, y = %d, z = %dn", x, y, z);

 z = x++ + ++y; // First y is incremented to 6, and then z gets calculated to 12. Lastly, x is incremented to 7

 puts("");
 puts("z = x++ + ++y");
 printf("After: x = %d, y = %d, z = %dn", x, y, z);

 puts("");
 printf("Before: x = %d, y = %d, z = %dn", x, y, z);

 z = x++ - --y; // Same format as above

 puts("");
 puts("z = x++ - --y");
 printf("After: x = %d, y = %d, z = %dn", x, y, z);

 fflush(stdin);
 getchar();
}

And here is the output for the above code:

C Increment and Decrement Operators

Output for the above sample code. Click the image to enlarge.

If you have any question regarding the increment and decrement operators, leave a comment below.

10

Running Sims 3 under PlayOnLinux in Ubuntu Linux

The Sims 3 running on GNU/LinuxBack when I was using Windows Vista years ago, I played The Sims 3 and other games for several hours. Once I switched to GNU/Linux, I got rid of these games when I failed to run them under Wine. However, for some reasons, I found a folder which stores The Sims 3 ISO file while cleaning and organize the hard drives today that I downloaded from a website that I don’t remember anymore. I searched over on the Wine database and found that the game and its expansion packs are in the gold state which I assume that it works very well on the GNU/Linux platform.

After searching around in the Ubuntu repositories, I discovered PlayOnLinux which is the front-end of Wine. I installed it and found out that there are almost all the Windows software and games that are pre-configured by PlayOnLinux. One thing that I discovered when I was running The Sims 3 under PlayOnLinux is that the sound would go out about one minute after running the game. The following is the solution that I came up with the help of this PlayOnLinux forum thread:

  1. Open the terminal and type playonlinux to run the GUI which you can add to the GNOME Menu manually with this command. Read this article on detailed instructions on how to do this.
  2. Install the game by clicking the Install button on the toolbar and follow the instruction.
  3. Run the game you installed. If it doesn’t have any sound problem, enjoy the program. Otherwise, go on to the next step.
  4. Follow the instruction on the first post of this thread under the FIX section.
  5. Instead of using last step on that thread, create a launcher on the desktop with the following information:
    Type: Application
    Name: The program name that you installed in step 2. In my case is Sims 3.
    Command: padsp playonlinux –run “The Sims 3″
    (Replace The Sims 3 with the program name that you want to run, note that this name must exactly the same with the name listed in the PlayOnLinux main window, otherwise it will fail to run)
    Comment: Optional. You can add your own description.
  6. You can add an unique icon by clicking the button on the left and select a JPG image.
  7. Click the launcher that you created and enjoy the game.
  8. You can also add this launcher to the GNOME menu by following the instruction from the link I provided in step 1.

If you have any problem for the above steps, leave a comment below and I will try to help as quick as possible. Note that I will not answer comments other than sound problem, especially the CD-related issue for the legal concern of my hosting provider.