Tag Archives: Ubuntu

Wordpress Plugin

Some old posts restored and Other updates

I know that I haven’t post anything in a while. I have been busying with the new site lately. In fact, today is the first time I visited this blog after the last post I wrote about two weeks ago.

Anyway, I discovered that the traffic has been surprisingly increasing since this blog relaunched a while ago. All of these traffic surges are thanks to the posts I wrote two years ago or so when I was still using Linux. As you know, I already deleted these posts because of the white screen of death, which means that the visitors of these links were presented with the 404 error page.

Based on the traffic log, I restored some of the posts which are still popular today from my backup copy of the site. These posts didn’t actually stored in the WordPress files. They stored in the WordPress MySQL database. I will write about how to do a scheduled backup of the database in another post.

Here are the restored posts with no specific order:

Unfortunately, not all of the posts are recoverable. Here is one post which I couldn’t find. I can’t remember the exact content for the post. But by looking at its URL, I think it is about using jQuery to generate the breadcrumb navigation.

The URL for each of these post are maintained so that others can visit the posts from other sites without updating their links. This is achieved by changing the publishing date to the original publishing date. For example, the publishing date for the post wrote on 12/19/2010 was set to 12/19/2010 and so on.

The content for these posts are almost original. I removed the images in these posts since I don’t have them anymore. The original comments were retained for nearly all of the posts thanks to Disqus.

I will be adding more of these old posts as they appear in the traffic log.

Now onto the updates for the site. In the next several days, I will be creating the child theme for this blog based on the Twenty Twelve theme. The upcoming posts will be the daily report for the child theme features of the day.

As of right now, I’m focusing on the WordPress development, mainly the plugin. For the last several months, I have been modifying the WordPress plugins for others. Recently I started my own WordPress plugin project. It will be used to managing my modified plugins and others’ feedbacks for  my plugin modification service. If all goes well, I will publish this plugin to the WordPress plugins repo.

That’s all for this post. Be sure to leave a comment below to discuss which of my old posts do you want me to publish except for those that were already on the blog, as well as other feedbacks for this post.

Reinstall Ubuntu on CR-48 notebook with USB

Introduction

According to the /etc/X11/xorg.conf in the Chrome OS, the USB devices need to be manually mounted (AutoAddDevices=’false’). I inserted a sample USB device and run lsusb command to see if detected. It detected successfully without any problem. I then copied the image file with 5GB of size onto the USB drive with a little bit of issue. Using only steps from one small section on the official Chromium OS page, I was able to successfully reinstall Ubuntu on the Chrome OS in about 45 minutes (and downgraded to 10.04 since WebDAV support is broken in 10.10). Here are the detailed steps:

Steps

  1. You need an empty USB thumb drive. The file we are going to copy to the USB drive is more than a little 5GB. The file system for the most flash drives is vfat (FAT file system). It has a single file size limit of about 3GB which our file would fail to copy to the disk. To solve this issue, you need to reformat your flash drive to the file system format other than FAT using the Disk Utility from System -> Administration menu.
  2. Copy rootfs.bin you converted from VDI image to the USB drive.
  3. After it’s finished, insert the drive into the USB slot of CR-48.
  4. Boot into Chrome OS, press Ctrl + Alt + => to switch to develop mode, and login as chronos.
  5. Type sudo su to login to root and type the following line to get the information on where the USB drive is located:[bash]dmesg | grep sd[/bash]
  6. My USB drive is located at /dev/sdb1, so I type the following to the command line (replace sdb1 with yours):

    [bash]
    mkdir /tmp/usb
    mount /dev/sdb1 /tmp/usb
    [/bash]

  7. After it’s mounted, copy rootfs.bin to sda7 with dd command:[bash]
    cd /tmp/usb
    cat rootfs.bin | dd of=/dev/sda7
    [/bash]

    This should take about 20 minutes.

  8. Mount sda7 after that and copy the necessary files to the disk:[bash]
    mkdir /tmp/urfs
    mount /dev/sda7 /tmp/urfs
    cd /tmp/urfs
    cp /usr/bin/cgpt usr/bin/cgpt
    chmod a+rx usr/bin/cgpt
    cd /lib/modules
    cp -ar * /tmp/urfs/lib/modules/
    [/bash]
  9. And finally, don’t forget to unmount the disk:[bash]
    umount /tmp/urfs
    umount /tmp/usb
    [/bash]
  10. There you have it, a brand new Ubuntu installation. You can use the following command to boot into Ubuntu or use the aliases from my last post:[bash]
    cgpt add -i 6 -P 5 -S 1 /dev/sda
    [/bash]

