Monthly Archive: November 2010

C Language Reference Resources

C Language Reference Resources

C Plus Plus Minus MinusThis is just a small post to list some of the references for C standard library functions:

Do you have any other resources for the C language? Please share them in the comment below.

Generating Random Numbers with C

C Plus Plus Minus Minus


There are some standard library functions for generating random numbers in C:

  • The function rand is used for generating a pseudo-random number between 0 and RAND_MAX where RAND_MAX is defined using #define. Here is an example:
  • Note that pseudo-random number means that sometimes the function will generate the same number each time the function is executed.
  • The function srand can be used to fix this issue so that it generates different random number all the time. It’s used to seed (which I think it’s the helper function) the rand function, Below is an example:

Example Code

Questions or problems?

If you have any issue compiling and running the above code, fell free to discuss them in the comment below.

Using Standard I/O Functions


Continue from the last post, this time I’m going to talk about the usage of standard I/O functions.

Example Code

The following code is copied from the original tutorial. It’s well documented by me. I also added and modified some places of the source code wherever GCC is mentioned in the comments.

Questions or Problems?

If you have any problem compile and running above source code, please leave a comment below.

Some Useful gEdit Plugins for Developers: Part Three – Third-Party Plugins (2)


In the last post, I listed few of the third-party plugins from the gEdit plugins page that are useful for developers. This post I’m going to list some more useful third-party plugins for development. Here is the list of previous posts in this series:

  1. Part One – Default Plugins and gedit-plugins
  2. Part Two – Third-Party Plugins (1)