Have issues?

Do you have any issues with any of the steps above? Please feel free to discuss them below.

My First Tip on using Ubuntu with Chrome OS on CR-48 Notebook (Updated)

Update (12/19/2010): I wrote a post on how to use your flash/USB drive to (re)install Ubuntu on the CR-48. Check it out.

Update (12/18/2010): I just discovered that .bashrc file is never executed in Chrome OS unless running another bash after chronos is logged in, and .profile is the file which being executed after each login. Therefore I changed the following instruction to .profile for Chrome OS. If you already created .bashrc file in the chronos home folder, you just have to rename it to .profile using the command below:

[bash]
mv .bashrc .profile
[/bash]

Introduction

I have used the newly received CR-48 from Google for two days. I enjoyed so far for web browsing, but not so for web development / programming. Since I couldn’t find any good IDE on the cloud which has support for WebDAV, I decided to following the instruction on the Chromium Project website to install Ubuntu onto this device. After several hours of installation, Ubuntu loaded to the device. However, because it comes from a VirtualBox disk image, it’s nearly impossible to reinstall Ubuntu without re-transferring the disk image from my laptop to this notebook which is a 5GB file, it would spend another 5 hours just for transferring this file over ssh. I’m trying to shorten this long waiting hours. I will post another tip if I find a way. But for now, here are the two scripts I wrote to switch between Ubuntu and Chrome OS using the alias command.

Steps

First of all, I assume you also received a CR-48 notebook and installed Ubuntu on it by following on this page.

This first script is for Ubuntu:

  1. Open the file named .bashrc in the home folder using your favorite text editor (make sure to show the hidden files by pressing Ctrl+H).
  2. Add the following line to the end of the file:
    [bash]
    alias chromeos=’sudo cgpt add -i 6 -P 0 -S 0 /dev/sda;echo "Switched to Chrome OS, restart the machine to take effect"’
    [/bash]
  3. Open a new terminal window to load the new alias.
  4. Type chromeos and a message will be displayed stating that you need to restart to switch to Chrome OS
  5. Restart your device and you are in the Chrome OS.

Now inside the Chrome OS:

  1. Press Ctrl + Alt + -> (the Forward button in the first row) and login as chronos
  2. Since Chrome OS also uses bash, we can write to the .profile file, but this time in the chronos home folder.
    [bash]
    qemacs .profile
    [/bash]

    The command above creates and opens a new file called .profile inside the home folder using the only text editor available in Chrome OS qemacs.

  3. Insert the following line into .profile
    [bash]
    alias ubuntu=’sudo cgpt add -i 6 -P 5 -S 1 /dev/sda;echo "Switched to Ubuntu, restart the machine to take effect"’
    [/bash]
  4. Execute bash to launch another instance of bash, or if you are confused, you could just logoff current session by typing exit command and login again.
  5. Typing ubuntu command to switch to Ubuntu on the next startup.
  6. Restart your device to begin using Ubuntu.

In the future, you could just use chromeos and ubuntu commands to switch back and forth between Chrome OS and Ubuntu without changing back to normal mode using the small switch on the back of the battery.

Enjoy the free dual-boot notebook from Google.

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 this page 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.
  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.

Do you have any questions regarding the import process? Feel free to leave a comment below.

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.

Running Sims 3 under PlayOnLinux in Ubuntu Linux

Back 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.

Create a Wallpaper Slideshow on Ubuntu (Updated)

UPDATE (08/24/2010): I added one more step in the last part of this post. Please see the detailed step below.

I have many collections of wallpapers that I downloaded from DeviantArt.com, art.gnome.org, and other sites, but I never used them as my desktop wallpapers, mainly because I didn’t want to manually switch wallpaper from time to time. Recently I have had an idea to make a slideshow from these wallpapers thanks to the cosmos wallpaper collection in the background section in the Appearance Preferences on Ubuntu. After I took a look in the cosmos directory in /usr/share/backgrounds/, I discovered that the slideshow is controlled by a xml file. The content of the xml file is very straightforward:

<background>
<starttime>
<year>2009</year>
<month>08</month>
<day>04</day>
<hour>00</hour>
<minute>00</minute>
<second>00</second>
</starttime>
<!– This animation will start at midnight. –>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/cosmos/cloud.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/cosmos/cloud.jpg</from>
<to>/usr/share/backgrounds/cosmos/comet.jpg</to>
</transition>

</background>

You should understand the format of the above xml content very easily. If not, here are my basic explanation for each syntax:

  • <background> needs to be wrapped outside the whole document, it gives Ubuntu the ability to open this file as background/wallpaper.
  • You can set the values inside <starttime> to whenever you want to start the slideshow. The syntax inside <starttime> is self-explanatory. If you set the start time before the time right now, the slideshow will start automatically after you open this xml file as wallpaper in the Appearance Preferences window.
  • <static> contains two properties, <duration> and <file>.
    • <duration> is the time to display the wallpaper before change to the next wallpaper in seconds.
    • <file> is the absolute location that the wallpaper is located.
      (You can place each wallpaper and this xml file in different location if you want, but I prefer to place these files in one folder)
  • <transition> contains three properties that controls the time and direction that slideshow is transit to.
    • <duration> is the time that the transition will take in seconds.
    • <from> is the location of the current wallpaper.
    • <to> is the location of the next wallpaper.
  • Repeat the <static> and <transition> process as you want as long as you have different wallpapers.
  • In the last <transition>, you must place the first wallpaper in this list into the <to> property in order to loop your wallpapers continuously.

Here is the backgrounds.xml file that I created:

<background>
 <starttime>
  <year>2010</year>
  <month>03</month>
  <day>29</day>
  <hour>05</hour>
  <minute>38</minute>
  <second>00</second>
 </starttime>
 <static>
  <duration>50.0</duration>
  <file>/home/robbychen/Downloads/Wallpapers/dreamyblue.png</file>
 </static>
 <transition>
  <duration>5.0</duration>
  <from>/home/robbychen/Downloads/Wallpapers/dreamyblue.png</from>
  <to>/home/robbychen/Downloads/Wallpapers/dreamybrown.png</to>
 </transition>
 <static>
  <duration>50.0</duration>
  <file>/home/robbychen/Downloads/Wallpapers/dreamybrown.png</file>
 </static>
 <transition>
  <duration>5.0</duration>
  <from>/home/robbychen/Downloads/Wallpapers/dreamybrown.png</from>
  <to>/home/robbychen/Downloads/Wallpapers/dreamycrimson.png</to>
 </transition>
 <static>
  <duration>50.0</duration>
  <file>/home/robbychen/Downloads/Wallpapers/dreamycrimson.png</file>
 </static>
 <transition>
  <duration>5.0</duration>
  <from>/home/robbychen/Downloads/Wallpapers/dreamycrimson.png</from>
  <to>/home/robbychen/Downloads/Wallpapers/dreamyinverted.png</to>
 </transition>
 <static>
  <duration>50.0</duration>
  <file>/home/robbychen/Downloads/Wallpapers/dreamyinverted.png</file>
 </static>
 <transition>
  <duration>5.0</duration>
  <from>/home/robbychen/Downloads/Wallpapers/dreamyinverted.png</from>
  <to>/home/robbychen/Downloads/Wallpapers/Linux_wallpaper_by_varian.jpg</to>
 </transition>
 <static>
  <duration>50.0</duration>
  <file>/home/robbychen/Downloads/Wallpapers/Linux_wallpaper_by_varian.jpg</file>
 </static>
 <transition>
  <duration>5.0</duration>
  <from>/home/robbychen/Downloads/Wallpapers/Linux_wallpaper_by_varian.jpg</from>
  <to>/home/robbychen/Downloads/Wallpapers/Ubuntu-Sun.png</to>
 </transition>
 <static>
  <duration>50.0</duration>
  <file>/home/robbychen/Downloads/Wallpapers/Ubuntu-Sun.png</file>
 </static>
 <transition>
  <duration>5.0</duration>
  <from>/home/robbychen/Downloads/Wallpapers/Ubuntu-Sun.png</from>
  <to>/home/robbychen/Downloads/Wallpapers/dreamyblue.png</to>
 </transition>
 </background>

After you created this file, open the Appearance Preferences and go to Background section. Click Add button and select the xml file that you created.
Update (08/24/2010): As I described in the comment below, you need to select All files on top of the Open button in the Add Wallpaper dialog box (default is Images) in order to see the xml file.
Click open and you should see a stack of images that is similar to the cosmos background:

Visit here to learn more about XML, and please leave a comment if you have any problem creating your own slideshow. I will be glad to help you.