The List

  • Focus Autosave (
    Once this plugin is enabled, the opened documents/tabs will save automatically when switching to another window. It is very useful for testing the just written code in the web browser. What I like this plugin is that it saves all the opened documents/tabs instead of save only the current document when using the auto save feature in the default gEdit preferences.
  • Line-Spacing (
    When enabling this plugin, click the Configure Plugin button to set line height in pixels between each line. The plugin could be used for reading the source code by making the lines easier to read.
  • Macro (
    This plugin reduces the code repetition by automatically enter key strokes using macro. It even has a 64-bit version. However, the plugin could store only one macro. This means that it could only store one repeatable task at a time.
  • Pair char autocompletion (
    This plugin gives gEdit the ability to add and override the closing brackets and quotes after typing these opening operators. It’s even better compare to the NetBeans editor. The plugin also supports operator which NetBeans doesn't support. This operator is normally used within SQL statements. Including this operator, the plugin also supports the following: (), [], {}, "", '', and `. There is full documentation on its Google Code project page.
  • Right Pane (
    This plugin adds another pane to the right of the gEdit window. After click the Right Side Pane from the View menu for the first time, the manage window would appear allows you to manage left and right pane allocation. After the first time, this window can be accessed through View -> Manage Left & Right Panes or press Ctrl+F10. This is useful for opening two panes at the same time like Eclipse and NetBeans editors.
  • Class Browser (
    As the name suggests, this plugin lists the variables, functions, and classes for the current document to the Side Pane for easier navigation. However, it is not on-demand, meaning that the document needs to be saved in order to trigger the plugin to refresh to the latest version. It requires to install the ctags in order to use this plugin which is very easy. After the ctags was downloaded, just execute ./configure, make, and sudo make install to install ctags to the system. After that, restart gEdit in order to completely activate plugin.


These are some gEdit plugins which I think are useful to the developers. All of these plugins are from the official gEdit website ( I believe that there are gEdit plugins out there other than this page. If you found additional plugins on other websites, please share them in the comments below.

Some Useful gEdit Plugins for Developers: Part Two – Third-Party Plugins (1)


In part 1, I listed some useful development plugins in the default gEdit installation and the gedit-plugins. In this post, I will list the first batch of useful third-party plugins for developers from the third party gEdit plugins list (

The List

  • Advanced Find/Replace (
    This plugin can search or replace specified characters whether in the current document, opened documents, or selected directory. The search results will be outputted to the Bottom Pane after a search is performed. It also highlights the search results in the document. It is useful to find a specified function or class within a project/directory.
  • AutoComplete (
    This plugin suggests words that exists in the opened documents as you type. According to its website, I think it also suggests custom libraries although I was not tested it yet. It would save me lots of time to retype the function name.
  • Session Autosave (
    Once this plugin is enabled, it will save the current opened tabs/documents on exit and reopen them when gEdit started next time. The feature is the exactly the same with NetBeans default feature for opening up last opened documents to continue editing them. However, I noticed that it only saves opened documents. This means that it will open the previously closed documents when gEdit started. The solution is to select Tools -> Session Save to refresh the session.

To Be Continued …

These are just a couple of plugins I tested. In the next post, I will list some more plugins useful for programming development. All the plugins mentioned in this post and the upcoming posts are available on the gEdit plugin page (

Do you have any gEdit plugins that does not list on the gEdit plugin page? Please share them in the comments below.

Some Useful gEdit Plugins for Developers: Part One – Default Plugins and gedit-plugins



I recently found out that gEdit has some wonderful plugins that useful as an IDE and decided to search for the additional third-party plugins which work well for my development environment. This part is focused on the default installed plugins and gedit-plugins package ( which is available in the repos of most distros. The next one (or two) part(s) will be focused on the third-party plugins (

The List

  • Code Comment
    This plugin is useful when commenting out part of the code for testing or other purpose. To comment or uncomment a block of code, select them and press Ctrl+M to comment and Shift+Ctrl+M to uncomment.
  • Color Picker
    This plugin is extremely useful to me because I always had issue with color assignment when using NetBeans and Bluefish since they don’t have an easy way to access color palette when writing CSS. To use the color picker, place the cursor where the color code will be placed, and then select Tools -> Pick Color to choose a color from the color palette.
  • Embedded Terminal
    This plugin shows an embedded terminal at the bottom panel. To see the bottom panel, select View -> Bottom Panel or press Ctrl+F9. This terminal is useful when writing a programming language such as C and want to compile and test the code without leaving the editor.
  • External Tools
    This plugin can be set up to work with external commands within the editor. It comes with some default commands and can be used as templates to add additional commands. To manage commands, select Tools -> Manage External Tools. The produced output would normally appear in the Shell Output tab at the Bottom Panel. However, it can be customized in the Manage External Tools window. If you don’t know how to write commands, here is the list of pre-made commands from the official gedit website (
  • File Browser Pane
    This plugin adds a File Browser tab to the Side Panel. If the Side Panel is not open, select View->Side Panel or press F9 to open it. It could be useful when working on a project with multiple files or just browse through the folder and open the files without leaving the editor.
  • Snippets
    This plugin adds a menu item named Manage Snippets in the Tools menu. When creating a document and saved as specified format or change the highlight mode from the View menu, the snippets shortcut is activated for that format. When entered a shortcut and press Tab, the corresponding code defined in the snippets will be expanded and can be edited in the appropriate places. Press Tab again when finished editing to complete the statement.  Note that you can download additional snippets from the official gedit website (
  • Spell Checker
    This plugin adds spell checking feature similar to the spell checking in the Word Processor. After the plugin is enabled, the Autocheck spelling can be enabled from the Tools menu to check the spelling for the current documents automatically. A red line will appear below the incorrect word. Right-click the word and hover over the Spelling Suggestions to see the suggested words to be corrected.
  • Tag list
    Once this plugin is enabled, the tag list tab will be added to the Side Panel. It is useful for reference the appropriate tags and for adding the special characters which are hard to remember. The tag can be added to the current document by double-clicking the appropriate tag.

Build a Private Git Server using VirtualBox Bridged Network

Ubuntu Tips

I had been adjusting my new GNU/Linux environment with Arch Linux lately. Almost all the utilities that I need in Arch Linux were downloaded through the AUR and then compile and install them on demand which was pretty fast. Along with the software installation in Arch Linux, I also discovered Git version control system which I think it’s useful for version control my website files. However, the only Git hosting provider GitHub offers 300MB of storage space which is not enough for my 600MB (and growing) website files. Therefore, I decided to build a private virtual Git server for self usage.

Virtual Git Server with VirtualBoxBackground

For a long time, I use NAT network interface as the default interface for the network when building a virtual machine with VirtualBox. Recently, I tried to build a virtual private Git server to version control my website files. I created a virtual machine in VirtualBox and customized it a little as usual, and installed Ubuntu Server as the server OS. After the installation was finished and logged into the server, I noticed that the IP address was which can’t be accessed both by the host system and other systems on my home network. The Networking Modes section in the VirtualBox manual ( explains that the NAT uses a virtual router to obtain the IP address whereas the Bridged uses a virtual network adapter to obtain the IP address which means that it obtained the IP address from my home router. This solves my problem for getting IP address for the virtual server to join my home network.


  1. Open VirtualBox.
  2. Choose the virtual machine with the network interface to be configured.
  3. Click Settings and select Network on the left.
  4. Choose Bridged Adapter in the “Attached to” list.
  5. Choose the appropriate physical network adapter in the Name list (I chose wlan0 since I’m using a netbook).
  6. Click OK to close the Settings dialog and click Start to start the virtual server.
  7. After the server was fully started and logged in, type “ifconfig” (without quote) to verify the IP address. If it’s like the format “192.168.0.x” or the format similar to your home network, the bridged networking is activated. Otherwise, visit the community forums ( for help.
  8. Test the network – First, test on the host system: Type the IP address you got from the previous step into the browser on the host system (in my case, on the netbook). The network is working if “It works!” default web server page appears in the browser.
  9. Then, test on another system in the same network (which is my laptop in my case): the same procedures as in the last step.
  10. If all went well, you should ssh from another system to the virtual server for remote access in order to create a Git repository.
  11. For more information on how to create a private Git server, read this article ( The steps are the same except you are setting up in a virtual server instead of a real server.

Feel free to comment below if you have any questions regarding creating a server in the VirtualBox.

My First Static WordPress Plugin (Updated)

Update: I’m no longer using ever since I swtched to Mac. The service also seems to be no longer active.

After almost 3 hours of researches and trials, I finally finished the first one-page WordPress plugin called “ reminder”. As the name suggests, it’s used for reminding me to post an update whenever I added or updated a blog post. Since ( also posts updates automatically to Twitter and Facebook, I only need to update the status for my account. And because the lack of the good WordPress plugins, I decided to manually update the status once a blog post is added or updated.

This was the first time I began to learn WordPress plugin. Thanks to the detailed documentation on the WordPress Codex wiki, I was able to learn and create the plugin at the same time. Here is the whole source code for my basic plugin (also includes very detailed comments):

Note that when I wrote and tested this plugin, the “messages[‘post’]” array cannot be changed partially. The only way I can change the value is to copy the modified value to a new array, then make the structure of the new array the same as messages’. For instance, I tried to do the following in the code above:

It seems that without this format, the add_filter function would not be executed. As the above example shows, it just applies to the “post” post type, although I have not tested it with custom post type yet.

You can download the source file here.

Below are the resources I used to help me for creating this plugin: